13 // BamIndex base class
17 BamIndex(BamTools::BgzfData* bgzf,
18 BamTools::BamReader* reader,
20 virtual ~BamIndex(void) { }
23 // creates index data (in-memory) from current reader data
24 virtual bool Build(void) =0;
25 // calculates offset(s) for a given region
26 virtual bool GetOffsets(const BamTools::BamRegion& region, const bool isRightBoundSpecified, std::vector<int64_t>& offsets) =0;
27 // loads existing data from file into memory
28 virtual bool Load(const std::string& filename) =0;
29 // returns whether reference has alignments or no
30 virtual bool HasAlignments(const int& referenceID);
31 // writes in-memory index data out to file
32 // N.B. - (this is the original BAM filename, method will modify it to use applicable extension)
33 virtual bool Write(const std::string& bamFilename) =0;
36 BamTools::BgzfData* m_BGZF;
37 BamTools::BamReader* m_reader;
38 BamTools::RefVector m_references;
42 // BamDefaultIndex class
44 // implements default (per SAM/BAM spec) index file ops
45 class BamDefaultIndex : public BamIndex {
50 BamDefaultIndex(BamTools::BgzfData* bgzf,
51 BamTools::BamReader* reader,
53 ~BamDefaultIndex(void);
55 // interface (implements BamIndex virtual methods)
57 // creates index data (in-memory) from current reader data
59 // calculates offset(s) for a given region
60 bool GetOffsets(const BamTools::BamRegion& region, const bool isRightBoundSpecified, std::vector<int64_t>& offsets);
61 // loads existing data from file into memory
62 bool Load(const std::string& filename);
63 // writes in-memory index data out to file
64 // N.B. - (this is the original BAM filename, method will modify it to use applicable extension)
65 bool Write(const std::string& bamFilename);
67 // internal implementation
69 struct BamDefaultIndexPrivate;
70 BamDefaultIndexPrivate* d;
73 // BamToolsIndex class
75 // implements BamTools-specific index file ops
76 class BamToolsIndex : public BamIndex {
80 BamToolsIndex(BamTools::BgzfData* bgzf,
81 BamTools::BamReader* reader,
85 // interface (implements BamIndex virtual methods)
87 // creates index data (in-memory) from current reader data
89 // calculates offset(s) for a given region
90 bool GetOffsets(const BamTools::BamRegion& region, const bool isRightBoundSpecified, std::vector<int64_t>& offsets);
91 // loads existing data from file into memory
92 bool Load(const std::string& filename);
93 // writes in-memory index data out to file
94 // N.B. - (this is the original BAM filename, method will modify it to use applicable extension)
95 bool Write(const std::string& bamFilename);
97 // internal implementation
99 struct BamToolsIndexPrivate;
100 BamToolsIndexPrivate* d;
103 } // namespace BamTools
105 #endif // BAM_INDEX_H