]> git.donarmstrong.com Git - bamtools.git/blobdiff - BamReader.h
Modified BamWriter::Open() to return bool on success/fail - was silent before, so...
[bamtools.git] / BamReader.h
index 0b13786b1b112a48cccae944ac73f14c4f7e6e53..c93987b1a41bfbe41b7f0a10bd9d826a3514e681 100644 (file)
@@ -3,7 +3,7 @@
 // Marth Lab, Department of Biology, Boston College\r
 // All rights reserved.\r
 // ---------------------------------------------------------------------------\r
-// Last modified: 8 June 2010 (DB)\r
+// Last modified: 9 July 2010 (DB)\r
 // ---------------------------------------------------------------------------\r
 // Uses BGZF routines were adapted from the bgzf.c code developed at the Broad\r
 // Institute.\r
@@ -21,7 +21,7 @@
 #include "BamAux.h"\r
 \r
 namespace BamTools {\r
-\r
+  \r
 class BamReader {\r
 \r
     // constructor / destructor\r
@@ -38,12 +38,19 @@ class BamReader {
 \r
         // close BAM file\r
         void Close(void);\r
+        // returns whether reader is open for reading or not\r
+        bool IsOpen(void) const;\r
         // performs random-access jump to reference, position\r
         bool Jump(int refID, int position = 0);\r
         // opens BAM file (and optional BAM index file, if provided)\r
-        void Open(const std::string& filename, const std::string& indexFilename = "");\r
+        bool Open(const std::string& filename, const std::string& indexFilename = "");\r
         // returns file pointer to beginning of alignments\r
         bool Rewind(void);\r
+        // sets a region of interest (with left & right bound reference/position)\r
+        // attempts a Jump() to left bound as well\r
+        // returns success/failure of Jump()\r
+        bool SetRegion(const BamRegion& region);\r
+        bool SetRegion(const int& leftRefID, const int& leftBound, const int& rightRefID, const int& rightBound);\r
 \r
         // ----------------------\r
         // access alignment data\r
@@ -53,7 +60,7 @@ class BamReader {
         bool GetNextAlignment(BamAlignment& bAlignment);\r
         \r
         // retrieves next available alignment core data (returns success/fail)\r
-        // ** DOES NOT parse any character data (bases, qualities, tag data)\r
+        // ** DOES NOT parse any character data (read name, bases, qualities, tag data)\r
         //    these can be accessed, if necessary, from the supportData \r
         // useful for operations requiring ONLY positional or other alignment-related information\r
         bool GetNextAlignmentCore(BamAlignment& bAlignment);\r
@@ -67,7 +74,7 @@ class BamReader {
         // returns number of reference sequences\r
         int GetReferenceCount(void) const;\r
         // returns vector of reference objects\r
-        const BamTools::RefVector GetReferenceData(void) const;\r
+        const BamTools::RefVector& GetReferenceData(void) const;\r
         // returns reference id (used for BamReader::Jump()) for the given reference name\r
         int GetReferenceID(const std::string& refName) const;\r
         // returns the name of the file associated with this BamReader\r
@@ -78,8 +85,8 @@ class BamReader {
         // ----------------------\r
 \r
         // creates index for BAM file, saves to file (default = bamFilename + ".bai")\r
-        bool CreateIndex(void);\r
-\r
+        bool CreateIndex(bool useDefaultIndex = true);\r
+        \r
     // private implementation\r
     private:\r
         struct BamReaderPrivate;\r