]> git.donarmstrong.com Git - bamtools.git/blobdiff - src/api/BamIndex.h
Moved BamAlignment data structure out to its own .h/.cpp. BamAux.h was getting over...
[bamtools.git] / src / api / BamIndex.h
index dc95889a95e6f8354e4ac16e8b0c2e5f7f0c6908..710893a0c55361ace7e9cdd7b1597f7edbe3afae 100644 (file)
@@ -3,7 +3,7 @@
 // Marth Lab, Department of Biology, Boston College
 // All rights reserved.
 // ---------------------------------------------------------------------------
-// Last modified: 3 September 2010 (DB)
+// Last modified: 18 September 2010 (DB)
 // ---------------------------------------------------------------------------
 // Provides index functionality - both for the standardized BAM index format
 // (".bai") as well as a BamTools-specific (nonstandard) index format (".bti").
@@ -15,7 +15,7 @@
 #include <iostream>
 #include <string>
 #include <vector>
-#include "BamAux.h"
+#include "BamAlignment.h"
 
 namespace BamTools {
 
@@ -30,16 +30,18 @@ class BamIndex {
     public:
         BamIndex(BamTools::BgzfData* bgzf, BamTools::BamReader* reader, bool isBigEndian);
         virtual ~BamIndex(void) { }
-
+        
     // index interface
     public:
         // creates index data (in-memory) from current reader data
         virtual bool Build(void) =0;
         // returns supported file extension
         virtual const std::string Extension(void) const =0;
-        // calculates offset(s) for a given region
-        //virtual bool GetOffsets(const BamTools::BamRegion& region, const bool isRightBoundSpecified, std::vector<int64_t>& offsets) =0;
-        virtual bool Jump(const BamTools::BamRegion& region) =0;
+        // attempts to use index to jump to region; returns success/fail
+        // a "successful" jump indicates no error, but not whether this region has data
+        //   * thus, the method sets a flag to indicate whether there are alignments 
+        //     available after the jump position
+        virtual bool Jump(const BamTools::BamRegion& region, bool* hasAlignmentsInRegion) =0;
         // returns whether reference has alignments or no
         virtual bool HasAlignments(const int& referenceID); 
         // loads existing data from file into memory
@@ -97,9 +99,11 @@ class BamStandardIndex : public BamIndex {
         bool Build(void);
         // returns supported file extension
         const std::string Extension(void) const { return std::string(".bai"); }
-        // calculates offset(s) for a given region
-        bool GetOffsets(const BamTools::BamRegion& region, const bool isRightBoundSpecified, std::vector<int64_t>& offsets);
-        bool Jump(const BamTools::BamRegion& region);
+        // attempts to use index to jump to region; returns success/fail
+        // a "successful" jump indicates no error, but not whether this region has data
+        //   * thus, the method sets a flag to indicate whether there are alignments 
+        //     available after the jump position
+        bool Jump(const BamTools::BamRegion& region, bool* hasAlignmentsInRegion);
          // loads existing data from file into memory
         bool Load(const std::string& filename);
         // writes in-memory index data out to file 
@@ -131,9 +135,11 @@ class BamToolsIndex : public BamIndex {
         bool Build(void);
         // returns supported file extension
         const std::string Extension(void) const { return std::string(".bti"); }
-        // calculates offset(s) for a given region
-        bool GetOffsets(const BamTools::BamRegion& region, const bool isRightBoundSpecified, std::vector<int64_t>& offsets);
-        bool Jump(const BamTools::BamRegion& region);
+        // attempts to use index to jump to region; returns success/fail
+        // a "successful" jump indicates no error, but not whether this region has data
+        //   * thus, the method sets a flag to indicate whether there are alignments 
+        //     available after the jump position
+        bool Jump(const BamTools::BamRegion& region, bool* hasAlignmentsInRegion);
          // loads existing data from file into memory
         bool Load(const std::string& filename);
         // writes in-memory index data out to file