Пример #1
0
    float
    SimpleRecursor<M, E, C>::LinkAlphaBeta(const E& e,
                                           const M& alpha, int alphaColumn,
                                           const M& beta, int betaColumn,
                                           int absoluteColumn) const
    {
        const int I = e.ReadLength();

        assert(alphaColumn > 1 && absoluteColumn > 1);
        assert(absoluteColumn < e.TemplateLength());

        int usedBegin, usedEnd;
        boost::tie(usedBegin, usedEnd) = \
            RangeUnion(alpha.UsedRowRange(alphaColumn - 2),
                       alpha.UsedRowRange(alphaColumn - 1),
                       beta.UsedRowRange(betaColumn),
                       beta.UsedRowRange(betaColumn + 1));

        float v = NEG_INF, thisMoveScore;

        for (int i = usedBegin; i < usedEnd; i++)
        {
            if (i < I)
            {
                // Incorporate
                thisMoveScore = alpha(i, alphaColumn - 1) +
                                e.Inc(i, absoluteColumn - 1) +
                                beta(i + 1, betaColumn);
                v = C::Combine(v, thisMoveScore);

                // Merge (2 possible ways):
                thisMoveScore = alpha(i, alphaColumn - 2) +
                                e.Merge(i, absoluteColumn - 2) +
                                beta(i + 1, betaColumn);
                v = C::Combine(v, thisMoveScore);

                thisMoveScore = alpha(i, alphaColumn - 1) +
                                e.Merge(i, absoluteColumn - 1) +
                                beta(i + 1, betaColumn + 1);
                v = C::Combine(v, thisMoveScore);
            }

            // Delete:
            thisMoveScore = alpha(i, alphaColumn - 1) +
                            e.Del(i, absoluteColumn - 1) +
                            beta(i, betaColumn);
            v = C::Combine(v, thisMoveScore);
        }

        return v;
    }
Пример #2
0
    INLINE_CALLEES void
    EdnaCounts::DoCount(Feature<int> channelRead,
                             EdnaEvaluator& eval,
                             MutationScorer<SparseSseEdnaRecursor>& scorer,
                             int j1, int j2, float *results)
    {
        const SparseMatrix *alpha = scorer.Alpha();
        const SparseMatrix *beta = scorer.Beta();

        int usedBegin, usedEnd;
        boost::tie(usedBegin, usedEnd) = RangeUnion(alpha->UsedRowRange(j1),
                                                    beta->UsedRowRange(j2));

        for (int k = 0; k < 5; k++)
            results[k] = NEG_INF;

        for (int i = usedBegin; i < usedEnd; i++)
        {
            results[0] = detail::logAdd(results[0],
                                        alpha->Get(i, j1) +
                                        eval.ScoreMove(j1, j2, 0) +
                                        beta->Get(i, j2));
        }

        int nRows = alpha->Rows();
        int usedCap = usedEnd < nRows - 1 ? usedEnd : nRows - 1;

        for (int i = usedBegin; i < usedCap; i++)
        {
            int readBase = channelRead[i];
            results[readBase] = detail::logAdd(results[readBase],
                                               alpha->Get(i, j1) +
                                               eval.ScoreMove(j1, j2, readBase) +
                                               beta->Get(i+1, j2));
        }
    }