From a9671b73ca0fc50d7c2722727e90d731d38037aa Mon Sep 17 00:00:00 2001 From: Menachem Fromer Date: Fri, 27 Jan 2012 16:01:30 -0500 Subject: [PATCH] Fix to permit proper handling of mapping qualities between 128 to 255 (which get converted to byte values of -128 to -1) --- .../org/broadinstitute/sting/utils/QualityUtils.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/public/java/src/org/broadinstitute/sting/utils/QualityUtils.java b/public/java/src/org/broadinstitute/sting/utils/QualityUtils.java index 19e03a19d..7ec6a74d7 100755 --- a/public/java/src/org/broadinstitute/sting/utils/QualityUtils.java +++ b/public/java/src/org/broadinstitute/sting/utils/QualityUtils.java @@ -17,7 +17,7 @@ public class QualityUtils { private static double qualToErrorProbCache[] = new double[256]; static { - for (int i = 0; i < 256; i++) qualToErrorProbCache[i] = qualToErrorProbRaw((byte)i); + for (int i = 0; i < 256; i++) qualToErrorProbCache[i] = qualToErrorProbRaw(i); } /** @@ -44,15 +44,15 @@ public class QualityUtils { * Convert a quality score to a probability of error. This is the Phred-style * conversion, *not* the Illumina-style conversion (though asymptotically, they're the same). * - * @param qual a quality score (0-40) - * @return a probability (0.0-1.0) + * @param qual a quality score (0 - 255) + * @return a probability (0.0 - 1.0) */ - static public double qualToErrorProbRaw(byte qual) { + static private double qualToErrorProbRaw(int qual) { return Math.pow(10.0, ((double) qual)/-10.0); } static public double qualToErrorProb(byte qual) { - return qualToErrorProbCache[qual]; + return qualToErrorProbCache[(int)qual & 0xff]; // Map: 127 -> 127; -128 -> 128; -1 -> 255; etc. } /**