// Marth Lab, Department of Biology, Boston College
// All rights reserved.
// ---------------------------------------------------------------------------
-// Last modified: 3 September 2010 (DB)
+// Last modified: 18 September 2010 (DB)
// ---------------------------------------------------------------------------
// Provides index functionality - both for the standardized BAM index format
// (".bai") as well as a BamTools-specific (nonstandard) index format (".bti").
#include <iostream>
#include <string>
#include <vector>
-#include "BamAux.h"
+#include "BamAlignment.h"
namespace BamTools {
public:
BamIndex(BamTools::BgzfData* bgzf, BamTools::BamReader* reader, bool isBigEndian);
virtual ~BamIndex(void) { }
-
+
// index interface
public:
// creates index data (in-memory) from current reader data
virtual bool Build(void) =0;
// returns supported file extension
virtual const std::string Extension(void) const =0;
- // calculates offset(s) for a given region
- virtual bool GetOffsets(const BamTools::BamRegion& region, const bool isRightBoundSpecified, std::vector<int64_t>& offsets) =0;
+ // attempts to use index 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;
// returns whether reference has alignments or no
virtual bool HasAlignments(const int& referenceID);
// loads existing data from file into memory
bool Build(void);
// returns supported file extension
const std::string Extension(void) const { return std::string(".bai"); }
- // calculates offset(s) for a given region
- bool GetOffsets(const BamTools::BamRegion& region, const bool isRightBoundSpecified, std::vector<int64_t>& offsets);
+ // attempts to use index 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
+ bool Jump(const BamTools::BamRegion& region, bool* hasAlignmentsInRegion);
// loads existing data from file into memory
bool Load(const std::string& filename);
// writes in-memory index data out to file
bool Build(void);
// returns supported file extension
const std::string Extension(void) const { return std::string(".bti"); }
- // calculates offset(s) for a given region
- bool GetOffsets(const BamTools::BamRegion& region, const bool isRightBoundSpecified, std::vector<int64_t>& offsets);
+ // attempts to use index 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
+ bool Jump(const BamTools::BamRegion& region, bool* hasAlignmentsInRegion);
// loads existing data from file into memory
bool Load(const std::string& filename);
// writes in-memory index data out to file