Skip to content
Browse files

Protect against features that start off the end of the read (otherwis…

…e, Arrays.fill fails)
  • Loading branch information...
1 parent 99996f2 commit 74c9db9e97f28c8e31be58483d4da9acaa5dee72 @eitanbanks eitanbanks committed
Showing with 13 additions and 4 deletions.
  1. +13 −4 public/java/src/org/broadinstitute/sting/gatk/walkers/bqsr/BaseRecalibrator.java
View
17 public/java/src/org/broadinstitute/sting/gatk/walkers/bqsr/BaseRecalibrator.java
@@ -268,16 +268,25 @@ protected boolean badSolidOffset( final GATKSAMRecord read, final int offset ) {
}
protected boolean[] calculateKnownSites( final GATKSAMRecord read, final List<Feature> features ) {
- final int BUFFER_SIZE = 0;
final int readLength = read.getReadBases().length;
final boolean[] knownSites = new boolean[readLength];
Arrays.fill(knownSites, false);
for( final Feature f : features ) {
int featureStartOnRead = ReadUtils.getReadCoordinateForReferenceCoordinate(read.getSoftStart(), read.getCigar(), f.getStart(), ReadUtils.ClippingTail.LEFT_TAIL, true); // BUGBUG: should I use LEFT_TAIL here?
- if( featureStartOnRead == ReadUtils.CLIPPING_GOAL_NOT_REACHED ) { featureStartOnRead = 0; }
+ if( featureStartOnRead == ReadUtils.CLIPPING_GOAL_NOT_REACHED ) {
+ featureStartOnRead = 0;
+ }
+
int featureEndOnRead = ReadUtils.getReadCoordinateForReferenceCoordinate(read.getSoftStart(), read.getCigar(), f.getEnd(), ReadUtils.ClippingTail.LEFT_TAIL, true);
- if( featureEndOnRead == ReadUtils.CLIPPING_GOAL_NOT_REACHED ) { featureEndOnRead = readLength; }
- Arrays.fill(knownSites, Math.max(0, featureStartOnRead - BUFFER_SIZE), Math.min(readLength, featureEndOnRead + 1 + BUFFER_SIZE), true);
+ if( featureEndOnRead == ReadUtils.CLIPPING_GOAL_NOT_REACHED ) {
+ featureEndOnRead = readLength;
+ }
+
+ if( featureStartOnRead > readLength ) {
+ featureStartOnRead = featureEndOnRead = readLength;
+ }
+
+ Arrays.fill(knownSites, Math.max(0, featureStartOnRead), Math.min(readLength, featureEndOnRead + 1), true);
}
return knownSites;
}

0 comments on commit 74c9db9

Please sign in to comment.
Something went wrong with that request. Please try again.