// Marth Lab, Department of Biology, Boston College\r
// All rights reserved.\r
// ---------------------------------------------------------------------------\r
-// Last modified: 8 June 2010 (DB)\r
+// Last modified: 9 July 2010 (DB)\r
// ---------------------------------------------------------------------------\r
// Uses BGZF routines were adapted from the bgzf.c code developed at the Broad\r
// Institute.\r
#include "BamAux.h"\r
\r
namespace BamTools {\r
-\r
+ \r
class BamReader {\r
\r
// constructor / destructor\r
\r
// close BAM file\r
void Close(void);\r
+ // returns whether reader is open for reading or not\r
+ bool IsOpen(void) const;\r
// performs random-access jump to reference, position\r
bool Jump(int refID, int position = 0);\r
// opens BAM file (and optional BAM index file, if provided)\r
- void Open(const std::string& filename, const std::string& indexFilename = "");\r
+ bool Open(const std::string& filename, const std::string& indexFilename = "");\r
// returns file pointer to beginning of alignments\r
bool Rewind(void);\r
+ // sets a region of interest (with left & right bound reference/position)\r
+ // attempts a Jump() to left bound as well\r
+ // returns success/failure of Jump()\r
+ bool SetRegion(const BamRegion& region);\r
+ bool SetRegion(const int& leftRefID, const int& leftBound, const int& rightRefID, const int& rightBound);\r
\r
// ----------------------\r
// access alignment data\r
bool GetNextAlignment(BamAlignment& bAlignment);\r
\r
// retrieves next available alignment core data (returns success/fail)\r
- // ** DOES NOT parse any character data (bases, qualities, tag data)\r
+ // ** DOES NOT parse any character data (read name, bases, qualities, tag data)\r
// these can be accessed, if necessary, from the supportData \r
// useful for operations requiring ONLY positional or other alignment-related information\r
bool GetNextAlignmentCore(BamAlignment& bAlignment);\r
// returns number of reference sequences\r
int GetReferenceCount(void) const;\r
// returns vector of reference objects\r
- const BamTools::RefVector GetReferenceData(void) const;\r
+ const BamTools::RefVector& GetReferenceData(void) const;\r
// returns reference id (used for BamReader::Jump()) for the given reference name\r
int GetReferenceID(const std::string& refName) const;\r
// returns the name of the file associated with this BamReader\r
// ----------------------\r
\r
// creates index for BAM file, saves to file (default = bamFilename + ".bai")\r
- bool CreateIndex(void);\r
-\r
+ bool CreateIndex(bool useDefaultIndex = true);\r
+ \r
// private implementation\r
private:\r
struct BamReaderPrivate;\r