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

The PbiFilter class provides iterable access to a DataSet‘s BAM records, limiting results to those matching filter criteria.


// setup filter
PbiFilter filter;
filter.Add(PbiReadAccuracyFilter(0.9, Compare::GREATER_THAN_EQUAL));

// using C++11 range-based for loop
PbiFilterQuery query(filter, dataset);
for (const BamRecord& r : query) {
    assert(r.HoleNumber() == 42);
    assert(r.ReadAccuracy() >= 0.9);

// OR

// using iterators directly
PbiFilterQuery query(filter, dataset);
auto iter = query.cbegin();
auto end  = query.cend();
for (; iter != end; ++iter) {
    assert(iter->HoleNumber() == 42);
    assert(iter->ReadAccuracy() >= 0.9);

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

PbiFilterQuery(const PbiFilter &filter, const DataSet &dataset)

Creates a new PbiFilterQuery, limiting record results to only those matching filter criteria.

  • filter: filtering criteria
  • dataset: input data source(s)
  • std::runtime_error: on failure to open/read underlying BAM or PBI files.

bool GetNext(BamRecord &r)

Main iteration point for record access.

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

uint32_t NumReads() const

Return number of records that pass the provided filter.