-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing zero-length interval bug in IntervalList.merge #1318
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add tests around zero-length intervals.
*/ | ||
static Interval merge(final Iterable<Interval> intervals, final boolean concatenateNames) { | ||
final Interval first = intervals.iterator().next(); | ||
final String chrom = first.getContig(); | ||
int start = first.getStart(); | ||
int end = start; | ||
int end = first.getEnd(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what should happen when we merge a zero-length interval with a non-zerolength one after it?
so,
10-9 merged with 11-15 should remain those two intervals
10-9 merged with 10-15 should become one interval 10-15
10-9 merged with 9-15 should become one interval 9-15
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first case, you mean it should become 10-15? Merge never leaves them separate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no...I think that it should not become 10-15....since the size of the first interval is 0 it shouldn't change the total number of bases covered...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that zero length intervals need to either be dropped when merging, or ignored...normal rules of merging do not apply.
*/ | ||
static Interval merge(final Iterable<Interval> intervals, final boolean concatenateNames) { | ||
final Interval first = intervals.iterator().next(); | ||
final String chrom = first.getContig(); | ||
int start = first.getStart(); | ||
int end = start; | ||
int end = first.getEnd(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice catch. sorry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I definitely didn't notice it in review. It makes sense, you can't have an end before start..
Codecov Report
@@ Coverage Diff @@
## master #1318 +/- ##
===========================================
Coverage 67.635% 67.635%
Complexity 8230 8230
===========================================
Files 562 562
Lines 33617 33617
Branches 5642 5642
===========================================
Hits 22737 22737
Misses 8706 8706
Partials 2174 2174
|
8b83dd9
to
198a2e1
Compare
I added some more test cases to cover the cases you mentioned |
@yfarjoun I added the tests I think you wanted. Is there anything else? |
{Arrays.asList(zeroLengthInterval, interval600To601), true, interval600To625}, | ||
{Arrays.asList(interval600To601, new Interval(contig, 100, 200, false, "hasName")), true, new Interval(contig, 100, 601, false, "hasName")}, | ||
{Arrays.asList(interval600To601, new Interval(contig, 100, 200, false, "hasName")), false, new Interval(contig, 100, 601, false, "hasName")}, | ||
{Arrays.asList(zeroInterval10To9, new Interval(contig, 11, 15)), false, new Interval(contig, 10, 15)}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that this is right. adding a zero-length interval shouldn't add bases to another interval.
* Fixing a bug in IntervalList.merge() that caused it to break when merging 0 length intervals * Improving tests for merge * The bug was introduced in #1265
198a2e1
to
8cca313
Compare
Responded to comments as well as I can here, punting the rest to a new pr
👍 |
Checklist