ZmwGroupQuery

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

The ZmwGroupQuery class provides iterable access to a DataSet‘s BAM records, limiting results to those matching a ZMW hole number whitelist, and grouping those results by hole number.

Example:

bool allHoleNumbersEqual(const vector<BamRecord>& group) 
{
    if (group.empty()) 
        return true;
    const auto firstHoleNumber = group[0].HoleNumber();
    for (size_t i = 1; i < group.size(); ++i) {
       if (group[i].HoleNumber() != firstHoleNumber)
           return false;
    }
    return true;
}

vector<int32_t> whitelist = { 50, 100 };
ZmwGroupQuery query(whitelist, dataset);
for(const vector<BamRecord>& group : query) {

    assert(allHoleNumbersEqual(group));

    for (const BamRecord& record : group) {
        assert(record.HoleNumber() == 50 ||
               record.HoleNumber() == 100);
    }
}

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 IGroupQuery

Public Functions

ZmwGroupQuery(const std::vector<int32_t> &zmwWhitelist, const DataSet &dataset)

Creates a new ZmwGroupQuery, limiting record results to only those matching a ZMW hole number criterion.

Parameters
  • zmwWhitelist: vector of allowed ZMW hole numbers
  • dataset: input data source(s)
Exceptions
  • std::runtime_error: on failure to open/read underlying BAM or PBI files.

~ZmwGroupQuery()
bool GetNext(std::vector<BamRecord> &records)

Main iteration point for record access.

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