]> git.donarmstrong.com Git - bamtools.git/blob - src/api/internal/BamMultiReader_p.h
Cleaned up intra-API includes & moved version numbers to 2.0.0
[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: 10 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         bool Close(void);
48         bool CloseFile(const std::string& filename);
49         const std::vector<std::string> Filenames(void) const;
50         bool Jump(int refID, int position = 0);
51         bool Open(const std::vector<std::string>& filenames);
52         bool OpenFile(const std::string& filename);
53         bool Rewind(void);
54         bool SetRegion(const BamRegion& region);
55
56         // access alignment data
57         bool GetNextAlignment(BamAlignment& al);
58         bool GetNextAlignmentCore(BamAlignment& al);
59         bool HasOpenReaders(void);
60
61         // access auxiliary data
62         SamHeader GetHeader(void) const;
63         std::string GetHeaderText(void) const;
64         int GetReferenceCount(void) const;
65         const BamTools::RefVector GetReferenceData(void) const;
66         int GetReferenceID(const std::string& refName) const;
67
68         // BAM index operations
69         bool CreateIndexes(const BamIndex::IndexType& type = BamIndex::STANDARD);
70         bool HasIndexes(void) const;
71         bool LocateIndexes(const BamIndex::IndexType& preferredType = BamIndex::STANDARD);
72         bool OpenIndexes(const std::vector<std::string>& indexFilenames);
73         void SetIndexCacheMode(const BamIndex::IndexCacheMode mode);
74
75         // error handling
76         std::string GetErrorString(void) const;
77
78     // 'internal' methods
79     public:
80
81         bool CloseFiles(const std::vector<std::string>& filenames);
82         IMultiMerger* CreateAlignmentCache(void) const;
83         bool PopNextCachedAlignment(BamAlignment& al, const bool needCharData);
84         bool RewindReaders(void);
85         void SaveNextAlignment(BamReader* reader, BamAlignment* alignment);
86         void SetErrorString(const std::string& where, const std::string& what) const; //
87         bool UpdateAlignmentCache(void);
88         bool ValidateReaders(void) const;
89
90     // data members
91     public:
92         std::vector<MergeItem> m_readers;
93         IMultiMerger* m_alignmentCache;
94         mutable std::string m_errorString;
95 };
96
97 } // namespace Internal
98 } // namespace BamTools
99
100 #endif // BAMMULTIREADER_P_H