1 // ***************************************************************************
2 // BamReader_p.h (c) 2010 Derek Barnett
3 // Marth Lab, Department of Biology, Boston College
4 // All rights reserved.
5 // ---------------------------------------------------------------------------
6 // Last modified: 24 February 2011 (DB)
7 // ---------------------------------------------------------------------------
8 // Provides the basic functionality for reading BAM files
9 // ***************************************************************************
18 // This file is not part of the BamTools API. It exists purely as an
19 // implementation detail. This header file may change from version to version
20 // without notice, or even be removed.
24 #include <api/BamAlignment.h>
25 #include <api/BamIndex.h>
26 #include <api/BamReader.h>
27 #include <api/SamHeader.h>
28 #include <api/internal/BamHeader_p.h>
29 #include <api/internal/BamRandomAccessController_p.h>
30 #include <api/internal/BgzfStream_p.h>
36 class BamReaderPrivate {
40 BamReaderPrivate(BamReader* parent);
41 ~BamReaderPrivate(void);
43 // BamReader interface
48 const std::string Filename(void) const;
49 bool IsOpen(void) const;
50 bool Open(const std::string& filename);
52 bool SetRegion(const BamRegion& region);
54 // access alignment data
55 bool GetNextAlignment(BamAlignment& alignment);
56 bool GetNextAlignmentCore(BamAlignment& alignment);
58 // access auxiliary data
59 std::string GetHeaderText(void) const;
60 SamHeader GetSamHeader(void) const;
61 int GetReferenceCount(void) const;
62 const RefVector& GetReferenceData(void) const;
63 int GetReferenceID(const std::string& refName) const;
66 bool CreateIndex(const BamIndex::IndexType& type);
67 bool HasIndex(void) const;
68 bool LocateIndex(const BamIndex::IndexType& preferredType);
69 bool OpenIndex(const std::string& indexFilename);
70 void SetIndex(BamIndex* index);
71 void SetIndexCacheMode(const BamIndex::IndexCacheMode& mode);
73 // BamReaderPrivate interface
75 BgzfStream* Stream(void);
79 // retrieves header text from BAM file
80 bool LoadHeaderData(void);
81 // retrieves BAM alignment under file pointer
82 // (does no overlap checking or character data parsing)
83 bool LoadNextAlignment(BamAlignment& alignment);
84 // builds reference data structure from BAM file
85 bool LoadReferenceData(void);
90 // general BAM file data
91 int64_t m_alignmentsBeginOffset;
92 std::string m_filename;
93 RefVector m_references;
101 // BamReaderPrivate components
103 BamRandomAccessController m_randomAccessController;
107 } // namespace Internal
108 } // namespace BamTools
110 #endif // BAMREADER_P_H