]> git.donarmstrong.com Git - bamtools.git/blobdiff - src/api/internal/BamMultiReader_p.h
Removed unnecessary peek-and-rewind behavior in BamMultiReader
[bamtools.git] / src / api / internal / BamMultiReader_p.h
index 942f60b3da6d3835435eb81735002e94029ba243..70c0edb216282d3fc38df14acfa8c66218b6dadc 100644 (file)
@@ -3,7 +3,7 @@
 // Marth Lab, Department of Biology, Boston College
 // All rights reserved.
 // ---------------------------------------------------------------------------
-// Last modified: 17 January 2011 (DB)
+// Last modified: 9 September 2011 (DB)
 // ---------------------------------------------------------------------------
 // Functionality for simultaneously reading multiple BAM files
 // *************************************************************************
@@ -21,6 +21,7 @@
 //
 // We mean it.
 
+#include <api/SamHeader.h>
 #include <api/BamMultiReader.h>
 #include <string>
 #include <vector>
@@ -32,6 +33,10 @@ class IBamMultiMerger;
 
 class BamMultiReaderPrivate {
 
+    // typedefs
+    public:
+        typedef std::pair<BamReader*, BamAlignment*> ReaderAlignment;
+
     // constructor / destructor
     public:
         BamMultiReaderPrivate(void);
@@ -42,15 +47,15 @@ class BamMultiReaderPrivate {
 
         // file operations
         void Close(void);
-        bool Open(const std::vector<std::string>& filenames,
-                  bool openIndexes = true,
-                  bool coreMode = false,
-                  bool preferStandardIndex = false);
-        bool IsIndexLoaded(void) const;
+        void CloseFile(const std::string& filename);
+        void CloseFiles(const std::vector<std::string>& filenames);
+        const std::vector<std::string> Filenames(void) const;
         bool Jump(int refID, int position = 0);
+        bool Open(const std::vector<std::string>& filenames);
+        bool OpenFile(const std::string& filename);
         void PrintFilenames(void) const;
-        bool SetRegion(const BamRegion& region);
         bool Rewind(void);
+        bool SetRegion(const BamRegion& region);
 
         // access alignment data
         bool GetNextAlignment(BamAlignment& al);
@@ -59,34 +64,37 @@ class BamMultiReaderPrivate {
         void SetSortOrder(const BamMultiReader::SortOrder& order);
 
         // access auxiliary data
-        const std::string GetHeaderText(void) const;
-        const int GetReferenceCount(void) const;
+        SamHeader GetHeader(void) const;
+        std::string GetHeaderText(void) const;
+        int GetReferenceCount(void) const;
         const BamTools::RefVector GetReferenceData(void) const;
-        const int GetReferenceID(const std::string& refName) const;
+        int GetReferenceID(const std::string& refName) const;
 
         // BAM index operations
-        bool CreateIndexes(bool useStandardIndex = true);
-        void SetIndexCacheMode(const BamIndex::BamIndexCacheMode mode);
+        bool CreateIndexes(const BamIndex::IndexType& type = BamIndex::STANDARD);
+        bool HasIndexes(void) const;
+        bool LocateIndexes(const BamIndex::IndexType& preferredType = BamIndex::STANDARD);
+        bool OpenIndexes(const std::vector<std::string>& indexFilenames);
+        void SetIndexCacheMode(const BamIndex::IndexCacheMode mode);
 
-    // internal methods
-    private:
+    // 'internal' methods
+    public:
         IBamMultiMerger* CreateMergerForCurrentSortOrder(void) const;
         const std::string ExtractReadGroup(const std::string& headerLine) const;
-        bool LoadNextAlignment(BamAlignment& al, bool coreMode);
-        void SaveNextAlignment(BamTools::BamReader* reader, BamTools::BamAlignment* alignment);
+        bool HasAlignmentData(void) const;
+        bool LoadNextAlignment(BamReader* reader, BamAlignment* alignment);
+        ReaderAlignment OpenReader(const std::string& filename, bool* ok);
+        bool PopNextCachedAlignment(BamAlignment& al, const bool needCharData);
+        bool RewindReaders(void);
+        void SaveNextAlignment(BamReader* reader, BamAlignment* alignment);
         const std::vector<std::string> SplitHeaderText(const std::string& headerText) const;
-        // updates our alignment cache
-        void UpdateAlignments(void);
-        // validates that we have a congruent set of BAM files that are aligned against the same reference sequences
+        void UpdateAlignmentCache(void);
         void ValidateReaders(void) const;
 
     // data members
-    public:
-        typedef std::pair<BamReader*, BamAlignment*> ReaderAlignment;
+    public:        
         std::vector<ReaderAlignment> m_readers;
-
         IBamMultiMerger* m_alignments;
-        bool m_isCoreMode;
         BamMultiReader::SortOrder m_sortOrder;
 };