]> git.donarmstrong.com Git - bamtools.git/blob - src/api/BamMultiReader.cpp
Implemented proper -byname sorting (finally).
[bamtools.git] / src / api / BamMultiReader.cpp
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
9 // Institute.
10 // ---------------------------------------------------------------------------
11 // Functionality for simultaneously reading multiple BAM files.
12 //
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 // ***************************************************************************
18
19 #include <api/BamMultiReader.h>
20 #include <api/BGZF.h>
21 #include <api/internal/BamMultiReader_p.h>
22 using namespace BamTools;
23
24 #include <string>
25 #include <vector>
26 using namespace std;
27
28 // -----------------------------------------------------
29 // BamMultiReader implementation
30 // -----------------------------------------------------
31
32 BamMultiReader::BamMultiReader(void)
33     : d(new Internal::BamMultiReaderPrivate)
34 { }
35
36 BamMultiReader::~BamMultiReader(void) {
37     delete d;
38     d = 0;
39 }
40
41 void BamMultiReader::Close(void) {
42     d->Close();
43 }
44
45 bool BamMultiReader::CreateIndexes(bool useStandardIndex) {
46     return d->CreateIndexes(useStandardIndex);
47 }
48
49 void BamMultiReader::SetIndexCacheMode(const BamIndex::BamIndexCacheMode mode) {
50     d->SetIndexCacheMode(mode);
51 }
52
53 const string BamMultiReader::GetHeaderText(void) const {
54     return d->GetHeaderText();
55 }
56
57 bool BamMultiReader::GetNextAlignment(BamAlignment& nextAlignment) {
58     return d->GetNextAlignment(nextAlignment);
59 }
60
61 bool BamMultiReader::GetNextAlignmentCore(BamAlignment& nextAlignment) {
62     return d->GetNextAlignmentCore(nextAlignment);
63 }
64
65 const int BamMultiReader::GetReferenceCount(void) const {
66     return d->GetReferenceCount();
67 }
68
69 const BamTools::RefVector BamMultiReader::GetReferenceData(void) const {
70     return d->GetReferenceData();
71 }
72
73 const int BamMultiReader::GetReferenceID(const string& refName) const { 
74     return d->GetReferenceID(refName);
75 }
76
77 bool BamMultiReader::HasOpenReaders() {
78     return d->HasOpenReaders();
79 }
80
81 bool BamMultiReader::IsIndexLoaded(void) const {
82     return d->IsIndexLoaded();
83 }
84
85 bool BamMultiReader::Jump(int refID, int position) {
86     return d->Jump(refID, position);
87 }
88
89 bool BamMultiReader::Open(const vector<string>& filenames,
90                           bool openIndexes,
91                           bool coreMode,
92                           bool preferStandardIndex)
93 {
94     return d->Open(filenames, openIndexes, coreMode, preferStandardIndex);
95 }
96
97 void BamMultiReader::PrintFilenames(void) const {
98     d->PrintFilenames();
99 }
100
101 bool BamMultiReader::Rewind(void) {
102     return d->Rewind();
103 }
104
105 bool BamMultiReader::SetRegion(const int& leftRefID,
106                                const int& leftPosition,
107                                const int& rightRefID,
108                                const int& rightPosition)
109 {
110     BamRegion region(leftRefID, leftPosition, rightRefID, rightPosition);
111     return d->SetRegion(region);
112 }
113
114 bool BamMultiReader::SetRegion(const BamRegion& region) {
115     return d->SetRegion(region);
116 }
117
118 void BamMultiReader::SetSortOrder(const SortOrder& order) {
119     d->SetSortOrder(order);
120 }