BamIndex.h

Go to the documentation of this file.
00001 // ***************************************************************************
00002 // BamIndex.h (c) 2009 Derek Barnett
00003 // Marth Lab, Department of Biology, Boston College
00004 // ---------------------------------------------------------------------------
00005 // Last modified: 10 October 2011 (DB)
00006 // ---------------------------------------------------------------------------
00007 // Provides basic BAM index interface
00008 // ***************************************************************************
00009 
00010 #ifndef BAM_INDEX_H
00011 #define BAM_INDEX_H
00012 
00013 #include "api/api_global.h"
00014 #include "api/BamAux.h"
00015 #include <string>
00016 
00017 namespace BamTools {
00018 
00019 namespace Internal {
00020     class BamReaderPrivate;
00021 } // namespace Internal
00022 
00034 class API_EXPORT BamIndex {
00035 
00036     // enums
00037     public:
00038 
00039         // list of supported BamIndex types
00040         enum IndexType { BAMTOOLS = 0
00041                        , STANDARD
00042                        };
00043   
00044     // ctor & dtor
00045     public:
00046         BamIndex(Internal::BamReaderPrivate* reader) : m_reader(reader) { }
00047         virtual ~BamIndex(void) { }
00048         
00049     // index interface
00050     public:
00051         // builds index from associated BAM file & writes out to index file
00052         virtual bool Create(void) =0;
00053 
00054         // returns a human-readable description of the last error encountered
00055         std::string GetErrorString(void) { return m_errorString; }
00056 
00057         // returns whether reference has alignments or no
00058         virtual bool HasAlignments(const int& referenceID) const =0;
00059 
00060         // attempts to use index data to jump to @region, returns success/fail
00061         // a "successful" jump indicates no error, but not whether this region has data
00062         //   * thus, the method sets a flag to indicate whether there are alignments
00063         //     available after the jump position
00064         virtual bool Jump(const BamTools::BamRegion& region, bool* hasAlignmentsInRegion) =0;
00065 
00066         // loads existing data from file into memory
00067         virtual bool Load(const std::string& filename) =0;
00068 
00069         // returns the 'type' enum for derived index format
00070         virtual BamIndex::IndexType Type(void) const =0;
00071 
00073 
00074     // internal methods
00075     protected:
00076         void SetErrorString(const std::string& where, const std::string& what) const {
00077             m_errorString = where + ": " + what;
00078         }
00079 
00080     // data members
00081     protected:
00082         Internal::BamReaderPrivate* m_reader; // copy, not owned
00083         mutable std::string m_errorString;
00084 
00086 };
00087 
00088 } // namespace BamTools
00089 
00090 #endif // BAM_INDEX_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Wed Aug 29 17:43:46 2012 for BamTools by  doxygen 1.6.3