Repository navigation
Corrected mode: Z-drop ends (#22), X-drop/Z-drop score with match == 0 (#55), BiWFA - #56
Merged
Merged
Conversation
On a Z-drop, C backtraces the best cell's diagonal and offset starting at the current score, where that cell needn't exist. High memory then finds no source and returns an empty CIGAR or unchecked matches (invalid with match < 0); med/low read a dead cell whose backtrace C never initialized, so C's high and med results differ. In Compat::Corrected, a Z-drop end is backtraced at the score the best cell was found at: from the stored wavefronts in high memory, and in med/low from the cell's (pcigar, prev), kept when it became the best and pinned through backtrace-buffer compaction (which now pins a slice). All memory modes then give a valid partial alignment with the same score. Compat::C is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
X-drop and Z-drop score cells with (swg_match*(v+h) - wf_score)/2. For match == 0, C's stand-in match score is -1 since its commit 51fb1aa (before, a special case used "match-score=1"), so progress lowers the score: X-drop prunes the diagonals that progress most, abandoning nearly every divergent pair with default penalties, and Z-drop's best cell is the start. heuristic::swg_match returns -1 in Compat::C and +1 in Compat::Corrected, passed to the heuristics in place of the match penalty. With default penalties, X-drop goes from ~0/300 to 300/300 optimal on long.seq. The #21 tests move to wfa.utest.seq pair 305 with match-reward penalties and X-drop 20,2, so they still compare corrected scores with C's; their CIGAR check now uses the SW score bound. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The forward, reverse and base sub-aligners run the heuristics and the base backtrace, but were created with Compat::C and only given the parent's heuristic, so corrected mode never reached BiWFA: the #21 and #55 fixes didn't apply there. take_biwfa_subs now sets their compat to the parent's on every call. The #21 tests check BiWFA too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A BiWFA base sub-alignment that Z-drops is backtraced like the unidirectional end in C: at the current score, and in the sub-problem's end component, which can be I/D, though the best cell is an M cell. In Compat::Corrected it starts in M at the best cell's score, so BiWFA's partial alignments are valid too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 17, 2026
Open
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.
Refs #22, #55, #21. These stay open until upstream C resolves them. All changes are behind
Compat::Corrected(#32);Compat::Cis unchanged. There are four atomic commits:1.
210f60e: Z-drop ends backtraced at the best cell's score (#22)On a Z-drop, C backtraces the best cell's diagonal and offset starting at the current score, where that cell needn't exist.
match < 0the CIGARs are invalid, e.g.2I58Mon a 2 kb, 8%-error pair, and up to 300/300 invalid onlong.seqwith affine-3,5,3,2and Z-drop100,5. Known issue (C bug): Z-drop in med/low backtraces from uninitialized cells (high vs med differ) #22 only described themedside, so this part is new.med/low: the backtrace reads a dead cell that C never initialized (Known issue (C bug): Z-drop in med/low backtraces from uninitialized cells (high vs med differ) #22).Corrected mode backtraces the cell at the score it was found at:
med/lowfrom the cell's(pcigar, prev), saved when it became the best and pinned through backtrace-buffer compaction (compaction now takes a slice of pinned chains).2.
b7b7889: X-drop/Z-drop score withmatch == 0(#55, new)C's Smith-Waterman score for these heuristics uses
swg_match = -1whenmatch == 0, which is the default for every gap metric. This regression from C's 51fb1aa flipped the old "match-score=1" stand-in, so progress lowers the score:long.seq: typically 0/300 optimal).Corrected mode uses
+1(heuristic::swg_match). With default penalties, X-drop is then optimal on 300/300long.seqpairs at50,10/100,5for affine, linear and affine2p, and Z-drop gives real partial alignments.The #21 tests move to
wfa.utest.seqpair 305 with match-reward penalties and X-drop20,2, so they still check that corrected scores equal C's. Their CIGAR check now uses the SW-score bound, which is meaningful with a match reward.3.
6374f4d: passCompatto BiWFA's sub-aligners (Rust bug from #54)BiWFA's forward, reverse and base sub-aligners were created with
Compat::Cand only given the parent's heuristic. So the #21 fix (and now #55) never applied under BiWFA; #54's "BiWFA identical to C" was this, not parity. Now:4.
70e6f2d: BiWFA Z-drop ends at the best cell (#22)BiWFA's base step backtraces a Z-drop in the same way as C, and also starts in the sub-problem's end component (I/D at a breakpoint), though the best cell is an M cell. Corrected mode starts in M at the best cell's score. Across BiWFA Z-drop configurations:
long.seq50,10: 0, C: 300).Results
match < 0(the existing fix). Banded, adaptive and core cases are identical to C.20,1/50,1/50,10/100,5× default and-3,5,3,2× global / extension / ends-free ×wfa.utest.seqandlong.seq:medexcept co-optimal ties (an empty CIGAR vs1M/2M, both scoring 0).Tests
tests/corrected_zdrop.rs:med/lowagree;tests/corrected_xdrop.rs: now also checks BiWFA.test_compute_sw_scores_c_formula: covers both stand-ins.cargo testpasses in release and debug; clippy is clean.Docs: the
Compatlist, theXDrop/ZDroprustdoc, the README, and FIXED_BUGS 14e, 14f and 14g.🤖 Generated with Claude Code