]> git.donarmstrong.com Git - bamtools.git/blob - src/api/internal/BamMultiReader_p.h
Major update to BamTools version 1.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 // All rights reserved.
5 // ---------------------------------------------------------------------------
6 // Last modified: 13 March 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/SamHeader.h>
25 #include <api/BamMultiReader.h>
26 #include <string>
27 #include <vector>
28
29 namespace BamTools {
30 namespace Internal {
31
32 class IBamMultiMerger;
33
34 class BamMultiReaderPrivate {
35
36     // constructor / destructor
37     public:
38         BamMultiReaderPrivate(void);
39         ~BamMultiReaderPrivate(void);
40
41     // public interface
42     public:
43
44         // file operations
45         void Close(void);
46         void CloseFile(const std::string& filename);
47         void CloseFiles(const std::vector<std::string>& filenames);
48         const std::vector<std::string> Filenames(void) const;
49         bool Jump(int refID, int position = 0);
50         bool Open(const std::vector<std::string>& filenames);
51         bool OpenFile(const std::string& filename);
52         void PrintFilenames(void) const;
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         void SetSortOrder(const BamMultiReader::SortOrder& order);
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         IBamMultiMerger* CreateMergerForCurrentSortOrder(void) const;
79         const std::string ExtractReadGroup(const std::string& headerLine) const;
80         bool HasAlignmentData(void) const;
81         bool LoadNextAlignment(BamAlignment& al);
82         BamTools::BamReader* OpenReader(const std::string& filename);
83         bool RewindReaders(void);
84         void SaveNextAlignment(BamTools::BamReader* reader, BamTools::BamAlignment* alignment);
85         const std::vector<std::string> SplitHeaderText(const std::string& headerText) const;
86         void UpdateAlignmentCache(void);
87         void ValidateReaders(void) const;
88
89     // data members
90     public:
91         typedef std::pair<BamReader*, BamAlignment*> ReaderAlignment;
92         std::vector<ReaderAlignment> m_readers;
93
94         IBamMultiMerger* m_alignments;
95         bool m_isCoreMode;
96         BamMultiReader::SortOrder m_sortOrder;
97 };
98
99 } // namespace Internal
100 } // namespace BamTools
101
102 #endif // BAMMULTIREADER_P_H