1 // ***************************************************************************
2 // BamMultiReader_p.h (c) 2010 Derek Barnett
3 // Marth Lab, Department of Biology, Boston College
4 // ---------------------------------------------------------------------------
5 // Last modified: 14 January 2013 (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/bam/BamMultiMerger_p.h"
32 class BamMultiReaderPrivate {
36 typedef std::pair<BamReader*, BamAlignment*> ReaderAlignment;
38 // constructor / destructor
40 BamMultiReaderPrivate(void);
41 ~BamMultiReaderPrivate(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);
54 bool SetRegion(const BamRegion& region);
56 // access alignment data
57 BamMultiReader::MergeOrder GetMergeOrder(void) const;
58 bool GetNextAlignment(BamAlignment& al);
59 bool GetNextAlignmentCore(BamAlignment& al);
60 bool HasOpenReaders(void);
61 bool SetExplicitMergeOrder(BamMultiReader::MergeOrder order);
63 // access auxiliary data
64 SamHeader GetHeader(void) const;
65 std::string GetHeaderText(void) const;
66 int GetReferenceCount(void) const;
67 const BamTools::RefVector GetReferenceData(void) const;
68 int GetReferenceID(const std::string& refName) const;
70 // BAM index operations
71 bool CreateIndexes(const BamIndex::IndexType& type = BamIndex::STANDARD);
72 bool HasIndexes(void) const;
73 bool LocateIndexes(const BamIndex::IndexType& preferredType = BamIndex::STANDARD);
74 bool OpenIndexes(const std::vector<std::string>& indexFilenames);
77 std::string GetErrorString(void) const;
82 bool CloseFiles(const std::vector<std::string>& filenames);
83 IMultiMerger* CreateAlignmentCache(void);
84 bool PopNextCachedAlignment(BamAlignment& al, const bool needCharData);
85 bool RewindReaders(void);
86 void SaveNextAlignment(BamReader* reader, BamAlignment* alignment);
87 void SetErrorString(const std::string& where, const std::string& what) const; //
88 bool UpdateAlignmentCache(void);
89 bool ValidateReaders(void) const;
93 std::vector<MergeItem> m_readers;
94 IMultiMerger* m_alignmentCache;
96 bool m_hasUserMergeOrder;
97 BamMultiReader::MergeOrder m_mergeOrder;
99 mutable std::string m_errorString;
102 } // namespace Internal
103 } // namespace BamTools
105 #endif // BAMMULTIREADER_P_H