]> git.donarmstrong.com Git - bamtools.git/blobdiff - BamMultiReader.h
added warning for duplicate @RG tag in header
[bamtools.git] / BamMultiReader.h
index 0464256814f31349b42a0355c438e466308fb99b..6d5a805f2739c9306ac6c9d2f23bc37b63ab388e 100644 (file)
@@ -13,6 +13,9 @@
 \r
 // C++ includes\r
 #include <string>\r
+#include <map>\r
+#include <utility> // for pair\r
+#include <sstream>\r
 \r
 using namespace std;\r
 \r
@@ -22,7 +25,9 @@ using namespace std;
 \r
 namespace BamTools {\r
 \r
-enum BamReaderState { START, END, CLOSED };\r
+// index mapping reference/position pairings to bamreaders and their alignments\r
+typedef multimap<pair<int, int>, pair<BamReader*, BamAlignment*> > AlignmentIndex;\r
+\r
 \r
 class BamMultiReader {\r
 \r
@@ -89,21 +94,18 @@ class BamMultiReader {
 \r
         // utility\r
         void PrintFilenames(void);\r
-        void UpdateAlignments(void);\r
-\r
+        void DumpAlignmentIndex(void);\r
 \r
     // private implementation\r
     private:\r
-        // TODO perhaps, for legibility, I should use a struct to wrap them all up\r
-        //      But this may actually make things more confusing, as I'm only\r
-        //      operating on them all simultaneously during GetNextAlignment\r
-        //      calls.\r
-        // all these vectors are ordered the same\r
-        // readers.at(N) refers to the same reader as alignments.at(N) and readerStates.at(N)\r
-        vector<BamReader*> readers; // the set of readers which we operate on\r
-        vector<BamAlignment*> alignments; // the equivalent set of alignments we use to step through the files\r
-        vector<BamReaderState> readerStates; // states of the various readers\r
-        // alignment position?\r
+\r
+        // the set of readers and alignments which we operate on, maintained throughout the life of this class\r
+        vector<pair<BamReader*, BamAlignment*> > readers;\r
+\r
+        // readers and alignments sorted by reference id and position, to keep track of the lowest (next) alignment\r
+        // when a reader reaches EOF, its entry is removed from this index\r
+        AlignmentIndex alignments;\r
+\r
         vector<string> fileNames;\r
 };\r
 \r