You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Known issue (C parity): score-only score for unreachable alignments evaluated at an unset end position #23
Status: undefined behaviour in C WFA2-lib, reproduced for output parity. Affects only score-only output with a match reward (match < 0) for alignments that end unreachable (banded, X-drop). Not yet reported upstream.
Symptom
For unreachable alignments, C's wavefront_unialign_terminate computes the classic (SW) score at alignment_end_pos, which is still its initial value (k = DPMATRIX_DIAGONAL_NULL = INT_MAX, offset = WAVEFRONT_OFFSET_NULL = INT32_MIN/2). end_v = offset - k overflows (signed overflow, undefined behaviour); in practice it wraps so that v + h == 1, and the reported score is (swg_match - score) / 2. That depends only on the score at which the alignment gave up, not on any alignment.
Example: wfa.utest.seq pair 262, -a gap-affine-wfa --affine-penalties=-3,5,3,2 --wfa-score-only --wfa-heuristic=xdrop --wfa-heuristic-parameters=20,1 gives -113 (in CIGAR mode the same pair is -1 -, unreachable). (Corrected 2026-10-17: this example originally named pair 101, which is reachable.)
Related, not undefined behaviour: with match == 0 an unreachable pair's score-only output is the negated score where the search gave up, and a failed BiWFA score search prints INT32_MIN.
Rust
Reproduced for byte parity: the CLI evaluates the classic score at the same position with wrapping arithmetic (wf_score_to_sw_score is now wrapping), and the end position is initialized as in C. A saner output would be the -1 sentinel or the score at the best cell.
Corrected mode (#57): with --no-c-compat, the CLI prints -1 in score-only mode whenever there is no alignment (all three cases), as CIGAR mode does. Compat::C still reproduces C.
Plan
Report upstream: overflow/UB, plus a suggestion for unreachable alignments.
Fixed in the CLI's corrected mode by #57 (c9e97eb); keeping this open until upstream C resolves it. With --no-c-compat, score-only prints -1 when there's no alignment. That covers this overflow case, the give-up score with match == 0, and BiWFA's INT32_MIN. I corrected the example above: pair 101 is reachable, and pair 262 reproduces the overflow (-113). Known limitation: BiWFA score-only has no partial result, so when its search Z-drops it prints -1 even though CIGAR mode returns a partial alignment (FIXED_BUGS 14h).
Activity
Merge pull request #57 from HPCBio/fix/unreachable-score-corrected
cjfields commentedon Oct 17, 2026
Fixed in the CLI's corrected mode by #57 (
c9e97eb); keeping this open until upstream C resolves it. With--no-c-compat, score-only prints-1when there's no alignment. That covers this overflow case, the give-up score withmatch == 0, and BiWFA'sINT32_MIN. I corrected the example above: pair 101 is reachable, and pair 262 reproduces the overflow (-113). Known limitation: BiWFA score-only has no partial result, so when its search Z-drops it prints-1even though CIGAR mode returns a partial alignment (FIXED_BUGS 14h).