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