fix(depth): 0-based output is half-open, not closed (#427) - #430
Conversation
pb.depth(..., use_zero_based=True) returned 0-based *closed* blocks instead of the documented half-open. Both coordinates were shifted down by one while the interval stayed closed, so every block covered one base fewer than its 1-based counterpart — on tests/data/io/cram/test.cram, summing block widths gave 36 bases instead of 117. The defect is upstream: PileupConfig::zero_based reached the BAM/CRAM provider and the schema metadata but never the coverage-block emitters, which hardcoded an inclusive end. Fixed in biodatageeks/datafusion-bio-functions#205; pin the pileup dep to that rev until it lands in a release. Tests: the existing coordinate-system tests only asserted the schema metadata flag, and the samtools golden-parity suite ran exclusively with use_zero_based=False, so nothing covered the actual 0-based coordinates. Add value-level tests over BAM/SAM/CRAM (half-open ends, the equal-width invariant across systems, block chaining, first-block-at-zero) and extend the NA12878 10k golden suite with a 0-based parity test across 1/2/4 partitions. All 12 new tests fail against the previous pileup pin and pass on the fix, while the 28 pre-existing pileup tests pass either way — which is precisely why this reached users. Against the golden dataset the old build recovers 19,888 of 21,155 covered positions. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
@codex pls review |
|
@claude pls review |
|
Claude finished @mwiewior's task in 2m 14s —— View job Code Review
Overall: ✅ Looks good — one medium concern, a few nits. The fix is clean and minimal (no Python code changes — correct: the bug was upstream). The test suite is thorough and the failure message in the assertion is particularly good ("A short count means 0-based ends are inclusive rather than exclusive" at Medium: Dependency jumps 3 minor versions
# Cargo.toml:66
datafusion-bio-function-pileup = { ..., rev = "d8f48e07bf90faad54f4470433119a7d7f44af84", ... }This is fine if the 0.12/0.13/0.14 pileup releases are safe, but worth a quick scan of the upstream changelog. The Suggestion: Confirm the 0.12–0.14 intermediate pileup releases don't include any breaking changes or regressions vs. the current build; add a tracking issue or TODO pointing to the upstream release to make it easy to retag later. Low: Row-order assumption in
|
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
The #427 half-open coordinate fix was pinned to a rev of biodatageeks/datafusion-bio-functions#205 while it was unreleased. It shipped in v0.14.1, so switch back to a tag as the comment promised. No behaviour change: v0.14.1 is that fix (447dba4) plus the release commit. Full suite passes, including the value-level 0-based coordinate tests this branch adds. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Repointed the pileup dependency from the temporary rev to tag No behaviour change: v0.14.1 is that fix ( Full suite passes — 1080 passed, 3 skipped — including the value-level 0-based coordinate tests this branch adds. I left |
pb.depth(..., use_zero_based=True) returned 0-based closed blocks instead of the documented half-open. Both coordinates were shifted down by one while the interval stayed closed, so every block covered one base fewer than its 1-based counterpart — on tests/data/io/cram/test.cram, summing block widths gave 36 bases instead of 117.
The defect is upstream: PileupConfig::zero_based reached the BAM/CRAM provider and the schema metadata but never the coverage-block emitters, which hardcoded an inclusive end. Fixed in
biodatageeks/datafusion-bio-functions#205; pin the pileup dep to that rev until it lands in a release.
Tests: the existing coordinate-system tests only asserted the schema metadata flag, and the samtools golden-parity suite ran exclusively with use_zero_based=False, so nothing covered the actual 0-based coordinates. Add value-level tests over BAM/SAM/CRAM (half-open ends, the equal-width invariant across systems, block chaining, first-block-at-zero) and extend the NA12878 10k golden suite with a 0-based parity test across 1/2/4 partitions.
All 12 new tests fail against the previous pileup pin and pass on the fix, while the 28 pre-existing pileup tests pass either way — which is precisely why this reached users. Against the golden dataset the old build recovers 19,888 of 21,155 covered positions.
Description
Related issue
Closes #
Type of change
How has this been tested?
Checklist
python -m pytest) and, for Rust changes,cargo check/cargo testpass.maturin develop --releaseand verified the change works end-to-end where applicable.docs/) as needed.CHANGELOG.mdunder[Unreleased]where user-facing behavior changed.Additional notes