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 // *************************************************************************
10 #ifndef BAMMULTIREADER_P_H
11 #define BAMMULTIREADER_P_H
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.
23 #include <api/SamHeader.h>
24 #include <api/BamMultiReader.h>
25 #include <api/internal/BamMultiMerger_p.h>
32 class BamMultiReaderPrivate {
36 typedef std::pair<BamReader*, BamAlignment*> ReaderAlignment;
38 // constructor / destructor
40 BamMultiReaderPrivate(void);
41 ~BamMultiReaderPrivate(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);
55 bool SetRegion(const BamRegion& region);
57 // access alignment data
58 bool GetNextAlignment(BamAlignment& al);
59 bool GetNextAlignmentCore(BamAlignment& al);
60 bool HasOpenReaders(void);
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;
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);
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;
88 std::vector<MergeItem> m_readers;
89 IMultiMerger* m_alignmentCache;
92 } // namespace Internal
93 } // namespace BamTools
95 #endif // BAMMULTIREADER_P_H