// Derek Barnett
// Marth Lab, Boston College
-// Last modified: 6 April 2009
+// Last modified: 23 April 2009
#include "BamReader.h"
#include <iostream>
m_currentRefID = refID;
m_currentLeft = left;
m_isRegionSpecified = true;
- return ( bam_seek(m_file, GetOffset(m_currentRefID, m_currentLeft), SEEK_SET) == 0 );
+
+ int64_t offset = GetOffset(m_currentRefID, m_currentLeft);
+ if ( offset == -1 ) { return false; }
+ else { return ( bam_seek(m_file, offset, SEEK_SET) == 0 ); }
}
return false;
}
return alignEnd;
}
-uint64_t BamReader::GetOffset(int refID, unsigned int left) {
+int64_t BamReader::GetOffset(int refID, unsigned int left) {
// make space for bins
uint16_t* bins = (uint16_t*)calloc(MAX_BIN, 2);
free(bins);
// there should be at least 1
- assert(regionChunks.size() > 0);
+ if(regionChunks.size() > 0) { return -1; }
// sort chunks by start position
sort ( regionChunks.begin(), regionChunks.end(), LookupKeyCompare<uint64_t, uint64_t>() );
}
// return beginning file offset of first chunk for region
- return regionChunks.at(0).first;
+ return (int64_t)regionChunks.at(0).first;
}
bool BamReader::IsOverlap(BamAlignment& bAlignment) {
\r
// Derek Barnett\r
// Marth Lab, Boston College\r
-// Last modified: 6 April 2009\r
+// Last modified: 23 April 2009\r
\r
#ifndef BAMREADER_H\r
#define BAMREADER_H\r
private:\r
int BinsFromRegion(int, unsigned int, uint16_t[MAX_BIN]);\r
uint32_t CalculateAlignmentEnd(const unsigned int&, const vector<CigarOp>&);\r
- uint64_t GetOffset(int, unsigned int);\r
+ int64_t GetOffset(int, unsigned int);\r
bool IsOverlap(BamAlignment&);\r
bool LoadHeader(void);\r
bool LoadIndex(void);\r