Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
R3
legacy
bedtools2
Commits
0ea1769d
Commit
0ea1769d
authored
Nov 09, 2014
by
Neil Kindlon
Browse files
Fixed bug133, missing intersection of zero length records
parent
5ba347e1
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/utils/Contexts/ContextBase.cpp
View file @
0ea1769d
...
...
@@ -32,7 +32,7 @@ ContextBase::ContextBase()
_writeOverlap
(
false
),
_writeAllOverlap
(
false
),
_haveFraction
(
false
),
_overlapFraction
(
1E-9
),
_overlapFraction
(
0.0
),
_reciprocal
(
false
),
_sameStrand
(
false
),
_diffStrand
(
false
),
...
...
src/utils/FileRecordTools/Records/Record.cpp
View file @
0ea1769d
...
...
@@ -160,15 +160,27 @@ bool Record::sameChromIntersects(const Record *record,
int
otherStart
=
record
->
getStartPos
();
int
otherEnd
=
record
->
getEndPos
();
bool
otherZeroLen
=
(
otherStart
-
otherEnd
==
0
);
int
maxStart
=
max
(
_startPos
,
otherStart
);
int
minEnd
=
min
(
_endPos
,
otherEnd
);
bool
localZeroLen
=
(
_endPos
-
_startPos
==
0
);
//rule out all cases of no intersection at all
if
(
minEnd
<
maxStart
)
{
return
false
;
}
if
(
overlapFraction
==
0.0
)
{
//don't care about amount of overlap.
//however, if minEnd and maxStart are equal, and
//neither record is zeroLen, return false.
if
(
minEnd
==
maxStart
&&
!
otherZeroLen
&&
!
localZeroLen
)
{
return
false
;
}
return
true
;
}
int
overlapBases
=
minEnd
-
maxStart
;
int
len
=
_endPos
-
_startPos
;
int
otherLen
=
otherEnd
-
otherStart
;
...
...
src/utils/RecordOutputMgr/RecordOutputMgr.cpp
View file @
0ea1769d
...
...
@@ -210,6 +210,7 @@ void RecordOutputMgr::printRecord(RecordKeyVector &keyList, RecordKeyVector *blo
if
((
static_cast
<
ContextIntersect
*>
(
_context
))
->
getWriteAllOverlap
())
{
// -wao the user wants to force the reporting of 0 overlap
if
(
printKeyAndTerminate
(
keyList
))
{
_currBamBlockList
=
NULL
;
return
;
}
...
...
@@ -223,6 +224,7 @@ void RecordOutputMgr::printRecord(RecordKeyVector &keyList, RecordKeyVector *blo
else
if
((
static_cast
<
ContextIntersect
*>
(
_context
))
->
getLeftJoin
())
{
if
(
printKeyAndTerminate
(
keyList
))
{
_currBamBlockList
=
NULL
;
return
;
}
tab
();
...
...
@@ -230,11 +232,13 @@ void RecordOutputMgr::printRecord(RecordKeyVector &keyList, RecordKeyVector *blo
newline
();
if
(
needsFlush
())
flush
();
_currBamBlockList
=
NULL
;
return
;
}
}
else
{
if
(
printBamRecord
(
keyList
,
true
)
==
BAM_AS_BAM
)
{
_currBamBlockList
=
NULL
;
return
;
}
int
hitIdx
=
0
;
...
...
@@ -252,14 +256,17 @@ void RecordOutputMgr::printRecord(RecordKeyVector &keyList, RecordKeyVector *blo
newline
();
}
_currBamBlockList
=
NULL
;
return
;
}
else
if
(
_context
->
getProgram
()
==
ContextBase
::
MAP
)
{
printKeyAndTerminate
(
keyList
);
_currBamBlockList
=
NULL
;
return
;
}
else
if
(
_context
->
getProgram
()
==
ContextBase
::
MERGE
)
{
printKeyAndTerminate
(
keyList
);
_currBamBlockList
=
NULL
;
return
;
}
}
...
...
@@ -380,6 +387,7 @@ void RecordOutputMgr::reportOverlapDetail(const Record *keyRecord, const Record
newline
();
if
(
needsFlush
())
flush
();
}
const_cast
<
Record
*>
(
keyRecord
)
->
adjustZeroLength
();
}
void
RecordOutputMgr
::
reportOverlapSummary
(
RecordKeyVector
&
keyList
)
...
...
test/intersect/a_testZeroLen.bed
0 → 100644
View file @
0ea1769d
chr1 5 15 r1
chr1 7 12 r3
chr1 20 25 r2
test/intersect/b_testZeroLen.bed
0 → 100644
View file @
0ea1769d
chr1 9 9 m3
chr1 50 150 m1
chr2 20 25 m2
test/intersect/new_test-intersect.sh
View file @
0ea1769d
...
...
@@ -764,3 +764,24 @@ $BT intersect -a oneRecordNoNewline.bed -b oneRecordNoNewline.bed > obs
check obs exp
rm
obs exp
###########################################################
# Test zero length intersections in non-bam files.
############################################################
echo
" intersect.new.t65...
\c
"
echo
\
"chr1 5 15 r1 chr1 9 9 m3 0
chr1 7 12 r3 chr1 9 9 m3 0"
>
exp
$BT
intersect
-a
a_testZeroLen.bed
-b
b_testZeroLen.bed
-wo
>
obs
check exp obs
rm
exp obs
###########################################################
# Test zero length intersections in non-bam files, -sorted
############################################################
echo
" intersect.new.t66...
\c
"
echo
\
"chr1 5 15 r1 chr1 9 9 m3 0
chr1 7 12 r3 chr1 9 9 m3 0"
>
exp
$BT
intersect
-a
a_testZeroLen.bed
-b
b_testZeroLen.bed
-wo
-sorted
>
obs
check exp obs
rm
exp obs
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment