Robustify the NeedlemanWunsch Aligner

This change is about future proofing, it has no effect right now.

The aligner has to deal with an edge case where an insertion can follow
a deletion, or a deletion can follow an insertion.  To make this
happen, when considering insertions or deletions, we have to consider
opening a gap from both the "Match" state as well as the "Gap Score"
and the highest of these will form the viterbi path.

For all sensible parameter settings, the Match state should be the
highest score, but for some pathological ones, the gap states might be.
 This clarifies which states are the most likely, and makes it so that
in the future if someone switched the order of move preferences (e.g.
so that in an event of equal scoring, rather than vertical->left->diag
being the order of preference it is left->vertical->diag) the code
would still produce the highest score.  Before, we only took the best
score for the vertical move, and the match score for the horizontal
move.
This commit is contained in:
Nigel Delaney 2015-12-06 16:50:30 -08:00
Родитель 9a3aad059e
Коммит 19b35d728a
1 изменённых файлов: 2 добавлений и 2 удалений

Просмотреть файл

@ -261,7 +261,7 @@ namespace Bio.Algorithms.Alignment
// Gap in reference sequence
int scoreAbove;
int scoreAboveOpen = cellAbove.BestScore + GapOpenCost;
int scoreAboveOpen = Math.Max(cellAbove.HorizontalGapScore, cellAbove.MatchScore) + GapOpenCost;
int scoreAboveExtend = cellAbove.VerticalGapScore + GapExtensionCost;
if (scoreAboveOpen > scoreAboveExtend)
{
@ -276,7 +276,7 @@ namespace Bio.Algorithms.Alignment
// Gap in query sequence
int scoreLeft;
int scoreLeftOpen = cellLeft.MatchScore + GapOpenCost;
int scoreLeftOpen = Math.Max(cellLeft.MatchScore, cellLeft.VerticalGapScore) + GapOpenCost;
int scoreLeftExtend = cellLeft.HorizontalGapScore + GapExtensionCost;
if (scoreLeftOpen > scoreLeftExtend)
{