Repository navigation
fix(bam): per-reference CRAM fetch keeps only that reference's records - #178
Draft
NicoDeVeaux wants to merge 2 commits into
Draft
NicoDeVeaux wants to merge 2 commits into
NicoDeVeaux wants to merge 2 commits into
Conversation
… records In a multi-reference CRAM slice, `fetch(tid)` returns every record in the slice whose position overlaps the (whole-reference) interval, whatever its reference: noodles' query filters on the interval only. On the parallel path each such record is counted once per reference fetch (flagstat "in total" 10 instead of 6 for the samtools-written fixture at --threads 4). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
noodles' CRAM `query` filters records on the interval only, so in a multi-reference slice `fetch(tid)` also returned other references' records whose positions fall inside the whole-reference interval. Keep only records whose reference sequence ID is `tid`, as htslib does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
fix(bam): per-reference CRAM fetch keeps only that reference's records
For PR #118, stacked on
fix/pr118-unmapped-sweep(base #118 head0b00cf1). Found while testing that branch; not one of the review's findings.What
IndexedReader::fetch(tid)on a CRAM now keeps only records whose reference sequence ID istid.Why
noodles' CRAM
query(noodles-cram0.94.0,io/reader/query.rs) selects containers through the index but then filters records by interval only, not by reference. In a multi-reference slice (htslib can write these when references have few records, such as many small contigs;--output-fmt-option multi_seq_per_slice=1forces one) a per-reference fetch over the whole-reference interval also returns the other references' records. On the parallel path each such record is counted once per reference fetch.Input:
tests/data/unmapped_sweep/multi_ref_slice.cram(six records, chr1/chr2 and two unplaced, in one slice; samtools 1.22.1),--reference sweep.fa:-t 1in total-t 4in totalmainbea5571 (htslib)fix/pr118-unmapped-sweepThe per-reference CRAMs (
single_ref_slices.cram) give 6 everywhere.How tested
cram_unmapped_sweep_returns_only_unplaced_recordsnow also checks that the per-reference fetches plus the sweep return each record once for the multi-reference CRAM (before:r0, r1, r2, r3each twice).test_parallel_cram_multi_reference_slice_counts_each_record_once: flagstat at--threads 1and4must equal samtools 1.22.1's (before:10 + 0 in totalat-t 4).cargo test --release --locked --offline: 206 unit, 12 bin, 20 integration, 2 doc tests pass.cargo fmt --checkpasses.cargo clippy -- -D warningsreports the same threeneedless_range_looperrors as unmodifiedmainwith the local toolchain (clippy 0.1.90); with that lint allowed,--all-targetsis clean.Not changed, and why
🤖 Generated with Claude Code