From 1cc5e7443578e9f31cf055bffc81000d74da1be9 Mon Sep 17 00:00:00 2001 From: depristo Date: Thu, 30 Apr 2009 22:12:07 +0000 Subject: [PATCH] More ways to access quality utils git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@573 348d0f76-0448-11de-a6fe-93d51630548a --- .../sting/utils/QualityUtils.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/java/src/org/broadinstitute/sting/utils/QualityUtils.java b/java/src/org/broadinstitute/sting/utils/QualityUtils.java index 3cf445cab..f8f283bbd 100755 --- a/java/src/org/broadinstitute/sting/utils/QualityUtils.java +++ b/java/src/org/broadinstitute/sting/utils/QualityUtils.java @@ -30,7 +30,22 @@ public class QualityUtils { * @return a quality score (0-40) */ static public byte probToQual(double prob) { - return (byte) Math.round(-10.0*Math.log10(1.0 - prob + 0.0001)); + return probToQual(prob, 0.0001); + //return (byte) Math.round(-10.0*Math.log10(1.0 - prob + 0.0001)); + } + + /** + * Convert a probability to a quality score. Note, this is capped at Q40. + * + * @param prob a probability (0.0-1.0) + * @param eps min probabilty allowed (0.0-1.0) + * @return a quality score (0-255) + */ + static public byte probToQual(double prob, double eps) { + double lp = Math.round(-10.0*Math.log10(1.0 - prob + eps)); + byte b = (byte) Math.min(lp, 63); + //System.out.printf("LP is %f, byte is %d%n", lp, b); + return b; } /**