From 0cd9438ac2225eea9dc629e49bf79d538b88a837 Mon Sep 17 00:00:00 2001 From: Mauricio Carneiro Date: Tue, 30 Aug 2011 02:31:00 -0400 Subject: [PATCH] fixed soft unclipped calculation * getRefCoordSoftUnclippedEnd was not resetting the shift when hitting insertions. Fixed. * getReadCoordinateForReferenceCoordinateBeforeAlignmentEnd was returning the wrong read coordinate position. Fixed. --- .../src/org/broadinstitute/sting/utils/sam/ReadUtils.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 7d02c8d3b..62bbb0307 100644 --- a/public/java/src/org/broadinstitute/sting/utils/sam/ReadUtils.java +++ b/public/java/src/org/broadinstitute/sting/utils/sam/ReadUtils.java @@ -680,6 +680,8 @@ public class ReadUtils { lastOperator = cigarElement.getOperator(); if (cigarElement.getOperator().consumesReferenceBases() || cigarElement.getOperator() == CigarOperator.SOFT_CLIP || cigarElement.getOperator() == CigarOperator.HARD_CLIP) shift = cigarElement.getLength(); + else + shift = 0; } return (lastOperator == CigarOperator.HARD_CLIP) ? stop-1 : stop+shift-1 ; } @@ -710,8 +712,8 @@ public class ReadUtils { */ @Requires({"refCoord <= read.getUnclippedEnd()", "refCoord > read.getAlignmentEnd()"}) private static int getReadCoordinateForReferenceCoordinateBeforeAlignmentEnd(SAMRecord read, int refCoord) { - if (getRefCoordSoftUnclippedEnd(read) > refCoord) - return refCoord - read.getAlignmentEnd() + 1; + if (getRefCoordSoftUnclippedEnd(read) >= refCoord) + return refCoord - getRefCoordSoftUnclippedStart(read) + 1; return -1; }