1 // ***************************************************************************
2 // BamMultiReader.cpp (c) 2010 Erik Garrison, Derek Barnett
3 // Marth Lab, Department of Biology, Boston College
4 // All rights reserved.
5 // ---------------------------------------------------------------------------
6 // Last modified: 23 December 2010 (DB)
7 // ---------------------------------------------------------------------------
8 // Uses BGZF routines were adapted from the bgzf.c code developed at the Broad
10 // ---------------------------------------------------------------------------
11 // Functionality for simultaneously reading multiple BAM files.
13 // This functionality allows applications to work on very large sets of files
14 // without requiring intermediate merge, sort, and index steps for each file
15 // subset. It also improves the performance of our merge system as it
16 // precludes the need to sort merged files.
17 // ***************************************************************************
19 #include <api/BamMultiReader.h>
21 #include <api/internal/BamMultiReader_p.h>
22 using namespace BamTools;
28 // -----------------------------------------------------
29 // BamMultiReader implementation
30 // -----------------------------------------------------
32 BamMultiReader::BamMultiReader(void)
33 : d(new Internal::BamMultiReaderPrivate)
36 BamMultiReader::~BamMultiReader(void) {
41 void BamMultiReader::Close(void) {
45 bool BamMultiReader::CreateIndexes(bool useStandardIndex) {
46 return d->CreateIndexes(useStandardIndex);
49 void BamMultiReader::SetIndexCacheMode(const BamIndex::BamIndexCacheMode mode) {
50 d->SetIndexCacheMode(mode);
53 const string BamMultiReader::GetHeaderText(void) const {
54 return d->GetHeaderText();
57 bool BamMultiReader::GetNextAlignment(BamAlignment& nextAlignment) {
58 return d->GetNextAlignment(nextAlignment);
61 bool BamMultiReader::GetNextAlignmentCore(BamAlignment& nextAlignment) {
62 return d->GetNextAlignmentCore(nextAlignment);
65 const int BamMultiReader::GetReferenceCount(void) const {
66 return d->GetReferenceCount();
69 const BamTools::RefVector BamMultiReader::GetReferenceData(void) const {
70 return d->GetReferenceData();
73 const int BamMultiReader::GetReferenceID(const string& refName) const {
74 return d->GetReferenceID(refName);
77 bool BamMultiReader::HasOpenReaders() {
78 return d->HasOpenReaders();
81 bool BamMultiReader::IsIndexLoaded(void) const {
82 return d->IsIndexLoaded();
85 bool BamMultiReader::Jump(int refID, int position) {
86 return d->Jump(refID, position);
89 bool BamMultiReader::Open(const vector<string>& filenames,
92 bool preferStandardIndex)
94 return d->Open(filenames, openIndexes, coreMode, preferStandardIndex);
97 void BamMultiReader::PrintFilenames(void) const {
101 bool BamMultiReader::Rewind(void) {
105 bool BamMultiReader::SetRegion(const int& leftRefID,
106 const int& leftPosition,
107 const int& rightRefID,
108 const int& rightPosition)
110 BamRegion region(leftRefID, leftPosition, rightRefID, rightPosition);
111 return d->SetRegion(region);
114 bool BamMultiReader::SetRegion(const BamRegion& region) {
115 return d->SetRegion(region);
118 void BamMultiReader::SetSortOrder(const SortOrder& order) {
119 d->SetSortOrder(order);