-
Notifications
You must be signed in to change notification settings - Fork 594
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
Validate SVCallRecord coordinates #7714
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,8 +49,13 @@ public boolean areClusterable(final SVCallRecord a, final SVCallRecord b) { | |
if (a.getType() != b.getType()) return false; | ||
|
||
// Interval overlap | ||
if (!getPaddedRecordInterval(a.getContigA(), a.getPositionA(), a.getPositionB()) | ||
.overlaps(getPaddedRecordInterval(b.getContigA(), b.getPositionA(), b.getPositionB()))) return false; | ||
final SimpleInterval intervalA = getPaddedRecordInterval(a.getContigA(), a.getPositionA(), a.getPositionB()); | ||
Utils.nonNull(intervalA, "Invalid interval " + new SimpleInterval(a.getContigA(), a.getPositionA(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes you're right I added checks for valid coordinates so this wouldn't happen, and this is here simply for safety. I've added a comment about it. |
||
a.getPositionB()) + " for record " + a.getId()); | ||
final SimpleInterval intervalB = getPaddedRecordInterval(b.getContigA(), b.getPositionA(), b.getPositionB()); | ||
Utils.nonNull(intervalB, "Invalid interval " + new SimpleInterval(b.getContigA(), b.getPositionA(), | ||
b.getPositionB()) + " for record " + b.getId()); | ||
if (!intervalA.overlaps(intervalB)) return false; | ||
|
||
// Sample overlap | ||
if (!hasSampleOverlap(a, b, minSampleOverlap)) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,4 +55,24 @@ public Object[][] testIsCNVData() { | |
public void testIsCNV(final SVCallRecord record, final boolean expected) { | ||
Assert.assertEquals(record.isSimpleCNV(), expected); | ||
} | ||
|
||
@DataProvider(name = "testCreateInvalidCoordinatesData") | ||
public Object[][] testCreateInvalidCoordinatesData() { | ||
return new Object[][]{ | ||
{"chr1", 0, "chr1", 248956422}, | ||
{"chr1", 1, "chr1", 248956423}, | ||
{"chr1", 1, "chr1", 248956423}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I mentioned above maybe add a case where start == end? (I guess you'd have to change this test to handle positive examples as well..) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
{"chr1", 1, "chr2", 242193530}, | ||
{"chr1", 2, "chr1", 1}, | ||
{"chr2", 1, "chr1", 2} | ||
}; | ||
} | ||
|
||
@Test(dataProvider="testCreateInvalidCoordinatesData", expectedExceptions = { IllegalArgumentException.class }) | ||
public void testCreateInvalidCoordinates(final String contigA, final int posA, final String contigB, final int posB) { | ||
new SVCallRecord("var1", contigA, posA, true, contigB, posB, false, StructuralVariantType.BND, | ||
null, SVTestUtils.PESR_ONLY_ALGORITHM_LIST, Collections.emptyList(), Collections.emptyList(), | ||
Collections.emptyMap(), SVTestUtils.hg38Dict); | ||
Assert.fail("Expected exception not thrown"); | ||
} | ||
} |
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 forget -- do we do start == end for insertions in SVCallRecords? Just checking whether this needs to be
<=
or not. If we do, you might want to add a quick unit test condition to your new test inSVCallRecordUnitTest
where start == end with a comment.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.
Yes start==end should be correct. I've added a test with some valid coordinates to make sure they pass.