private double[] oneDprob(final EvidenceInterface evidence) { final Code code = mSubHypotheses.code(); final double[] probs = new double[mSubHypotheses.size()]; for (int i = 0; i < probs.length; i++) { final double a = Math.max(0, evidence.probability(code.a(i))); final double b = Math.max(0, evidence.probability(code.bc(i))); probs[i] = 0.5 * (a + b); } // System.err.println(probs.length + " :" + Arrays.toString(probs)); return probs; }
@Override public void increment(final EvidenceInterface evidence) { // System.err.println(evidence); incrementStatistics(evidence); if (ambiguityShortCircuit(evidence)) { return; } final double r = evidence.mapError(); final double rc = 1.0 - r; // Avoid case where mapq is 0 which gives a NaN if (rc <= 0.0) { return; } final double[] probs = oneDprob(evidence); final double pE = evidence.pe(); final double pEr = r * pE; final Code code = hypotheses().code(); for (int i = 0; i < size(); i++) { final int a = code.a(i); final int b = code.bc(i); // The cross-product is normal x cancer final double prob = probs[a] * mContamination + probs[b] * mContaminationM; // Phred scores of 0 can result in 0 probability, just skip them if (prob <= 0.0) { return; } // Adjust for mapQ - see theory in scoring.tex final double pr = prob * rc + pEr; final double np = arithmetic().multiply(mPosteriors[i], arithmetic().prob2Poss(pr)); assert arithmetic() .isValidPoss( np); // : System.err.println("np=" + np + " mPosteriors[i]=" + mPosteriors[i] + " i=" // + i + " pr=" + pr + " prob=" + prob + " rc=" + rc + " r=" + r + " pE=" + pE); mPosteriors[i] = np; } }