]> git.donarmstrong.com Git - bamtools.git/blob - src/api/internal/BamMultiReader_p.h
Attempt to fix SamHeaderVersion compile bug
[bamtools.git] / src / api / internal / BamMultiReader_p.h
1 // ***************************************************************************
2 // BamMultiReader_p.h (c) 2010 Derek Barnett
3 // Marth Lab, Department of Biology, Boston College
4 // All rights reserved.
5 // ---------------------------------------------------------------------------
6 // Last modified: 17 January 2011 (DB)
7 // ---------------------------------------------------------------------------
8 // Functionality for simultaneously reading multiple BAM files
9 // *************************************************************************
10
11 #ifndef BAMMULTIREADER_P_H
12 #define BAMMULTIREADER_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/BamMultiReader.h>
25 #include <string>
26 #include <vector>
27
28 namespace BamTools {
29 namespace Internal {
30
31 class IBamMultiMerger;
32
33 class BamMultiReaderPrivate {
34
35     // constructor / destructor
36     public:
37         BamMultiReaderPrivate(void);
38         ~BamMultiReaderPrivate(void);
39
40     // public interface
41     public:
42
43         // file operations
44         void Close(void);
45         bool Open(const std::vector<std::string>& filenames,
46                   bool openIndexes = true,
47                   bool coreMode = false,
48                   bool preferStandardIndex = false);
49         bool IsIndexLoaded(void) const;
50         bool Jump(int refID, int position = 0);
51         void PrintFilenames(void) const;
52         bool SetRegion(const BamRegion& region);
53         bool Rewind(void);
54
55         // access alignment data
56         bool GetNextAlignment(BamAlignment& al);
57         bool GetNextAlignmentCore(BamAlignment& al);
58         bool HasOpenReaders(void);
59         void SetSortOrder(const BamMultiReader::SortOrder& order);
60
61         // access auxiliary data
62         const std::string GetHeaderText(void) const;
63         const int GetReferenceCount(void) const;
64         const BamTools::RefVector GetReferenceData(void) const;
65         const int GetReferenceID(const std::string& refName) const;
66
67         // BAM index operations
68         bool CreateIndexes(bool useStandardIndex = true);
69         void SetIndexCacheMode(const BamIndex::BamIndexCacheMode mode);
70
71     // internal methods
72     private:
73         IBamMultiMerger* CreateMergerForCurrentSortOrder(void) const;
74         const std::string ExtractReadGroup(const std::string& headerLine) const;
75         bool LoadNextAlignment(BamAlignment& al, bool coreMode);
76         void SaveNextAlignment(BamTools::BamReader* reader, BamTools::BamAlignment* alignment);
77         const std::vector<std::string> SplitHeaderText(const std::string& headerText) const;
78         // updates our alignment cache
79         void UpdateAlignments(void);
80         // validates that we have a congruent set of BAM files that are aligned against the same reference sequences
81         void ValidateReaders(void) const;
82
83     // data members
84     public:
85         typedef std::pair<BamReader*, BamAlignment*> ReaderAlignment;
86         std::vector<ReaderAlignment> m_readers;
87
88         IBamMultiMerger* m_alignments;
89         bool m_isCoreMode;
90         BamMultiReader::SortOrder m_sortOrder;
91 };
92
93 } // namespace Internal
94 } // namespace BamTools
95
96 #endif // BAMMULTIREADER_P_H