From 9bfa5eb70fb3a7911583e883706841bdd0052c14 Mon Sep 17 00:00:00 2001 From: Mauricio Carneiro Date: Sun, 14 Apr 2013 23:25:33 -0400 Subject: [PATCH] Quick optimization to the PairHMM Problem -------- the logless HMM scale factor (to avoid double under-flows) was 10^300. Although this serves the purpose this value results in a complex mantissa that further complicates cpu calculations. Solution --------- initialize with 2^1020 (2^1023 is the max value), and adjust the scale factor accordingly. --- .../broadinstitute/sting/utils/pairhmm/LoglessPairHMM.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/protected/java/src/org/broadinstitute/sting/utils/pairhmm/LoglessPairHMM.java b/protected/java/src/org/broadinstitute/sting/utils/pairhmm/LoglessPairHMM.java index b62d7a334..ab2a5bb2a 100644 --- a/protected/java/src/org/broadinstitute/sting/utils/pairhmm/LoglessPairHMM.java +++ b/protected/java/src/org/broadinstitute/sting/utils/pairhmm/LoglessPairHMM.java @@ -56,8 +56,8 @@ import org.broadinstitute.sting.utils.QualityUtils; * Date: 10/16/12 */ public final class LoglessPairHMM extends PairHMM { - protected static final double SCALE_FACTOR_LOG10 = 300.0; - protected static final double INITIAL_CONDITION = Math.pow(10, SCALE_FACTOR_LOG10); + protected static final double INITIAL_CONDITION = Math.pow(2, 1020); + protected static final double INITIAL_CONDITION_LOG10 = Math.log10(INITIAL_CONDITION); private static final int matchToMatch = 0; private static final int indelToMatch = 1; @@ -118,7 +118,7 @@ public final class LoglessPairHMM extends PairHMM { for (int j = 1; j < paddedHaplotypeLength; j++) { finalSumProbabilities += matchMatrix[endI][j] + insertionMatrix[endI][j]; } - return Math.log10(finalSumProbabilities) - SCALE_FACTOR_LOG10; + return Math.log10(finalSumProbabilities) - INITIAL_CONDITION_LOG10; } /**