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

The SubreadLengthQuery class provides iterable access to a DataSet‘s BAM records, limiting results to those matching a subread length criterion.


// using C++11 range-based for loop
SubreadLengthQuery query(500, Compare::GREATER_THAN_EQUAL, dataset);
for (const BamRecord& r : query) {
    assert((r.QueryEnd() - r.QueryStart()) >= 500);  

// OR

// using iterators directly
SubreadLengthQuery query(500, Compare::GREATER_THAN_EQUAL, dataset);
auto iter = query.cbegin();
auto end  = query.cend();
for (; iter != end; ++iter) {
    assert((iter->QueryEnd() - iter->QueryStart()) >= 500);

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

SubreadLengthQuery(const int32_t length, const Compare::Type compareType, const DataSet &dataset)

Creates a new SubreadLengthQuery, limiting record results to only those matching a subread length criterion.

  • length: subread length value
  • compareType: compare operator
  • 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