BamTools 2.5.2
Loading...
Searching...
No Matches
BamIndex.h
Go to the documentation of this file.
1// ***************************************************************************
2// BamIndex.h (c) 2009 Derek Barnett
3// Marth Lab, Department of Biology, Boston College
4// ---------------------------------------------------------------------------
5// Last modified: 10 October 2011 (DB)
6// ---------------------------------------------------------------------------
7// Provides basic BAM index interface
8// ***************************************************************************
9
10#ifndef BAM_INDEX_H
11#define BAM_INDEX_H
12
13#include <string>
14#include "api/BamAux.h"
15#include "api/api_global.h"
16
17namespace BamTools {
18
19namespace Internal {
20class BamReaderPrivate;
21} // namespace Internal
22
34class API_EXPORT BamIndex
35{
36
37 // enums
38public:
39 // list of supported BamIndex types
41 {
42 BAMTOOLS = 0,
43 STANDARD
44 };
45
46 // ctor & dtor
47public:
48 BamIndex(Internal::BamReaderPrivate* reader)
49 : m_reader(reader)
50 {}
51 virtual ~BamIndex() {}
52
53 // index interface
54public:
55 // builds index from associated BAM file & writes out to index file
56 virtual bool Create() = 0;
57
58 // returns a human-readable description of the last error encountered
59 std::string GetErrorString()
60 {
61 return m_errorString;
62 }
63
64 // returns whether reference has alignments or no
65 virtual bool HasAlignments(const int& referenceID) const = 0;
66
67 // attempts to use index data to jump to @region, returns success/fail
68 // a "successful" jump indicates no error, but not whether this region has data
69 // * thus, the method sets a flag to indicate whether there are alignments
70 // available after the jump position
71 virtual bool Jump(const BamTools::BamRegion& region, bool* hasAlignmentsInRegion) = 0;
72
73 // loads existing data from file into memory
74 virtual bool Load(const std::string& filename) = 0;
75
76 // returns the 'type' enum for derived index format
77 virtual BamIndex::IndexType Type() const = 0;
78
80
81 // internal methods
82protected:
83 void SetErrorString(const std::string& where, const std::string& what) const
84 {
85 m_errorString = where + ": " + what;
86 }
87
88 // data members
89protected:
90 Internal::BamReaderPrivate* m_reader; // copy, not owned
91 mutable std::string m_errorString;
92
94};
95
96} // namespace BamTools
97
98#endif // BAM_INDEX_H
Provides methods for generating & loading BAM index files.
Definition BamIndex.h:35
virtual bool Jump(const BamTools::BamRegion &region, bool *hasAlignmentsInRegion)=0
virtual bool Load(const std::string &filename)=0
IndexType
Definition BamIndex.h:41
std::string GetErrorString()
Definition BamIndex.h:59
virtual bool Create()=0
virtual bool HasAlignments(const int &referenceID) const =0
virtual ~BamIndex()
Definition BamIndex.h:51
BamIndex(Internal::BamReaderPrivate *reader)
Definition BamIndex.h:48
virtual BamIndex::IndexType Type() const =0
Contains all BamTools classes & methods.
Definition Sort.h:24
Represents a sequential genomic region.
Definition BamAux.h:90