From 0d976d621162af883f282165651b59efb7335940 Mon Sep 17 00:00:00 2001 From: Mauricio Carneiro Date: Mon, 15 Aug 2011 12:04:53 -0400 Subject: [PATCH] Fixed second time clipping When a read is clipped once, and then in the second operation, because of indels, it doesn't reach the coordinate initially set for hard clipping, the indices were wrong. This should fix it. --- .../broadinstitute/sting/utils/clipreads/ReadClipper.java | 2 +- .../src/org/broadinstitute/sting/utils/sam/ReadUtils.java | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/public/java/src/org/broadinstitute/sting/utils/clipreads/ReadClipper.java b/public/java/src/org/broadinstitute/sting/utils/clipreads/ReadClipper.java index 00405a98c..85063ad14 100644 --- a/public/java/src/org/broadinstitute/sting/utils/clipreads/ReadClipper.java +++ b/public/java/src/org/broadinstitute/sting/utils/clipreads/ReadClipper.java @@ -50,7 +50,7 @@ public class ReadClipper { public SAMRecord hardClipByReferenceCoordinates(int refStart, int refStop) { int start = (refStart < 0) ? 0 : ReadUtils.getReadCoordinateForReferenceCoordinate(read, refStart); - int stop = (refStop < 0) ? read.getReadLength()-1 : ReadUtils.getReadCoordinateForReferenceCoordinate(read, refStop); + int stop = (refStop < 0) ? read.getReadLength() - 1 : ReadUtils.getReadCoordinateForReferenceCoordinate(read, refStop); System.out.println("DEBUG -- clipping start/stop: " + start + "/" + stop); this.addOp(new ClippingOp(start, stop)); 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 5d39a01a5..ef89a8820 100644 --- a/public/java/src/org/broadinstitute/sting/utils/sam/ReadUtils.java +++ b/public/java/src/org/broadinstitute/sting/utils/sam/ReadUtils.java @@ -655,16 +655,16 @@ public class ReadUtils { public static int getReadCoordinateForReferenceCoordinate(SAMRecord read, int refCoord) { int readBases = 0; int refBases = 0; - int goal = refCoord - read.getAlignmentStart(); // read coords are 0-based! + int goal = refCoord - read.getAlignmentStart(); // The goal is to move this many reference bases boolean goalReached = refBases == goal; Iterator cigarElementIterator = read.getCigar().getCigarElements().iterator(); while (!goalReached && cigarElementIterator.hasNext()) { CigarElement cigarElement = cigarElementIterator.next(); int shift = 0; - if (refBases == 0 && readBases == 0 && cigarElement.getOperator() == CigarOperator.HARD_CLIP) { - goal -= cigarElement.getLength(); - } + //if (refBases == 0 && readBases == 0 && cigarElement.getOperator() == CigarOperator.HARD_CLIP) { + // goal -= cigarElement.getLength(); + //} if (cigarElement.getOperator().consumesReferenceBases()) { if (refBases + cigarElement.getLength() < goal) {