BamMultiReader.h

Go to the documentation of this file.
00001 // ***************************************************************************
00002 // BamMultiReader.h (c) 2010 Erik Garrison, Derek Barnett
00003 // Marth Lab, Department of Biology, Boston College
00004 // ---------------------------------------------------------------------------
00005 // Last modified: 25 October 2011 (DB)
00006 // ---------------------------------------------------------------------------
00007 // Convenience class for reading multiple BAM files.
00008 // ***************************************************************************
00009 
00010 #ifndef BAMMULTIREADER_H
00011 #define BAMMULTIREADER_H
00012 
00013 #include "api/api_global.h"
00014 #include "api/BamReader.h"
00015 #include <map>
00016 #include <sstream>
00017 #include <string>
00018 #include <utility>
00019 
00020 namespace BamTools {
00021 
00022 namespace Internal {
00023     class BamMultiReaderPrivate;
00024 } // namespace Internal
00025 
00026 class API_EXPORT BamMultiReader {
00027 
00028     // constructor / destructor
00029     public:
00030         BamMultiReader(void);
00031         ~BamMultiReader(void);
00032 
00033     // public interface
00034     public:
00035 
00036         // ----------------------
00037         // BAM file operations
00038         // ----------------------
00039 
00040         // closes all open BAM files
00041         bool Close(void);
00042         // close only the requested BAM file
00043         bool CloseFile(const std::string& filename);
00044         // returns list of filenames for all open BAM files
00045         const std::vector<std::string> Filenames(void) const;
00046         // returns true if multireader has any open BAM files
00047         bool HasOpenReaders(void) const;
00048         // performs random-access jump within current BAM files
00049         bool Jump(int refID, int position = 0);
00050         // opens BAM files
00051         bool Open(const std::vector<std::string>& filenames);
00052         // opens a single BAM file, adding to any other current BAM files
00053         bool OpenFile(const std::string& filename);
00054         // returns file pointers to beginning of alignments
00055         bool Rewind(void);
00056         // sets the target region of interest
00057         bool SetRegion(const BamRegion& region);
00058         // sets the target region of interest
00059         bool SetRegion(const int& leftRefID,
00060                        const int& leftPosition,
00061                        const int& rightRefID,
00062                        const int& rightPosition);
00063 
00064         // ----------------------
00065         // access alignment data
00066         // ----------------------
00067 
00068         // retrieves next available alignment
00069         bool GetNextAlignment(BamAlignment& alignment);
00070         // retrieves next available alignment (without populating the alignment's string data fields)
00071         bool GetNextAlignmentCore(BamAlignment& alignment);
00072 
00073         // ----------------------
00074         // access auxiliary data
00075         // ----------------------
00076 
00077         // returns unified SAM header for all files
00078         SamHeader GetHeader(void) const;
00079         // returns unified SAM header text for all files
00080         std::string GetHeaderText(void) const;
00081         // returns number of reference sequences
00082         int GetReferenceCount(void) const;
00083         // returns all reference sequence entries.
00084         const BamTools::RefVector GetReferenceData(void) const;
00085         // returns the ID of the reference with this name.
00086         int GetReferenceID(const std::string& refName) const;
00087 
00088         // ----------------------
00089         // BAM index operations
00090         // ----------------------
00091 
00092         // creates index files for current BAM files
00093         bool CreateIndexes(const BamIndex::IndexType& type = BamIndex::STANDARD);
00094         // returns true if all BAM files have index data available
00095         bool HasIndexes(void) const;
00096         // looks for index files that match current BAM files
00097         bool LocateIndexes(const BamIndex::IndexType& preferredType = BamIndex::STANDARD);
00098         // opens index files for current BAM files.
00099         bool OpenIndexes(const std::vector<std::string>& indexFilenames);
00100 
00101         // ----------------------
00102         // error handling
00103         // ----------------------
00104 
00105         // returns a human-readable description of the last error that occurred
00106         std::string GetErrorString(void) const;
00107 
00108     // private implementation
00109     private:
00110         Internal::BamMultiReaderPrivate* d;
00111 };
00112 
00113 } // namespace BamTools
00114 
00115 #endif // BAMMULTIREADER_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