GenomicIntervalQuery¶
#include <pbbam/GenomicIntervalQuery.h>
-
class
PacBio::BAM::
GenomicIntervalQuery
¶ The GenomicIntervalQuery class provides iterable access to a DataSet‘s BAM records, limiting results to those overlapping a GenomicInterval.
Example:
// using C++11 range-based for loop GenomicIntervalQuery query(GenomicInterval("chr1:1000-2000"), dataset); for (const BamRecord& record : query) { // ... do stuff ... } // OR // using iterators directly GenomicIntervalQuery query(GenomicInterval("chr1:1000-2000"), dataset); auto iter = query.cbegin(); auto end = query.cend(); for (; iter != end; ++iter) { // ... do stuff ... }
- Note
- Currently, all BAM files must have a corresponding ”.bai” index file. Use BamFile::EnsureStandardIndexExists before creating the query if one may not be present.
Inherits from IQuery
Public Functions
-
GenomicIntervalQuery
(const GenomicInterval &interval, const PacBio::BAM::DataSet &dataset)¶ Constructs a new GenomiIntervalQuery, limiting record results to only those overalpping a GenomicInterval.
- Parameters
interval
: genomic interval of interestdataset
: input data source(s)
- Exceptions
std::runtime_error
: on failure to open/read underlying BAM or BAI files.
-
~GenomicIntervalQuery
()¶
-
bool
GetNext
(BamRecord &r)¶ Main iteration point for record access.
Most client code should not need to use this method directly. Use iterators instead.
-
GenomicIntervalQuery &
Interval
(const GenomicInterval &interval)¶ Sets a new genomic interval.
This allows the same dataset/query to be re-used over multiple regions of interest:
DataSet ds("data.xml"); GenomicIntervalQuery query(GenomicInterval(), ds); for (const GenomicInterval& interval : intervals) { query.Interval(interval); for (const BamRecord& record : query) {} // do stuff } }
- Return
- reference to this query
- Parameters
interval
: new genomic interval
-
const GenomicInterval &
Interval
() const¶ - Return
- Current genomic interval active on this query.