diff --git a/java/src/org/broadinstitute/sting/playground/gatk/walkers/ReadBackedPhasingWalker.java b/java/src/org/broadinstitute/sting/playground/gatk/walkers/ReadBackedPhasingWalker.java index a4f52853c..2a0f8c56e 100755 --- a/java/src/org/broadinstitute/sting/playground/gatk/walkers/ReadBackedPhasingWalker.java +++ b/java/src/org/broadinstitute/sting/playground/gatk/walkers/ReadBackedPhasingWalker.java @@ -282,15 +282,16 @@ public class ReadBackedPhasingWalker extends LocusWalker { private static double EQUALS_THRESH = 1e-6; private static double INFINITY = Double.POSITIVE_INFINITY; - private double logValue; + private double log10Value; public PreciseNonNegativeDouble(double d) { this(d, false); } - public PreciseNonNegativeDouble(double d, boolean isLog) { - if (isLog) { - this.logValue = d; + public PreciseNonNegativeDouble(double d, boolean isLog10) { + if (isLog10) { + this.log10Value = d; } else { if (d < 0) throw new IllegalArgumentException("non-log PreciseNonNegativeDouble argument must be non-negative"); - this.logValue = Math.log(d); + this.log10Value = Math.log10(d); } } public PreciseNonNegativeDouble(PreciseNonNegativeDouble pd) { - this.logValue = pd.logValue; + this.log10Value = pd.log10Value; } public double getValue() { - return Math.exp(logValue); + return Math.pow(10, log10Value); } - public double getLogValue() { - return logValue; + public double getLog10Value() { + return log10Value; } public PreciseNonNegativeDouble setEqual(PreciseNonNegativeDouble other) { - logValue = other.logValue; + log10Value = other.log10Value; return this; } @@ -62,12 +62,12 @@ public class PreciseNonNegativeDouble implements Comparable a R b, where R is one of: >, <, == - double logValDiff = this.logValue - other.logValue; + double logValDiff = this.log10Value - other.log10Value; if (Math.abs(logValDiff) <= EQUALS_THRESH) return 0; // this.equals(other) @@ -87,23 +87,23 @@ public class PreciseNonNegativeDouble implements Comparable= y) // x + log(1-e^(y-x)) = log(a) + log(1-e^(log(b)-log(a))) = log(a) + log(1-b/a) = a - b = |a-b|, since x >= y - return x + Math.log(1 - Math.exp(y-x)); + return x + Math.log10(1 - Math.pow(10, y-x)); else - return y + Math.log(1 - Math.exp(x-y)); + return y + Math.log10(1 - Math.pow(10, x-y)); } public String toString() { return new StringBuilder().append(getValue()).toString(); } -} +} \ No newline at end of file