1 // ***************************************************************************
2 // BamReader.cpp (c) 2009 Derek Barnett, Michael Str�mberg
3 // Marth Lab, Department of Biology, Boston College
4 // All rights reserved.
5 // ---------------------------------------------------------------------------
6 // Last modified: 22 November 2010 (DB)
7 // ---------------------------------------------------------------------------
8 // Provides the basic functionality for reading BAM files
9 // ***************************************************************************
11 #include <api/BamReader.h>
12 #include <api/internal/BamReader_p.h>
13 using namespace BamTools;
14 using namespace BamTools::Internal;
24 BamReader::BamReader(void) {
25 d = new BamReaderPrivate(this);
29 BamReader::~BamReader(void) {
35 void BamReader::Close(void) { d->Close(); }
36 bool BamReader::HasIndex(void) const { return d->HasIndex; }
37 bool BamReader::IsIndexLoaded(void) const { return HasIndex(); }
38 bool BamReader::IsOpen(void) const { return d->mBGZF.IsOpen; }
39 bool BamReader::Jump(int refID, int position) { return d->SetRegion( BamRegion(refID, position) ); }
40 bool BamReader::Open(const std::string& filename,
41 const std::string& indexFilename,
42 const bool lookForIndex,
43 const bool preferStandardIndex)
45 return d->Open(filename, indexFilename, lookForIndex, preferStandardIndex);
47 bool BamReader::Rewind(void) { return d->Rewind(); }
48 bool BamReader::SetRegion(const BamRegion& region) { return d->SetRegion(region); }
49 bool BamReader::SetRegion(const int& leftRefID, const int& leftBound, const int& rightRefID, const int& rightBound) {
50 return d->SetRegion( BamRegion(leftRefID, leftBound, rightRefID, rightBound) );
53 // access alignment data
54 bool BamReader::GetNextAlignment(BamAlignment& bAlignment) { return d->GetNextAlignment(bAlignment); }
55 bool BamReader::GetNextAlignmentCore(BamAlignment& bAlignment) { return d->GetNextAlignmentCore(bAlignment); }
57 // access auxiliary data
58 const string BamReader::GetHeaderText(void) const { return d->GetHeaderText(); }
59 int BamReader::GetReferenceCount(void) const { return d->References.size(); }
60 const RefVector& BamReader::GetReferenceData(void) const { return d->References; }
61 int BamReader::GetReferenceID(const string& refName) const { return d->GetReferenceID(refName); }
62 const std::string BamReader::GetFilename(void) const { return d->Filename; }
65 bool BamReader::CreateIndex(bool useStandardIndex) { return d->CreateIndex(useStandardIndex); }
66 void BamReader::SetIndexCacheMode(const BamIndex::BamIndexCacheMode mode) { d->SetIndexCacheMode(mode); }