1 // ***************************************************************************
2 // BamMultiReader_p.h (c) 2010 Derek Barnett
3 // Marth Lab, Department of Biology, Boston College
4 // ---------------------------------------------------------------------------
5 // Last modified: 25 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/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 bool GetNextAlignment(BamAlignment& al);
58 bool GetNextAlignmentCore(BamAlignment& al);
59 bool HasOpenReaders(void);
61 // access auxiliary data
62 SamHeader GetHeader(void) const;
63 std::string GetHeaderText(void) const;
64 int GetReferenceCount(void) const;
65 const BamTools::RefVector GetReferenceData(void) const;
66 int GetReferenceID(const std::string& refName) const;
68 // BAM index operations
69 bool CreateIndexes(const BamIndex::IndexType& type = BamIndex::STANDARD);
70 bool HasIndexes(void) const;
71 bool LocateIndexes(const BamIndex::IndexType& preferredType = BamIndex::STANDARD);
72 bool OpenIndexes(const std::vector<std::string>& indexFilenames);
75 std::string GetErrorString(void) const;
80 bool CloseFiles(const std::vector<std::string>& filenames);
81 IMultiMerger* CreateAlignmentCache(void) const;
82 bool PopNextCachedAlignment(BamAlignment& al, const bool needCharData);
83 bool RewindReaders(void);
84 void SaveNextAlignment(BamReader* reader, BamAlignment* alignment);
85 void SetErrorString(const std::string& where, const std::string& what) const; //
86 bool UpdateAlignmentCache(void);
87 bool ValidateReaders(void) const;
91 std::vector<MergeItem> m_readers;
92 IMultiMerger* m_alignmentCache;
93 mutable std::string m_errorString;
96 } // namespace Internal
97 } // namespace BamTools
99 #endif // BAMMULTIREADER_P_H