From 88a02fa2cb927923519fd354b821ee4cd0fe7913 Mon Sep 17 00:00:00 2001 From: Mauricio Carneiro Date: Mon, 2 Jul 2012 12:28:28 -0400 Subject: [PATCH] Fixing but for reads with cigars like 9S54H When hard-clipping predict when the read is going to be fully hard clipped to the point where only soft/hard-clips are left in the read and preemptively eliminate the read before the SAMRecord mathematics on malformed cigars kills the GATK. --- .../org/broadinstitute/sting/utils/clipping/ClippingOp.java | 5 ++++- .../src/org/broadinstitute/sting/utils/sam/ReadUtils.java | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/public/java/src/org/broadinstitute/sting/utils/clipping/ClippingOp.java b/public/java/src/org/broadinstitute/sting/utils/clipping/ClippingOp.java index 2e3978ddb..d12d2c2ec 100644 --- a/public/java/src/org/broadinstitute/sting/utils/clipping/ClippingOp.java +++ b/public/java/src/org/broadinstitute/sting/utils/clipping/ClippingOp.java @@ -285,7 +285,10 @@ public class ClippingOp { @Requires({"start <= stop", "start == 0 || stop == read.getReadLength() - 1"}) private GATKSAMRecord hardClip(GATKSAMRecord read, int start, int stop) { - if (start == 0 && stop == read.getReadLength() - 1) + final int firstBaseAfterSoftClips = read.getAlignmentStart() - read.getSoftStart(); + final int lastBaseBeforeSoftClips = read.getSoftEnd() - read.getSoftStart(); + + if (start == firstBaseAfterSoftClips && stop == lastBaseBeforeSoftClips) // note that if the read has no soft clips, these constants will be 0 and read length - 1 (beauty of math). return GATKSAMRecord.emptyRead(read); diff --git a/public/java/src/org/broadinstitute/sting/utils/sam/ReadUtils.java b/public/java/src/org/broadinstitute/sting/utils/sam/ReadUtils.java index 78ce81a7c..6b9ba79b4 100755 --- a/public/java/src/org/broadinstitute/sting/utils/sam/ReadUtils.java +++ b/public/java/src/org/broadinstitute/sting/utils/sam/ReadUtils.java @@ -520,7 +520,7 @@ public class ReadUtils { if (allowGoalNotReached) { return new Pair(CLIPPING_GOAL_NOT_REACHED, false); } else { - throw new ReviewedStingException("Somehow the requested coordinate is not covered by the read. Too many deletions?"); + throw new ReviewedStingException("Somehow the requested coordinate is not covered by the read. Alignment " + alignmentStart + " | " + cigar); } }