Skip to content

Commit

Permalink
fixed out-of-bounds error in CountNs annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbenjamin committed Jan 7, 2020
1 parent 0c376e9 commit 0fbe11f
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,14 @@ public List<VCFInfoHeaderLine> getDescriptions() {
public List<String> getKeyNames() { return Arrays.asList(GATKVCFConstants.N_COUNT_KEY); }

private Boolean doesReadHaveN(final GATKRead read, final VariantContext vc) {
final int offset = ReadUtils.getReadCoordinateForReferenceCoordinate(read.getSoftStart(), read.getCigar(), vc.getStart(), ReadUtils.ClippingTail.RIGHT_TAIL, true);
return ( offset != ReadUtils.CLIPPING_GOAL_NOT_REACHED && !AlignmentUtils.isInsideDeletion(read.getCigar(), offset) && read.getBase(offset) == 'N');

if (vc.getStart() < read.getStart() || read.getEnd() < vc.getStart()) {
return false;
}

final int offset = ReadUtils.getReadCoordinateForReferenceCoordinateUpToEndOfRead(read, vc.getStart(), ReadUtils.ClippingTail.RIGHT_TAIL, true);

return !(offset == ReadUtils.CLIPPING_GOAL_NOT_REACHED || offset < 0 || offset >= read.getLength() || AlignmentUtils.isInsideDeletion(read.getCigar(), offset))
&& read.getBase(offset) == 'N';
}
}

0 comments on commit 0fbe11f

Please sign in to comment.