1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- // ***************************************************************************
- // BamReader.h (c) 2009 Derek Barnett, Michael Strömberg
- // Marth Lab, Department of Biology, Boston College
- // All rights reserved.
- // ---------------------------------------------------------------------------
- // Last modified: 8 December 2009 (DB)
- // ---------------------------------------------------------------------------
- // Uses BGZF routines were adapted from the bgzf.c code developed at the Broad
- // Institute.
- // ---------------------------------------------------------------------------
- // Provides the basic functionality for reading BAM files
- // ***************************************************************************
- #ifndef BAMREADER_H
- #define BAMREADER_H
- // C++ includes
- #include <string>
- // BamTools includes
- #include "BamAux.h"
- namespace BamTools {
- class BamReader {
- // constructor / destructor
- public:
- BamReader(void);
- ~BamReader(void);
- // public interface
- public:
- // ----------------------
- // BAM file operations
- // ----------------------
- // close BAM file
- void Close(void);
- // performs random-access jump to reference, position
- bool Jump(int refID, int position = 0);
- // opens BAM file (and optional BAM index file, if provided)
- void Open(const std::string& filename, const std::string& indexFilename = "");
- // returns file pointer to beginning of alignments
- bool Rewind(void);
- // ----------------------
- // access alignment data
- // ----------------------
- // retrieves next available alignment (returns success/fail)
- bool GetNextAlignment(BamAlignment& bAlignment);
- // ----------------------
- // access auxiliary data
- // ----------------------
- // returns SAM header text
- const std::string GetHeaderText(void) const;
- // returns number of reference sequences
- const int GetReferenceCount(void) const;
- // returns vector of reference objects
- const BamTools::RefVector GetReferenceData(void) const;
- // returns reference id (used for BamReader::Jump()) for the given reference name
- const int GetReferenceID(const std::string& refName) const;
- // ----------------------
- // BAM index operations
- // ----------------------
- // creates index for BAM file, saves to file (default = bamFilename + ".bai")
- bool CreateIndex(void);
- // private implementation
- private:
- struct BamReaderPrivate;
- BamReaderPrivate* d;
- };
- } // namespace BamTools
- #endif // BAMREADER_H
|