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
|