From 3308d956f4d59ec8716da2f712f13e7c52e286a2 Mon Sep 17 00:00:00 2001 From: asivache Date: Thu, 22 Jul 2010 15:44:25 +0000 Subject: [PATCH] Added utility shortcut method: getOriginalQualsInCycleOrder(read) git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@3851 348d0f76-0448-11de-a6fe-93d51630548a --- .../sting/utils/sam/AlignmentUtils.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/java/src/org/broadinstitute/sting/utils/sam/AlignmentUtils.java b/java/src/org/broadinstitute/sting/utils/sam/AlignmentUtils.java index 50c1a68f2..3bd3b5350 100644 --- a/java/src/org/broadinstitute/sting/utils/sam/AlignmentUtils.java +++ b/java/src/org/broadinstitute/sting/utils/sam/AlignmentUtils.java @@ -350,6 +350,20 @@ public class AlignmentUtils { return Utils.reverse(read.getBaseQualities()); } + /** Returns the array of original base qualitites (before recalibration) in the order the bases were read on the machine (i.e. always starting from + * cycle 1). In other words, if the read is unmapped or aligned in the forward direction, the read's own base + * qualities are returned as stored in the SAM record; if the read is aligned in the reverse direction, the array + * of read's base qualitites is inverted (in this case new array is allocated and returned). If no original base qualities + * are available this method will throw a runtime exception. + * @param read + * @return + */ + public static byte [] getOriginalQualsInCycleOrder(SAMRecord read) { + if ( isReadUnmapped(read) || ! read.getReadNegativeStrandFlag() ) return read.getOriginalBaseQualities(); + + return Utils.reverse(read.getOriginalBaseQualities()); + } + /** Takes the alignment of the read sequence readSeq to the reference sequence refSeq * starting at 0-based position refIndex on the refSeq and specified by its cigar. * The last argument readIndex specifies 0-based position on the read where the alignment described by the