PbiIndexedBamReader

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

The PbiIndexedBamReader class provides read-only iteration over BAM records, limited to some filtering criteria.

The PacBio BAM index (*.pbi) is used to allow random-access operations.

Inherits from PacBio::BAM::BamReader

Constructors & Related Methods

PbiIndexedBamReader(const PbiFilter &filter, const std::string &bamFilename)

Constructs BAM reader, with an initial filter.

All reads that satisfy the filter will be available.

Parameters
  • filter: PbiFilter or compatible object
  • bamFilename: input BAM filename
Exceptions
  • std::runtime_error: if either file (*.bam or *.pbi) cannot be read

PbiIndexedBamReader(const PbiFilter &filter, const BamFile &bamFile)

Constructs BAM reader, with an initial filter.

All reads that satisfy the filter will be available.

Parameters
Exceptions
  • std::runtime_error: if either file (*.bam or *.pbi) cannot be read

PbiIndexedBamReader(const PbiFilter &filter, BamFile &&bamFile)

Constructs BAM reader, with an initial filter.

All reads that satisfy the filter will be available.

Parameters
Exceptions
  • std::runtime_error: if either file (*.bam or *.pbi) cannot be read

PbiIndexedBamReader(const std::string &bamFilename)

Constructs BAM reader, with no initial filter.

Useful for delaying either specifying the filtering criteria or performing the PBI lookups.

Parameters
  • bamFilename: input BAM filename
Exceptions
  • std::runtime_error: if either file (*.bam or *.pbi) cannot be read

PbiIndexedBamReader(const BamFile &bamFile)

Constructs BAM reader, with no initial filter.

Useful for delaying either specifying the filtering criteria or performing the PBI lookups.

Parameters
Exceptions
  • std::runtime_error: if either file (*.bam or *.pbi) cannot be read

PbiIndexedBamReader(BamFile &&bamFile)

Constructs BAM reader, with no initial filter.

Useful for delaying either specifying the filtering criteria or performing the PBI lookups.

Parameters
Exceptions
  • std::runtime_error: if either file (*.bam or *.pbi) cannot be read

~PbiIndexedBamReader()

Filtering & Index Data

const PbiFilter &Filter() const

Return
the current filter active on this reader

uint32_t NumReads() const
PbiIndexedBamReader &Filter(const PbiFilter &filter)

Sets a new filter on the reader.

Return
reference to this reader
Parameters
  • filter:

Protected Functions

int ReadRawData(BGZF *bgzf, bam1_t *b)

Performs the actual raw read of the next record from the BAM file.

Default implementation will read records, sequentially, until EOF. Derived readers may use additional criteria to decide which record is “next” and when reading is done.

Return value should be equivalent to htslib’s bam_read1(): >= 0 : normal -1 : EOF (not an error) < -1 : error

Return
integer status code, see description
Parameters
  • bgzf: BGZF stream pointer
  • b: BAM record pointer