Skip to content

Commit

Permalink
Added defensive check to OverhangFixingManager splices for non-refere…
Browse files Browse the repository at this point in the history
…cnce spanning reads (#5298)
  • Loading branch information
jamesemery authored Oct 11, 2018
1 parent ce669d1 commit 73a1b67
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,11 @@ public SplitRead(final GATKRead read) {

public void setRead(final GATKRead read) {
this.read = read;
if ( ! read.isUnmapped() ) {
unclippedLoc = genomeLocParser.createGenomeLoc(read.getContig(), read.getSoftStart(), read.getSoftEnd());
int softStart = read.getSoftStart();
int softEnd = read.getSoftEnd();
// Don't assign an unclipped loc if the read if it doesn't consume reference bases
if ( ! read.isUnmapped() && softStart < softEnd) {
unclippedLoc = genomeLocParser.createGenomeLoc(read.getContig(), softStart, softEnd);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,4 +285,19 @@ public void testReadWithDeletionsWindowSpanning() {
// Assert that no splitting happened (and no array exception) by asserting a copy of the read was not placed in split.read
Assert.assertTrue(split.read==read);
}

@Test
public void testReadWithOnlyInsertionInsideSpan() {
final OverhangFixingManager manager = new OverhangFixingManager(getHG19Header(), null, hg19GenomeLocParser, hg19ReferenceReader, 100, 100, 30, false, true);
// Create a splice that is going to overlap into the deletion of our read, forcing us to check for mismatches to the reference
OverhangFixingManager.Splice splice = manager.addSplicePosition("1",6816, 11247);
// Create a read that is entirely an insertion inside of the splice to demonstrate it is handled without creating an invalid loc
GATKRead read = ArtificialReadUtils.createArtificialRead(hg19Header, "read1", 0, 11244, new byte[100], new byte[100], "100I");
OverhangFixingManager.SplitRead split = manager.getSplitRead(read);
manager.fixSplit(split,splice);
// Assert that no splitting happened (and no array exception) by asserting a copy of the read was not placed in split.read
Assert.assertTrue(split.read==read);
}


}

0 comments on commit 73a1b67

Please sign in to comment.