]> git.donarmstrong.com Git - bamtools.git/blob - src/api/internal/BamMultiReader_p.h
Minor cleanup
[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 // ---------------------------------------------------------------------------
5 // Last modified: 9 September 2011 (DB)
6 // ---------------------------------------------------------------------------
7 // Functionality for simultaneously reading multiple BAM files
8 // *************************************************************************
9
10 #ifndef BAMMULTIREADER_P_H
11 #define BAMMULTIREADER_P_H
12
13 //  -------------
14 //  W A R N I N G
15 //  -------------
16 //
17 // This file is not part of the BamTools API.  It exists purely as an
18 // implementation detail. This header file may change from version to version
19 // without notice, or even be removed.
20 //
21 // We mean it.
22
23 #include <api/SamHeader.h>
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     // typedefs
36     public:
37         typedef std::pair<BamReader*, BamAlignment*> ReaderAlignment;
38
39     // constructor / destructor
40     public:
41         BamMultiReaderPrivate(void);
42         ~BamMultiReaderPrivate(void);
43
44     // public interface
45     public:
46
47         // file operations
48         void Close(void);
49         void CloseFile(const std::string& filename);
50         void CloseFiles(const std::vector<std::string>& filenames);
51         const std::vector<std::string> Filenames(void) const;
52         bool Jump(int refID, int position = 0);
53         bool Open(const std::vector<std::string>& filenames);
54         bool OpenFile(const std::string& filename);
55         void PrintFilenames(void) const;
56         bool Rewind(void);
57         bool SetRegion(const BamRegion& region);
58
59         // access alignment data
60         bool GetNextAlignment(BamAlignment& al);
61         bool GetNextAlignmentCore(BamAlignment& al);
62         bool HasOpenReaders(void);
63         void SetSortOrder(const BamMultiReader::SortOrder& order);
64
65         // access auxiliary data
66         SamHeader GetHeader(void) const;
67         std::string GetHeaderText(void) const;
68         int GetReferenceCount(void) const;
69         const BamTools::RefVector GetReferenceData(void) const;
70         int GetReferenceID(const std::string& refName) const;
71
72         // BAM index operations
73         bool CreateIndexes(const BamIndex::IndexType& type = BamIndex::STANDARD);
74         bool HasIndexes(void) const;
75         bool LocateIndexes(const BamIndex::IndexType& preferredType = BamIndex::STANDARD);
76         bool OpenIndexes(const std::vector<std::string>& indexFilenames);
77         void SetIndexCacheMode(const BamIndex::IndexCacheMode mode);
78
79     // 'internal' methods
80     public:
81         IBamMultiMerger* CreateMergerForCurrentSortOrder(void) const;
82         const std::string ExtractReadGroup(const std::string& headerLine) const;
83         bool HasAlignmentData(void) const;
84         bool LoadNextAlignment(BamReader* reader, BamAlignment* alignment);
85         ReaderAlignment OpenReader(const std::string& filename, bool* ok);
86         bool PopNextCachedAlignment(BamAlignment& al, const bool needCharData);
87         bool RewindReaders(void);
88         void SaveNextAlignment(BamReader* reader, BamAlignment* alignment);
89         const std::vector<std::string> SplitHeaderText(const std::string& headerText) const;
90         void UpdateAlignmentCache(void);
91         void ValidateReaders(void) const;
92
93     // data members
94     public:        
95         std::vector<ReaderAlignment> m_readers;
96         IBamMultiMerger* m_alignments;
97         BamMultiReader::SortOrder m_sortOrder;
98 };
99
100 } // namespace Internal
101 } // namespace BamTools
102
103 #endif // BAMMULTIREADER_P_H