Commit dbc19ad2 authored by Neil Kindlon's avatar Neil Kindlon
Browse files

bug fixes for kclosest sorted output, 0 length records, and map a vs b file with multi-dbs

parent ba3bb104
......@@ -65,7 +65,6 @@ ContextBase::ContextBase()
{
_programNames["intersect"] = INTERSECT;
_programNames["sample"] = SAMPLE;
_programNames["spacing"] = SPACING;
_programNames["map"] = MAP;
_programNames["merge"] = MERGE;
......@@ -220,12 +219,12 @@ bool ContextBase::isValidState()
}
if (hasColumnOpsMethods()) {
// TBD: Adjust column ops for multiple databases.
// For now, use last file.
FileRecordMgr *dbFile = getFile(getNumInputFiles()-1);
_keyListOps->setDBfileType(dbFile->getFileType());
if (!_keyListOps->isValidColumnOps(dbFile)) {
return false;
for (int i=0; i < (int)_dbFileIdxs.size(); i++) {
FileRecordMgr *dbFile = getFile(_dbFileIdxs[i]);
_keyListOps->setDBfileType(dbFile->getFileType());
if (!_keyListOps->isValidColumnOps(dbFile)) {
return false;
}
}
//if user specified a precision, pass it to
//keyList ops
......@@ -521,6 +520,7 @@ bool ContextBase::handle_null()
bool ContextBase::handle_delim()
{
if (!hasColumnOpsMethods()) {
_errorMsg = "\n***** ERROR: Can't set delimiter for tools without column operations. Exiting. *****";
return false;
}
if ((_i+1) < _argc) {
......
......@@ -27,7 +27,18 @@ public:
class DistanceTupleSortAscFunctor {
public:
bool operator()(const distanceTuple & d1, const distanceTuple & d2) const {
return ((d1._dist < d2._dist) ? true : (d1._dist == d2._dist ? (d1._isNeg && !d2._isNeg) : false)) ; }
// return ((d1._dist < d2._dist) ? true : (d1._dist == d2._dist ? (d1._rec->lessThan(d2._rec)) : false)); }
return (d1._dist < d2._dist ? true : (d1._dist == d2._dist ? d1._rec->lessThan(d2._rec) : false));
// if (d1._dist < d2._dist) {
// return true;
// } else if (d1._dist == d2._dist) {
// if () {
// return true;
// }
// }
// return false;
}
};
......
......@@ -218,6 +218,8 @@ void RecordOutputMgr::printRecord(RecordKeyVector &keyList, RecordKeyVector *blo
if (printKeyAndTerminate(keyList)) {
_currBamBlockList = NULL;
const_cast<Record *>(keyList.getKey())->adjustZeroLength();
return;
}
tab();
......@@ -231,6 +233,7 @@ void RecordOutputMgr::printRecord(RecordKeyVector &keyList, RecordKeyVector *blo
if (printKeyAndTerminate(keyList)) {
_currBamBlockList = NULL;
const_cast<Record *>(keyList.getKey())->adjustZeroLength();
return;
}
tab();
......@@ -245,6 +248,7 @@ void RecordOutputMgr::printRecord(RecordKeyVector &keyList, RecordKeyVector *blo
if (printBamRecord(keyList, true) == BAM_AS_BAM) {
_currBamBlockList = NULL;
const_cast<Record *>(keyList.getKey())->adjustZeroLength();
return;
}
int hitIdx = 0;
......@@ -261,24 +265,12 @@ void RecordOutputMgr::printRecord(RecordKeyVector &keyList, RecordKeyVector *blo
if (!printKeyAndTerminate(keyList)) {
newline();
}
_currBamBlockList = NULL;
return;
} else if (_context->getProgram() == ContextBase::MAP) {
printKeyAndTerminate(keyList);
_currBamBlockList = NULL;
return;
} else if (_context->getProgram() == ContextBase::MERGE) {
} else if (_context->getProgram() == ContextBase::MAP || _context->getProgram() == ContextBase::MERGE) {
printKeyAndTerminate(keyList);
_currBamBlockList = NULL;
return;
} else if (_context->getProgram() == ContextBase::SPACING) {
keyList.getKey()->print(_outBuf);
_currBamBlockList = NULL;
return;
}
_currBamBlockList = NULL;
const_cast<Record *>(keyList.getKey())->adjustZeroLength();
}
void RecordOutputMgr::checkForHeader() {
......@@ -397,7 +389,7 @@ void RecordOutputMgr::reportOverlapDetail(const Record *keyRecord, const Record
newline();
if (needsFlush()) flush();
}
const_cast<Record *>(keyRecord)->adjustZeroLength();
const_cast<Record *>(hitRecord)->adjustZeroLength();
}
void RecordOutputMgr::reportOverlapSummary(RecordKeyVector &keyList)
......
......@@ -471,21 +471,22 @@ rm obs exp
# Test multiple databases and mdb = all mode
###########################################################
echo " kclosest.t30...\c"
echo \
"chr1 100 110 q2.1 20 + 1 chr1 98 108 2.2 20 + 0
chr1 100 110 q2.1 20 + 1 chr1 105 115 2.3 20 + 0
"chr1 100 110 q2.1 20 + 2 chr1 90 105 3.7 20 + 0
chr1 100 110 q2.1 20 + 1 chr1 95 105 2.1 20 + 0
chr1 100 110 q2.1 20 + 2 chr1 95 110 3.8 20 - 0
chr1 100 110 q2.1 20 + 2 chr1 90 105 3.7 20 + 0
chr1 100 110 q2.1 20 + 1 chr1 98 108 2.2 20 + 0
chr1 100 110 q2.1 20 + 1 chr1 105 115 2.3 20 + 0
chr1 100 110 q2.1 20 + 2 chr1 110 115 3.9 20 + 1
chr1 100 110 q2.1 20 + 1 chr1 120 130 2.4 20 + 11
chr1 100 110 q2.1 20 + 2 chr1 120 130 3.10 20 - 11
chr1 100 110 q2.1 20 + 2 chr1 70 80 3.6 20 + -21
chr1 100 110 q2.1 20 + 2 chr1 75 80 3.65 20 + -21
chr1 105 110 q2.2 20 - 1 chr1 105 115 2.3 20 + 0
chr1 105 110 q2.2 20 - 1 chr1 98 108 2.2 20 + 0
chr1 105 110 q2.2 20 - 2 chr1 95 110 3.8 20 - 0
chr1 105 110 q2.2 20 - 1 chr1 98 108 2.2 20 + 0
chr1 105 110 q2.2 20 - 1 chr1 105 115 2.3 20 + 0
chr1 105 110 q2.2 20 - 2 chr1 90 105 3.7 20 + -1
chr1 105 110 q2.2 20 - 1 chr1 95 105 2.1 20 + -1
chr1 105 110 q2.2 20 - 2 chr1 110 115 3.9 20 + 1
......@@ -500,7 +501,7 @@ rm obs exp
echo " kclosest.t31...\c"
echo \
"chr1 100 110 q2.1 20 + 1 chr1 95 105 2.1 20 + 0
"chr1 100 110 q2.1 20 + 2 chr1 90 105 3.7 20 + 0
chr1 100 110 q2.1 20 + 2 chr1 110 115 3.9 20 + 1
chr1 100 110 q2.1 20 + 1 chr1 120 130 2.4 20 + 11
chr1 100 110 q2.1 20 + 2 chr1 70 80 3.6 20 + -21
......@@ -509,8 +510,8 @@ chr1 100 110 q2.1 20 + 1 chr1 140 160 2.5 20 + 31
chr1 100 110 q2.1 20 + 2 chr1 45 60 3.3 20 - -41
chr1 100 110 q2.1 20 + 2 chr1 30 40 3.2 20 + -61
chr1 100 110 q2.1 20 + 2 chr1 10 20 3.1 20 - -81
chr1 105 110 q2.2 20 - 1 chr1 98 108 2.2 20 + 0
chr1 105 110 q2.2 20 - 1 chr1 95 105 2.1 20 + -1
chr1 105 110 q2.2 20 - 2 chr1 95 110 3.8 20 - 0
chr1 105 110 q2.2 20 - 2 chr1 90 105 3.7 20 + -1
chr1 105 110 q2.2 20 - 1 chr1 120 130 2.4 20 + 11
chr1 105 110 q2.2 20 - 2 chr1 130 140 3.11 20 + 21
chr1 105 110 q2.2 20 - 2 chr1 70 80 3.6 20 + -26
......@@ -526,7 +527,7 @@ rm obs exp
echo " kclosest.t32...\c"
echo \
"chr1 100 110 q2.1 20 + 2 chr1 95 110 3.8 20 - 0
"chr1 100 110 q2.1 20 + 1 chr1 105 115 2.3 20 + 0
chr1 100 110 q2.1 20 + 2 chr1 110 115 3.9 20 + 1
chr1 100 110 q2.1 20 + 2 chr1 120 130 3.10 20 - 11
chr1 100 110 q2.1 20 + 2 chr1 130 140 3.11 20 + 21
......@@ -535,7 +536,7 @@ chr1 100 110 q2.1 20 + 1 chr1 140 150 2.7 20 + 31
chr1 100 110 q2.1 20 + 2 chr1 150 155 3.14 20 - 41
chr1 100 110 q2.1 20 + 2 chr1 170 180 3.15 20 + 61
chr1 100 110 q2.1 20 + 2 chr1 190 200 3.16 20 - 81
chr1 105 110 q2.2 20 - 2 chr1 95 110 3.8 20 - 0
chr1 105 110 q2.2 20 - 1 chr1 105 115 2.3 20 + 0
chr1 105 110 q2.2 20 - 2 chr1 110 115 3.9 20 + 1
chr1 105 110 q2.2 20 - 2 chr1 120 130 3.10 20 - 11
chr1 105 110 q2.2 20 - 2 chr1 130 140 3.11 20 + 21
......@@ -648,3 +649,6 @@ chr1 105 110 q2.2 20 - chr1 30 40 3.2 20 + 66" > exp
$BT closest -a q2.bed -b d3.bed -k 5 -D b -t first -fd > obs
check obs exp
rm obs exp
......@@ -502,8 +502,8 @@ $BT intersect -a a.bed -b b.bed -f 1.00001 2>&1 > /dev/null | cat - | head -2 |
check exp obs
rm exp obs
##################################################################bug167_strandSweep.bed
# Test that -s works with chromsweep
##################################################################
# bug167_strandSweep.bed
##################################################################
echo " intersect.t41...\c"
echo \
......@@ -512,8 +512,8 @@ $BT intersect -a bug167_strandSweep.bed -b bug167_strandSweep.bed -sorted -s -wa
check exp obs
rm exp obs
##################################################################bug167_strandSweep.bed
# Test that -S works with chromsweep
##################################################################
# bug167_strandSweep.bed
##################################################################
echo " intersect.t42...\c"
echo \
......@@ -525,6 +525,19 @@ rm exp obs
rm one_block.bam two_blocks.bam three_blocks.bam
##################################################################
# Bug 187 0 length records
##################################################################
echo " intersect.t43...\c"
echo \
"chr7 33059403 33059403 chr7 33059336 33060883 NT5C3A intron 0
chr7 33059403 33059403 chr7 32599076 33069221 NAq intron 0" > exp
$BT intersect -a bug187_a.bed -b bug187_b.bed -wao > obs
check exp obs
rm exp obs
cd multi_intersect
bash test-multi_intersect.sh
cd ..
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment