X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=src%2Fapi%2Finternal%2FBamReader_p.h;h=7dda67f14569a5412a0eff3df9c0867fa9515902;hb=8c80d760637f8df39262683cd2570f0589423d36;hp=3d49a6370bc11393cd91f967334127d2983a7bbb;hpb=577b6032aa3d85616047c8aba6061dd8dad20cfc;p=bamtools.git diff --git a/src/api/internal/BamReader_p.h b/src/api/internal/BamReader_p.h index 3d49a63..7dda67f 100644 --- a/src/api/internal/BamReader_p.h +++ b/src/api/internal/BamReader_p.h @@ -3,7 +3,7 @@ // Marth Lab, Department of Biology, Boston College // All rights reserved. // --------------------------------------------------------------------------- -// Last modified: 11 January 2011 (DB) +// Last modified: 24 February 2011 (DB) // --------------------------------------------------------------------------- // Provides the basic functionality for reading BAM files // *************************************************************************** @@ -23,114 +23,85 @@ #include #include -#include +#include #include +#include +#include +#include #include namespace BamTools { - -class BamReader; -class SamHeader; - namespace Internal { -class BamHeader; - class BamReaderPrivate { - // enums - public: enum RegionState { BEFORE_REGION = 0 - , WITHIN_REGION - , AFTER_REGION - }; - // ctor & dtor public: BamReaderPrivate(BamReader* parent); ~BamReaderPrivate(void); - // 'public' interface to BamReader + // BamReader interface public: // file operations void Close(void); - bool Open(const std::string& filename, - const std::string& indexFilename, - const bool lookForIndex, - const bool preferStandardIndex); + const std::string Filename(void) const; + bool IsOpen(void) const; + bool Open(const std::string& filename); bool Rewind(void); bool SetRegion(const BamRegion& region); // access alignment data - bool GetNextAlignment(BamAlignment& bAlignment); - bool GetNextAlignmentCore(BamAlignment& bAlignment); + bool GetNextAlignment(BamAlignment& alignment); + bool GetNextAlignmentCore(BamAlignment& alignment); // access auxiliary data - const std::string GetHeaderText(void) const; - const SamHeader GetSamHeader(void) const; + std::string GetHeaderText(void) const; + SamHeader GetSamHeader(void) const; + int GetReferenceCount(void) const; + const RefVector& GetReferenceData(void) const; int GetReferenceID(const std::string& refName) const; // index operations - bool CreateIndex(bool useStandardIndex); - void SetIndexCacheMode(const BamIndex::BamIndexCacheMode mode); + bool CreateIndex(const BamIndex::IndexType& type); + bool HasIndex(void) const; + bool LocateIndex(const BamIndex::IndexType& preferredType); + bool OpenIndex(const std::string& indexFilename); + void SetIndex(BamIndex* index); + void SetIndexCacheMode(const BamIndex::IndexCacheMode& mode); + + // BamReaderPrivate interface + public: + BgzfStream* Stream(void); // 'internal' methods public: - - // --------------------------------------- - // reading alignments and auxiliary data - - // adjusts requested region if necessary (depending on where data actually begins) - void AdjustRegion(BamRegion& region); - // checks to see if alignment overlaps current region - RegionState IsOverlap(BamAlignment& bAlignment); // retrieves header text from BAM file - void LoadHeaderData(void); + bool LoadHeaderData(void); // retrieves BAM alignment under file pointer - bool LoadNextAlignment(BamAlignment& bAlignment); + // (does no overlap checking or character data parsing) + bool LoadNextAlignment(BamAlignment& alignment); // builds reference data structure from BAM file - void LoadReferenceData(void); - // mark references with 'HasAlignments' status - void MarkReferences(void); - - // --------------------------------- - // index file handling - - // clear out inernal index data structure - void ClearIndex(void); - // loads index from BAM index file - bool LoadIndex(const bool lookForIndex, const bool preferStandardIndex); + bool LoadReferenceData(void); // data members public: - // general file data - BgzfData mBGZF; - BamIndex* Index; - RefVector References; - bool HasIndex; - int64_t AlignmentsBeginOffset; - std::string Filename; - std::string IndexFilename; - - - // index caching mode - BamIndex::BamIndexCacheMode IndexCacheMode; + // general BAM file data + int64_t m_alignmentsBeginOffset; + std::string m_filename; + RefVector m_references; // system data - bool IsBigEndian; - - // user-specified region values - BamRegion Region; - bool HasAlignmentsInRegion; + bool m_isBigEndian; // parent BamReader - BamReader* Parent; - BamHeader* m_header; + BamReader* m_parent; - // BAM character constants - const char* DNA_LOOKUP; - const char* CIGAR_LOOKUP; + // BamReaderPrivate components + BamHeader m_header; + BamRandomAccessController m_randomAccessController; + BgzfStream m_stream; }; } // namespace Internal