fix: off-by-one in bigWig interval start collapsed wide annot tracks (#233)#234
Merged
Conversation
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…233) bigtools get_interval already clips to the query range; storing start-1 shifted every interval one base 5', which made intervals_to_tracks compute a negative relative start and write an empty slice for wide intervals (value/span_length collapse) and a one-base dilution for fine tracks. Also fixes a latent u32 underflow for contig-start intervals. Two Rust unit tests in tests/test_bigwig.rs were asserting the buggy start-1 behavior; corrected to assert the right start coordinates. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <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.
Summary
Fixes #233. The Rust bigWig interval reader stored interval
start - 1instead ofstart. Since bigtools'get_intervalalready clips intervals to the query range, the-1was a pure off-by-one. For intervals wider than the query region (e.g. binned/annotation bigWigs), the numba kernelintervals_to_tracksthen computed a negative relative start and wrote an empty/truncated slice — collapsing wide intervals tovalue/span_length. Fine-grained tracks saw a one-base dilution. Also fixes a latentu32underflow for contig-start (start = 0) intervals.The fix is a single token in
src/bigwig.rs:MaybeUninit::new(start - 1)→MaybeUninit::new(start). The same reader backs both per-sampletracksandannot_tracks, so both paths are corrected.Changes
src/bigwig.rs— store true intervalstart(the fix).tests/integration/tracks/test_annot_tracks.py— new fail-first regression testtest_annot_bigwig_wide_intervals_full_width: builds 1 kb-binned intervals wider than the query regions, reads back the annot track, and asserts full-width fill (count_nonzero == e - s) plus value correctness against an independentpyBigWig.values()oracle. Failed 5-vs-350 on the buggy reader; passes now.tests/test_bigwig.rs— corrected two Rust unit-test expectations that had asserted the buggystart-1coordinates ([0,5]→[1,5],[99,105]→[100,105]; the true clipped coordinates).tests/dataset/_snapshots/— regenerated exactly the 4 track-dependent characterization snapshots (tracks_ragged,tracks_fixed,haps_tracks_fixed,haps_tracks_ragged); the change is a one-base edge correction. All seq-only snapshots unchanged.Scope / constraints
_dataset/_intervals.pyuntouched) — minimal, parity-preserving.SKILL.mdchange required (documents dataset-level reading, not the internal per-base coordinate).Verification
cargo test: 4/4 pass.ruff check+ruff format+typecheck: clean.🤖 Generated with Claude Code