]> git.donarmstrong.com Git - bamtools.git/blobdiff - src/api/BamReader.h
Reorganized source tree & build system
[bamtools.git] / src / api / BamReader.h
diff --git a/src/api/BamReader.h b/src/api/BamReader.h
new file mode 100644 (file)
index 0000000..c93987b
--- /dev/null
@@ -0,0 +1,98 @@
+// ***************************************************************************\r
+// BamReader.h (c) 2009 Derek Barnett, Michael Str�mberg\r
+// Marth Lab, Department of Biology, Boston College\r
+// All rights reserved.\r
+// ---------------------------------------------------------------------------\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
+// ---------------------------------------------------------------------------\r
+// Provides the basic functionality for reading BAM files\r
+// ***************************************************************************\r
+\r
+#ifndef BAMREADER_H\r
+#define BAMREADER_H\r
+\r
+// C++ includes\r
+#include <string>\r
+\r
+// BamTools includes\r
+#include "BamAux.h"\r
+\r
+namespace BamTools {\r
+  \r
+class BamReader {\r
+\r
+    // constructor / destructor\r
+    public:\r
+        BamReader(void);\r
+        ~BamReader(void);\r
+\r
+    // public interface\r
+    public:\r
+\r
+        // ----------------------\r
+        // BAM file operations\r
+        // ----------------------\r
+\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
+        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
+        // ----------------------\r
+\r
+        // retrieves next available alignment (returns success/fail)\r
+        bool GetNextAlignment(BamAlignment& bAlignment);\r
+        \r
+        // retrieves next available alignment core data (returns success/fail)\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
+\r
+        // ----------------------\r
+        // access auxiliary data\r
+        // ----------------------\r
+\r
+        // returns SAM header text\r
+        const std::string GetHeaderText(void) const;\r
+        // returns number of reference sequences\r
+        int GetReferenceCount(void) const;\r
+        // returns vector of reference objects\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
+        const std::string GetFilename(void) const;\r
+\r
+        // ----------------------\r
+        // BAM index operations\r
+        // ----------------------\r
+\r
+        // creates index for BAM file, saves to file (default = bamFilename + ".bai")\r
+        bool CreateIndex(bool useDefaultIndex = true);\r
+        \r
+    // private implementation\r
+    private:\r
+        struct BamReaderPrivate;\r
+        BamReaderPrivate* d;\r
+};\r
+\r
+} // namespace BamTools\r
+\r
+#endif // BAMREADER_H\r