]> git.donarmstrong.com Git - bamtools.git/blob - src/api/internal/BamReader_p.h
Removed explicit keyword from SamHeader-related object copy ctors
[bamtools.git] / src / api / internal / BamReader_p.h
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: 11 January 2011 (DB)
7 // ---------------------------------------------------------------------------
8 // Provides the basic functionality for reading BAM files
9 // ***************************************************************************
10
11 #ifndef BAMREADER_P_H
12 #define BAMREADER_P_H
13
14 //  -------------
15 //  W A R N I N G
16 //  -------------
17 //
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.
21 //
22 // We mean it.
23
24 #include <api/BamAlignment.h>
25 #include <api/BamIndex.h>
26 #include <api/BGZF.h>
27 #include <api/SamHeader.h>
28 #include <string>
29
30 namespace BamTools {
31
32 class BamReader;
33 class SamHeader;
34
35 namespace Internal {
36
37 class BamHeader;
38
39 class BamReaderPrivate {
40
41     // enums
42     public: enum RegionState { BEFORE_REGION = 0
43                              , WITHIN_REGION
44                              , AFTER_REGION
45                              };
46
47     // ctor & dtor
48     public:
49         BamReaderPrivate(BamReader* parent);
50         ~BamReaderPrivate(void);
51
52     // 'public' interface to BamReader
53     public:
54
55         // file operations
56         void Close(void);
57         bool Open(const std::string& filename,
58                   const std::string& indexFilename,
59                   const bool lookForIndex,
60                   const bool preferStandardIndex);
61         bool Rewind(void);
62         bool SetRegion(const BamRegion& region);
63
64         // access alignment data
65         bool GetNextAlignment(BamAlignment& bAlignment);
66         bool GetNextAlignmentCore(BamAlignment& bAlignment);
67
68         // access auxiliary data
69         const std::string GetHeaderText(void) const;
70         const SamHeader GetSamHeader(void) const;
71         int GetReferenceID(const std::string& refName) const;
72
73         // index operations
74         bool CreateIndex(bool useStandardIndex);
75         void SetIndexCacheMode(const BamIndex::BamIndexCacheMode mode);
76
77     // 'internal' methods
78     public:
79
80         // ---------------------------------------
81         // reading alignments and auxiliary data
82
83         // adjusts requested region if necessary (depending on where data actually begins)
84         void AdjustRegion(BamRegion& region);
85         // checks to see if alignment overlaps current region
86         RegionState IsOverlap(BamAlignment& bAlignment);
87         // retrieves header text from BAM file
88         void LoadHeaderData(void);
89         // retrieves BAM alignment under file pointer
90         bool LoadNextAlignment(BamAlignment& bAlignment);
91         // builds reference data structure from BAM file
92         void LoadReferenceData(void);
93         // mark references with 'HasAlignments' status
94         void MarkReferences(void);
95
96         // ---------------------------------
97         // index file handling
98
99         // clear out inernal index data structure
100         void ClearIndex(void);
101         // loads index from BAM index file
102         bool LoadIndex(const bool lookForIndex, const bool preferStandardIndex);
103
104     // data members
105     public:
106
107         // general file data
108         BgzfData  mBGZF;
109         BamIndex* Index;
110         RefVector References;
111         bool      HasIndex;
112         int64_t   AlignmentsBeginOffset;
113         std::string    Filename;
114         std::string    IndexFilename;
115
116
117         // index caching mode
118         BamIndex::BamIndexCacheMode IndexCacheMode;
119
120         // system data
121         bool IsBigEndian;
122
123         // user-specified region values
124         BamRegion Region;
125         bool HasAlignmentsInRegion;
126
127         // parent BamReader
128         BamReader* Parent;
129         BamHeader* m_header;
130
131         // BAM character constants
132         const char* DNA_LOOKUP;
133         const char* CIGAR_LOOKUP;
134 };
135
136 } // namespace Internal
137 } // namespace BamTools
138
139 #endif // BAMREADER_P_H