From 6dc1275cfbf95a9740b30bc65ffce7ea0884a071 Mon Sep 17 00:00:00 2001 From: asivache Date: Fri, 16 Apr 2010 00:15:57 +0000 Subject: [PATCH] Utility method added: getQualsInCycleOrder(read) - examines the read and returns its quals in the order the machine read them (i.e. always from cycle 1 to cycle N). Simply inverts quals if the read happens to be rc-aligned :) git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@3183 348d0f76-0448-11de-a6fe-93d51630548a --- .../broadinstitute/sting/utils/AlignmentUtils.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/java/src/org/broadinstitute/sting/utils/AlignmentUtils.java b/java/src/org/broadinstitute/sting/utils/AlignmentUtils.java index 1944e3ce0..4475daf25 100644 --- a/java/src/org/broadinstitute/sting/utils/AlignmentUtils.java +++ b/java/src/org/broadinstitute/sting/utils/AlignmentUtils.java @@ -339,4 +339,17 @@ public class AlignmentUtils { && r.getAlignmentStart() != SAMRecord.NO_ALIGNMENT_START ) return false ; return true; } + + /** Returns the array of base qualitites 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). + * @param read + * @return + */ + public static byte [] getQualsInCycleOrder(SAMRecord read) { + if ( isReadUnmapped(read) || ! read.getReadNegativeStrandFlag() ) return read.getBaseQualities(); + + return BaseUtils.reverse(read.getBaseQualities()); + } }