X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=BamMultiReader.h;h=37ad7652d46d0c8a38f61dbd138c9724c7d1eb01;hb=f6288f9f90747418a5d3c61b7713bee8e3a16112;hp=f1a2bb242e450785c5cacf32517d393a93fc9e1a;hpb=aa89df8c4510f88b2101ce91e8c46b99387560bd;p=bamtools.git diff --git a/BamMultiReader.h b/BamMultiReader.h index f1a2bb2..37ad765 100644 --- a/BamMultiReader.h +++ b/BamMultiReader.h @@ -15,6 +15,7 @@ #include #include #include // for pair +#include using namespace std; @@ -27,6 +28,7 @@ namespace BamTools { // index mapping reference/position pairings to bamreaders and their alignments typedef multimap, pair > AlignmentIndex; + class BamMultiReader { // constructor / destructor @@ -41,17 +43,31 @@ class BamMultiReader { int CurrentRefID; int CurrentLeft; + // region under analysis, specified using SetRegion + BamRegion Region; + // ---------------------- // BAM file operations // ---------------------- // close BAM files void Close(void); + + // opens BAM files (and optional BAM index files, if provided) + // @openIndexes - triggers index opening, useful for suppressing + // error messages during merging of files in which we may not have + // indexes. + // @coreMode - setup our first alignments using GetNextAlignmentCore(); + // also useful for merging + void Open(const vector filenames, bool openIndexes = true, bool coreMode = false, bool useDefaultIndex = true); + // performs random-access jump to reference, position bool Jump(int refID, int position = 0); - // opens BAM files (and optional BAM index files, if provided) - //void Open(const vector filenames, const vector indexFilenames); - void Open(const vector filenames, bool openIndexes = true); + + // sets the target region + bool SetRegion(const BamRegion& region); + bool SetRegion(const int&, const int&, const int&, const int&); // convenience function to above + // returns file pointers to beginning of alignments bool Rewind(void); @@ -63,6 +79,10 @@ class BamMultiReader { // retrieves next available alignment (returns success/fail) from all files bool GetNextAlignment(BamAlignment&); + // retrieves next available alignment (returns success/fail) from all files + // and populates the support data with information about the alignment + // *** BUT DOES NOT PARSE CHARACTER DATA FROM THE ALIGNMENT + bool GetNextAlignmentCore(BamAlignment&); // ... should this be private? bool HasOpenReaders(void); @@ -86,13 +106,14 @@ class BamMultiReader { // ---------------------- // creates index for BAM files which lack them, saves to files (default = bamFilename + ".bai") - bool CreateIndexes(void); + bool CreateIndexes(bool useDefaultIndex = true); //const int GetReferenceID(const string& refName) const; // utility void PrintFilenames(void); void DumpAlignmentIndex(void); + void UpdateAlignments(void); // updates our alignment cache // private implementation private: