File: PbiBuilder_WithReader.txt

package info (click to toggle)
pbbam 2.4.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 14,148 kB
  • sloc: cpp: 60,214; xml: 2,908; ansic: 660; sh: 275; python: 203; makefile: 187
file content (30 lines) | stat: -rw-r--r-- 904 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// To simply create a PBI file from BAM, the following is the easiest method:
//
#include <pbbam/BamFile.h>
#include <pbbam/PbiFile.h>

BamFile bamFile("data.bam");
PbiFile::CreateFrom(bamFile);


// However if you need to perform additional operations while reading the BAM file, 
// you can do something like the following:
//
{
    BamFile bamFile("data.bam");
    PbiBuilder builder(bamFile.PacBioIndexFilename(), 
                       bamFile.Header().Sequences().size());
    BamReader reader(bamFile);
    BamRecord b;
    int64_t offset = reader.VirtualTell(); // first record's vOffset
    while (reader.GetNext(b)) {

        // store PBI recrod entry & get next record's vOffset
        builder.AddRecord(b, offset);
        offset = reader.VirtualTell();
   
        // ... additional stuff as needed ...
    }

} // <-- PBI data will only be written here, as PbiBuilder goes out of scope