Skip to content
Snippets Groups Projects
Commit 8fe692c5 authored by nkindlon's avatar nkindlon
Browse files

Moved short circuit for BAM unmapped reads to Record::sameChromIntersect for...

Moved short circuit for BAM unmapped reads to Record::sameChromIntersect for when query record isn't BAM but DB record is.
parent 5795975f
No related branches found
No related tags found
No related merge requests found
......@@ -39,6 +39,7 @@ Context::Context()
_databaseFileIdx(-1),
_bamHeaderAndRefIdx(-1),
_maxNumDatabaseFields(0),
_useFullBamTags(false),
_reportCount(false),
_maxDistance(0),
_reportNames(false),
......@@ -234,6 +235,10 @@ bool Context::parseCmdArgs(int argc, char **argv, int skipFirstArgs) {
setUncompressedBam(true);
markUsed(i - skipFirstArgs);
}
else if (strcmp(argv[i], "-fbam") == 0) {
setUseFullBamTags(true);
markUsed(i - skipFirstArgs);
}
else if(strcmp(argv[i], "-sorted") == 0) {
setSortedInput(true);
markUsed(i - skipFirstArgs);
......@@ -327,7 +332,7 @@ bool Context::cmdArgsValid()
int Context::getBamHeaderAndRefIdx() {
if (_bamHeaderAndRefIdx != -1) {
//already found which BAM file to usefor the header
//already found which BAM file to use for the header
return _bamHeaderAndRefIdx;
}
if (_inputFiles[_queryFileIdx]._fileType == FileRecordTypeChecker::BAM_FILE_TYPE) {
......
......@@ -162,6 +162,9 @@ public:
bool getPrintable() const { return _printable; }
void setPrintable(bool val) { _printable = val; }
bool getUseFullBamTags() const { return _useFullBamTags; }
void setUseFullBamTags(bool val) { _useFullBamTags = val; }
//
// MERGE METHODS
//
......@@ -234,6 +237,7 @@ protected:
int _databaseFileIdx;
int _bamHeaderAndRefIdx;
int _maxNumDatabaseFields;
bool _useFullBamTags;
bool _reportCount;
int _maxDistance;
......
......@@ -227,7 +227,7 @@ void FileRecordMgr::allocateFileReader()
case FileRecordTypeChecker::BAM_FILE_TYPE:
_fileReader = new BamFileReader();
(static_cast<BamFileReader *>(_fileReader))->setUseTags(_useFullBamTags);
(static_cast<BamFileReader *>(_fileReader))->setUseTags(_context->getUseFullBamTags());
break;
default:
break;
......
......@@ -114,7 +114,9 @@ void RecordOutputMgr::printRecord(RecordKeyList &keyList, RecordKeyList *blockLi
if (needsFlush()) {
flush();
}
// if (keyList.getKey()->getChrName() == "chr1" && keyList.getKey()->getStartPos() == 11996) {
// printf("Break point here.\n");
// }
//The first time we print a record is when we print any header, because the header
//hasn't been read from the query file until after the first record has also been read.
if (_context->getPrintHeader()) {
......
......@@ -52,9 +52,37 @@ void BamRecord::clear()
{
Bed6Interval::clear();
_bamChromId = -1;
//For now, we're going to not clear the BamAlignment object, as all of its
//fields will be reset next time it is used anyway. If testing shows this to be a
//problem, we'll revisit.
//Clear the BamAlignment object. Sadly, it does not have a clear() method,
//so we have to do each member manually.
_bamAlignment.Name.clear();
_bamAlignment.Length = 0;
_bamAlignment.QueryBases.clear();
_bamAlignment.AlignedBases.clear();
_bamAlignment.Qualities.clear();
_bamAlignment.TagData.clear();
_bamAlignment.RefID = -1;
_bamAlignment.Position = -1;
_bamAlignment.Bin = 0;
_bamAlignment.MapQuality = 0;
_bamAlignment.AlignmentFlag = 0;
_bamAlignment.CigarData.clear();
_bamAlignment.MateRefID = -1;
_bamAlignment.MatePosition = -1;
_bamAlignment.InsertSize = -1;
_bamAlignment.Filename.clear();
_bamAlignment.SupportData.AllCharData.clear();
_bamAlignment.SupportData.BlockLength = 0;
_bamAlignment.SupportData.NumCigarOperations = 0;
_bamAlignment.SupportData.QueryNameLength = 0;
_bamAlignment.SupportData.QuerySequenceLength = 0;
_bamAlignment.SupportData.HasCoreOnly = false;
_bamAlignment.ErrorString.clear();
}
void BamRecord::print(QuickString &outBuf, RecordKeyList *keyList) const
......@@ -127,13 +155,3 @@ void BamRecord::printUnmapped(QuickString &outBuf) const {
outBuf.append(_score);
outBuf.append("\t.\t-1\t-1\t-1\t0,0,0\t0\t.\t."); // dot for strand, -1 for blockStarts and blockEnd
}
bool BamRecord::sameChromIntersects(const Record *record,
bool wantSameStrand, bool wantDiffStrand, float overlapFraction, bool reciprocal) const
{
// Special: For BAM records that are unmapped, intersect should automatically return false
if (_isUnmapped || record->isUnmapped()) {
return false;
}
return Record::sameChromIntersects(record, wantSameStrand, wantDiffStrand, overlapFraction, reciprocal);
}
......@@ -38,9 +38,6 @@ public:
const BamTools::BamAlignment &getAlignment() const { return _bamAlignment; }
int getBamChromId() const { return _bamChromId; }
virtual bool sameChromIntersects(const Record *otherRecord,
bool sameStrand, bool diffStrand, float overlapFraction, bool reciprocal) const;
protected:
BamTools::BamAlignment _bamAlignment;
int _bamChromId; //different from chromId, because BAM file may be in different order
......
......@@ -135,6 +135,11 @@ bool Record::intersects(const Record *record,
bool Record::sameChromIntersects(const Record *record,
bool wantSameStrand, bool wantDiffStrand, float overlapFraction, bool reciprocal) const
{
// Special: For records that are unmapped, intersect should automatically return false
if (_isUnmapped || record->isUnmapped()) {
return false;
}
//If user requested hits only on same strand, or only on different strands,
//rule out different strandedness first.
//If the strand is unknown in either case, then queries regarding strandedness
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment