Mercurial > repos > aaronquinlan > multi_intersect
comparison BEDTools-Version-2.14.3/src/utils/BamTools/src/api/BamMultiReader.h @ 0:dfcd8b6c1bda
Uploaded
author | aaronquinlan |
---|---|
date | Thu, 03 Nov 2011 10:25:04 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:dfcd8b6c1bda |
---|---|
1 // *************************************************************************** | |
2 // BamMultiReader.h (c) 2010 Erik Garrison, Derek Barnett | |
3 // Marth Lab, Department of Biology, Boston College | |
4 // All rights reserved. | |
5 // --------------------------------------------------------------------------- | |
6 // Last modified: 15 March 2011 (DB) | |
7 // --------------------------------------------------------------------------- | |
8 // Convenience class for reading multiple BAM files. | |
9 // *************************************************************************** | |
10 | |
11 #ifndef BAMMULTIREADER_H | |
12 #define BAMMULTIREADER_H | |
13 | |
14 #include <api/api_global.h> | |
15 #include <api/BamReader.h> | |
16 #include <map> | |
17 #include <sstream> | |
18 #include <string> | |
19 #include <utility> | |
20 | |
21 namespace BamTools { | |
22 | |
23 namespace Internal { | |
24 class BamMultiReaderPrivate; | |
25 } // namespace Internal | |
26 | |
27 class API_EXPORT BamMultiReader { | |
28 | |
29 public: | |
30 enum SortOrder { SortedByPosition = 0 | |
31 , SortedByReadName | |
32 , Unsorted | |
33 }; | |
34 | |
35 // constructor / destructor | |
36 public: | |
37 BamMultiReader(void); | |
38 ~BamMultiReader(void); | |
39 | |
40 // public interface | |
41 public: | |
42 | |
43 // ---------------------- | |
44 // BAM file operations | |
45 // ---------------------- | |
46 | |
47 // closes all open BAM files | |
48 void Close(void); | |
49 // close only the requested BAM file | |
50 void CloseFile(const std::string& filename); | |
51 // returns list of filenames for all open BAM files | |
52 const std::vector<std::string> Filenames(void) const; | |
53 // returns true if multireader has any open BAM files | |
54 bool HasOpenReaders(void) const; | |
55 // performs random-access jump within current BAM files | |
56 bool Jump(int refID, int position = 0); | |
57 // opens BAM files | |
58 bool Open(const std::vector<std::string>& filenames); | |
59 // opens a single BAM file, adding to any other current BAM files | |
60 bool OpenFile(const std::string& filename); | |
61 // returns file pointers to beginning of alignments | |
62 bool Rewind(void); | |
63 // sets the target region of interest | |
64 bool SetRegion(const BamRegion& region); | |
65 // sets the target region of interest | |
66 bool SetRegion(const int& leftRefID, | |
67 const int& leftPosition, | |
68 const int& rightRefID, | |
69 const int& rightPosition); | |
70 | |
71 // ---------------------- | |
72 // access alignment data | |
73 // ---------------------- | |
74 | |
75 // retrieves next available alignment | |
76 bool GetNextAlignment(BamAlignment& alignment); | |
77 // retrieves next available alignmnet (without populating the alignment's string data fields) | |
78 bool GetNextAlignmentCore(BamAlignment& alignment); | |
79 | |
80 // sets the expected sorting order for reading across multiple BAM files | |
81 void SetSortOrder(const SortOrder& order); | |
82 | |
83 // ---------------------- | |
84 // access auxiliary data | |
85 // ---------------------- | |
86 | |
87 // returns unified SAM header for all files | |
88 SamHeader GetHeader(void) const; | |
89 // returns unified SAM header text for all files | |
90 std::string GetHeaderText(void) const; | |
91 // returns number of reference sequences | |
92 int GetReferenceCount(void) const; | |
93 // returns all reference sequence entries. | |
94 const BamTools::RefVector GetReferenceData(void) const; | |
95 // returns the ID of the reference with this name. | |
96 int GetReferenceID(const std::string& refName) const; | |
97 | |
98 // ---------------------- | |
99 // BAM index operations | |
100 // ---------------------- | |
101 | |
102 // creates index files for current BAM files | |
103 bool CreateIndexes(const BamIndex::IndexType& type = BamIndex::STANDARD); | |
104 // returns true if all BAM files have index data available | |
105 bool HasIndexes(void) const; | |
106 // looks for index files that match current BAM files | |
107 bool LocateIndexes(const BamIndex::IndexType& preferredType = BamIndex::STANDARD); | |
108 // opens index files for current BAM files. | |
109 bool OpenIndexes(const std::vector<std::string>& indexFilenames); | |
110 // changes the caching behavior of the index data | |
111 void SetIndexCacheMode(const BamIndex::IndexCacheMode& mode); | |
112 | |
113 // deprecated methods | |
114 public: | |
115 // returns \c true if all BAM files have index data available. | |
116 bool IsIndexLoaded(void) const; | |
117 // convenience method for printing filenames to stdout | |
118 void PrintFilenames(void) const; | |
119 | |
120 // private implementation | |
121 private: | |
122 Internal::BamMultiReaderPrivate* d; | |
123 }; | |
124 | |
125 } // namespace BamTools | |
126 | |
127 #endif // BAMMULTIREADER_H |