Skip to content

Corrected mode: valid X-drop CIGARs with steps > 1 (#21) - #54

Merged
cjfields merged 1 commit into
mainfrom
fix/xdrop-steps-corrected
Oct 17, 2026
Merged

cjfields merged 1 commit into
mainfrom
fix/xdrop-steps-corrected

Conversation

@cjfields

Copy link
Copy Markdown
Member

Fixes #21 behind Compat::Corrected (#32). The default Compat::C mode is unchanged.

Problem

With steps_between_cutoffs > 1, only every n-th wavefront is pruned, and a cutoff can trim a wavefront to empty (lo > hi, null). Compute then reads it as the null wavefront. Its offsets, though, are still inside the initialized range, and the high-memory backtrace checks only that range. So the backtrace can take a source that compute never used. If that source's offset is bigger than the current cell's, the match count goes negative, and the CIGAR write position moves forward over earlier operations.

Example: wfa.utest.seq pair 201, affine 50,10. At score 506, k = 6, offset 547, the mismatch source M(502) was trimmed empty but still holds 548.

C's med mode records the real sources, so it was already valid.

Fix

In corrected mode, when a cutoff trims M, or I/D through equating, to empty, its initialized range is emptied too (Wavefront::clear_init_range). The backtrace then reads exactly what compute read. Scores are unchanged.

Results

Behaviour notes (FIXED_BUGS 14d)

  • CIGAR can rescore below the reported score: for the affine metrics, a valid CIGAR can rescore a few points below the reported score, never above. When pruning removes a gap-extend source, the WFA path opens a gap right after another, and the CIGAR merges the two. C's valid CIGARs show the same (affine2p 50,10: 5/305 pairs).
  • Some valid C CIGARs change: where C's stale source happened to stay valid, corrected mode now follows compute's path instead (e.g. long.seq pair 155, affine -3,5,3,2 100,5).
  • One extension pair returns no alignment: utest pair 222 (affine2p 100,5) now gives -1 -, as C's med mode does. C's high-memory CIGAR for it is invalid.

Tests

  • New tests/corrected_xdrop.rs (pair 201, tests/data/issue21_xdrop.seq, all three gap metrics):
    • C mode reproduces the invalid CIGAR;
    • corrected mode is valid, with the same score.
  • cargo test --release and the debug test run pass; clippy is clean.

A follow-up could give run.sh a corrected mode with its own list of expected differences, so CI checks this.

🤖 Generated with Claude Code

With steps_between_cutoffs > 1 a cutoff can trim a wavefront to empty.
Compute then reads it as the null wavefront, but its stale offsets stay
within the initialized range, so C's high-memory backtrace can take a
source compute never used; a negative match run then overwrites earlier
CIGAR operations.

In Compat::Corrected, a wavefront trimmed empty (M, or I/D by equating)
also gets an empty initialized range, so the backtrace reads what compute
read. Scores are unchanged; Compat::C is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Known issue (C parity): X-drop with steps_between_cutoffs > 1 returns invalid CIGARs

1 participant