1 // ***************************************************************************
2 // BamMultiReader_p.h (c) 2010 Derek Barnett
3 // Marth Lab, Department of Biology, Boston College
4 // All rights reserved.
5 // ---------------------------------------------------------------------------
6 // Last modified: 17 January 2011 (DB)
7 // ---------------------------------------------------------------------------
8 // Functionality for simultaneously reading multiple BAM files
9 // *************************************************************************
11 #ifndef BAMMULTIREADER_P_H
12 #define BAMMULTIREADER_P_H
18 // This file is not part of the BamTools API. It exists purely as an
19 // implementation detail. This header file may change from version to version
20 // without notice, or even be removed.
24 #include <api/BamMultiReader.h>
31 class IBamMultiMerger;
33 class BamMultiReaderPrivate {
35 // constructor / destructor
37 BamMultiReaderPrivate(void);
38 ~BamMultiReaderPrivate(void);
45 bool Open(const std::vector<std::string>& filenames,
46 bool openIndexes = true,
47 bool coreMode = false,
48 bool preferStandardIndex = false);
49 bool IsIndexLoaded(void) const;
50 bool Jump(int refID, int position = 0);
51 void PrintFilenames(void) const;
52 bool SetRegion(const BamRegion& region);
55 // access alignment data
56 bool GetNextAlignment(BamAlignment& al);
57 bool GetNextAlignmentCore(BamAlignment& al);
58 bool HasOpenReaders(void);
59 void SetSortOrder(const BamMultiReader::SortOrder& order);
61 // access auxiliary data
62 const std::string GetHeaderText(void) const;
63 const int GetReferenceCount(void) const;
64 const BamTools::RefVector GetReferenceData(void) const;
65 const int GetReferenceID(const std::string& refName) const;
67 // BAM index operations
68 bool CreateIndexes(bool useStandardIndex = true);
69 void SetIndexCacheMode(const BamIndex::BamIndexCacheMode mode);
73 IBamMultiMerger* CreateMergerForCurrentSortOrder(void) const;
74 const std::string ExtractReadGroup(const std::string& headerLine) const;
75 bool LoadNextAlignment(BamAlignment& al, bool coreMode);
76 void SaveNextAlignment(BamTools::BamReader* reader, BamTools::BamAlignment* alignment);
77 const std::vector<std::string> SplitHeaderText(const std::string& headerText) const;
78 // updates our alignment cache
79 void UpdateAlignments(void);
80 // validates that we have a congruent set of BAM files that are aligned against the same reference sequences
81 void ValidateReaders(void) const;
85 typedef std::pair<BamReader*, BamAlignment*> ReaderAlignment;
86 std::vector<ReaderAlignment> m_readers;
88 IBamMultiMerger* m_alignments;
90 BamMultiReader::SortOrder m_sortOrder;
93 } // namespace Internal
94 } // namespace BamTools
96 #endif // BAMMULTIREADER_P_H