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 {
34 // constructor / destructor
36 BamMultiReaderPrivate(void);
37 ~BamMultiReaderPrivate(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);
51 bool SetRegion(const BamRegion& region);
53 // access alignment data
54 bool GetNextAlignment(BamAlignment& al);
55 bool GetNextAlignmentCore(BamAlignment& al);
56 bool HasOpenReaders(void);
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;
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);
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;
83 std::vector<MergeItem> m_readers;
84 IMultiMerger* m_alignmentCache;
87 } // namespace Internal
88 } // namespace BamTools
90 #endif // BAMMULTIREADER_P_H