BarcodeQuery

#include <pbbam/BarcodeQuery.h>
class PacBio::BAM::BarcodeQuery

The BarcodeQuery class provides iterable access to a DataSet‘s BAM records, limiting results to those matching a particular barcode.

Example:

// using C++11 range-based for loop
BarcodeQuery query(42, dataset);
for (const BamRecord& r : query) {
    assert(r.HasBarcodes());
    assert(r.BarcodeForward() == 42 || r.barcodeReverse() == 42);
}

// OR

// using iterators directly
BarcodeQuery query(42, dataset);
auto iter = query.cbegin();
auto end  = query.cend();
for (; iter != end; ++iter) {
    assert(iter->HasBarcodes());
    assert(iter->BarcodeForward() == 42 || iter->barcodeReverse() == 42);
} 

Note
Currently, all BAM files must have a corresponding ”.pbi” index file. Use BamFile::EnsurePacBioIndexExists before creating the query if one may not be present.

Inherits from IQuery

Public Functions

BarcodeQuery(const int16_t barcode, const DataSet &dataset)

Creates a new BarcodeQuery, limiting record results to only those annotated with a particular barcode ID.

See
BamRecord::Barcodes
Parameters
  • barcode: filtering criteria
  • dataset: input data source(s)
Exceptions
  • std::runtime_error: on failure to open/read underlying BAM or PBI files.

~BarcodeQuery()
bool GetNext(BamRecord &r)

Main iteration point for record access.

Most client code should not need to use this method directly. Use iterators instead.