Repository navigation
Let a gap in one sequence directly follow a gap in the other - #1175
Open
josemduarte wants to merge 2 commits into
Open
josemduarte wants to merge 2 commits into
josemduarte wants to merge 2 commits into
Conversation
With an identity matrix, AAAKKDDDFDD against AAAFFDDDFDD should align KK and FF against gaps (score -13 with gaps 9/1), but the affine recurrence never lets a gap in one sequence directly follow a gap in the other, so it returns a worse alignment (-22), or a forbidden mismatch (-10012) when there is no shared residue to pivot on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…#213) The affine (Gotoh) recurrence only opened a deletion or an insertion from the substitution state, so an alignment could not switch straight from a gap in the query to a gap in the target. Allow both transitions, each charged a full gap opening, in AlignerHelper (global, local and anchored aligners) and in PairwiseStatisticsAligner, which must compute the same recurrence. A new transition is taken only when strictly better, so ties keep their previous alignment. The stored score matrices in three tests change only in the deletion and insertion states, and every changed value is higher; no substitution values, and so no scores in those tests, change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #213.
Problem
The affine (Gotoh) recurrence only opened a deletion or an insertion from the substitution state, so an alignment could never switch straight from a gap in one sequence to a gap in the other. With an identity matrix and gaps 9/1:
instead of
AAAKK--DDDFDD/AAA--FFDDDFDD(-13), and without the sharedFit was forced into a forbidden mismatch (-10012).Change
AlignerHelper.setScorePointandsetAffineScorePoint(used by the global, local and anchored aligners) allow deletion → insertion and insertion → deletion. The switch opens a new gap and is charged a full gap opening. The issue's example therefore scores -13, not the -4 suggested there, which charged one opening for both gaps.PairwiseStatisticsAlignercomputes the same recurrence forAllPairsScores, so it gets the same transitions in its local and global versions, keeping its path statistics.AllPairsScoresTestandPairwiseStatisticsAlignerTestcheck it against the aligners.Testing
NeedlemanWunschTest.testAdjacentGapsInBothSequences: both examples from the issue, checking the score and that no column pairs two different residues.NeedlemanWunschTest,SmithWatermanTest,SimpleProfileProfileAlignerTest). Their expected strings are regenerated: 121 cells change, all in the deletion and insertion states and all higher. No substitution values change, so the alignments and scores in those tests are the same.biojava-alignment(153),biojava-structure(457) andbiojava-genome(206) tests pass against this change.🤖 Generated with Claude Code