Loading...
Searching...
No Matches
BamIndex.h
Go to the documentation of this file.
// ***************************************************************************
// BamIndex.h (c) 2009 Derek Barnett
// Marth Lab, Department of Biology, Boston College
// ---------------------------------------------------------------------------
// Last modified: 10 October 2011 (DB)
// ---------------------------------------------------------------------------
// Provides basic BAM index interface
// ***************************************************************************
#ifndef BAM_INDEX_H
#define BAM_INDEX_H
#include <string>
#include "api/BamAux.h"
#include "api/api_global.h"
namespace BamTools {
namespace Internal {
class BamReaderPrivate;
} // namespace Internal
class API_EXPORT BamIndex
{
// enums
public:
// list of supported BamIndex types
enum IndexType
{
BAMTOOLS = 0,
STANDARD
};
// ctor & dtor
public:
BamIndex(Internal::BamReaderPrivate* reader)
: m_reader(reader)
{}
virtual ~BamIndex() {}
// index interface
public:
// builds index from associated BAM file & writes out to index file
virtual bool Create() = 0;
// returns a human-readable description of the last error encountered
std::string GetErrorString()
{
return m_errorString;
}
// returns whether reference has alignments or no
virtual bool HasAlignments(const int& referenceID) const = 0;
// attempts to use index data to jump to @region, returns success/fail
// a "successful" jump indicates no error, but not whether this region has data
// * thus, the method sets a flag to indicate whether there are alignments
// available after the jump position
virtual bool Jump(const BamTools::BamRegion& region, bool* hasAlignmentsInRegion) = 0;
// loads existing data from file into memory
virtual bool Load(const std::string& filename) = 0;
// returns the 'type' enum for derived index format
virtual BamIndex::IndexType Type() const = 0;
// internal methods
protected:
void SetErrorString(const std::string& where, const std::string& what) const
{
m_errorString = where + ": " + what;
}
// data members
protected:
Internal::BamReaderPrivate* m_reader; // copy, not owned
mutable std::string m_errorString;
};
} // namespace BamTools
#endif // BAM_INDEX_H
BamAux.h
api_global.h
BamTools::BamIndex::Jump
virtual bool Jump(const BamTools::BamRegion &region, bool *hasAlignmentsInRegion)=0
BamTools::BamIndex::Load
virtual bool Load(const std::string &filename)=0
BamTools::BamIndex::IndexType
IndexType
Definition BamIndex.h:41
BamTools::BamIndex::STANDARD
@ STANDARD
Definition BamIndex.h:43
BamTools::BamIndex::BAMTOOLS
@ BAMTOOLS
Definition BamIndex.h:42
BamTools::BamIndex::GetErrorString
std::string GetErrorString()
Definition BamIndex.h:59
BamTools::BamIndex::Create
virtual bool Create()=0
BamTools::BamIndex::HasAlignments
virtual bool HasAlignments(const int &referenceID) const =0
BamTools::BamIndex::~BamIndex
virtual ~BamIndex()
Definition BamIndex.h:51
BamTools::BamIndex::BamIndex
BamIndex(Internal::BamReaderPrivate *reader)
Definition BamIndex.h:48
BamTools::BamIndex::Type
virtual BamIndex::IndexType Type() const =0
BamTools
Contains all BamTools classes & methods.
Definition Sort.h:24
BamTools::BamRegion
Represents a sequential genomic region.
Definition BamAux.h:90