]> git.donarmstrong.com Git - bamtools.git/blob - src/api/internal/BamMultiReader_p.h
4c4e5ea3ba382d2186857449bf8dc1847a3f60ce
[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: 3 October 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 <api/internal/BamMultiMerger_p.h>
26 #include <string>
27 #include <vector>
28
29 namespace BamTools {
30 namespace Internal {
31
32 class BamMultiReaderPrivate {
33
34     // typedefs
35     public:
36         typedef std::pair<BamReader*, BamAlignment*> ReaderAlignment;
37
38     // constructor / destructor
39     public:
40         BamMultiReaderPrivate(void);
41         ~BamMultiReaderPrivate(void);
42
43     // public interface
44     public:
45
46         // file operations
47         void Close(void);
48         void CloseFile(const std::string& filename);
49         void CloseFiles(const std::vector<std::string>& filenames);
50         const std::vector<std::string> Filenames(void) const;
51         bool Jump(int refID, int position = 0);
52         bool Open(const std::vector<std::string>& filenames);
53         bool OpenFile(const std::string& filename);
54         bool Rewind(void);
55         bool SetRegion(const BamRegion& region);
56
57         // access alignment data
58         bool GetNextAlignment(BamAlignment& al);
59         bool GetNextAlignmentCore(BamAlignment& al);
60         bool HasOpenReaders(void);
61
62         // access auxiliary data
63         SamHeader GetHeader(void) const;
64         std::string GetHeaderText(void) const;
65         int GetReferenceCount(void) const;
66         const BamTools::RefVector GetReferenceData(void) const;
67         int GetReferenceID(const std::string& refName) const;
68
69         // BAM index operations
70         bool CreateIndexes(const BamIndex::IndexType& type = BamIndex::STANDARD);
71         bool HasIndexes(void) const;
72         bool LocateIndexes(const BamIndex::IndexType& preferredType = BamIndex::STANDARD);
73         bool OpenIndexes(const std::vector<std::string>& indexFilenames);
74         void SetIndexCacheMode(const BamIndex::IndexCacheMode mode);
75
76     // 'internal' methods
77     public:
78
79         IMultiMerger* CreateAlignmentCache(void) const;
80         bool PopNextCachedAlignment(BamAlignment& al, const bool needCharData);
81         bool RewindReaders(void);
82         void SaveNextAlignment(BamReader* reader, BamAlignment* alignment);
83         bool UpdateAlignmentCache(void);
84         bool ValidateReaders(void) const;
85
86     // data members
87     public:
88         std::vector<MergeItem> m_readers;
89         IMultiMerger* m_alignmentCache;
90 };
91
92 } // namespace Internal
93 } // namespace BamTools
94
95 #endif // BAMMULTIREADER_P_H