Repository navigation
Half-mapped pairs go through the same selection and filters as pairs - #367
Open
BenjaminDEMAILLE wants to merge 1 commit into
Open
BenjaminDEMAILLE wants to merge 1 commit into
BenjaminDEMAILLE wants to merge 1 commit into
Conversation
A pair with one aligned mate kept one location and skipped the multimapper filters. Pairs and single-mate alignments now share one list, score range, primary, mappedFilter and too-many-loci check, and one SAM builder. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 3, 2026
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.
Part of #354 (finding 2).
Moved from BenjaminDEMAILLE#1. The base,
perf/hotpaths, is a copy of #346's branch ataeba641, pushed here so this PR can target it. If #346 gets new commits, the copy needs them too. Once #346 merges, retarget this PR tomainand deleteperf/hotpaths.Stacked on #346 (
perf/hotpaths, tipaeba641). Only the one commit is this PR. It does not overlap with the PR for finding 3: the two merge without a conflict, and the merge is measured there.Problem
A pair with one aligned mate kept one location and skipped the multimapper filters. A mate in a 3-copy repeat, with its other mate unaligned, was reported as uniquely mapped at one copy:
perf/hotpathsNH:3NH:3--outSAMunmappedIt also wrote an unmapped-mate record that was not asked for.
What STAR does
Observed output of Homebrew STAR 2.7.11b; source not read.
NH:3, MAPQ 1, flags 73/329/329, in the order 5051, 15651, 10351, and no unmapped-mate record unless--outSAMunmapped Withinis set.Within: one unmapped-mate record after the alignments, tied to the primary (flags 133 / 69 / 165).Within KeepPairs: one after each single-mate alignment (389 / 325 / 421 on secondaries, with the AS and nM of its transcript).--outFilterMultimapScoreRange 30, the pair's records sayNH:3 HI:1and the singles follow.NHcounts alignments past--outSAMmultNmax.NH:2, each a single.--outFlagORand--outFlagANDapply to the mapped record only.--outReadsUnmapped Fastxwrites both mates of a half-mapped pair.Change
src/align/read_align.rs:PairedAlignmentResultgetsscore,output_rank,g_lengthandmates. OneVec<PairedAlignmentResult>in window order goes through one dedup, score range, order,filter_paired_transcriptsand too-many-loci check. The half-mapped fallback is gone, which is why the file shrinks.src/io/sam.rs:build_paired_recordstakes the whole list.build_half_mapped_recordswrites the mapped mate first and returns the unmapped mate separately, so the caller places it forWithinandKeepPairs.src/lib.rs:record_pair_alignment_statsand the output branches countresults.len(). The half-mapped special cases are removed.src/solo/mod.rs,src/wasp/mod.rs,src/quant/mod.rs,src/quant/splice_status.rs: take the list or its length. More than one alignment is a multimapper; no pair is unmapped.Measured against STAR
Fields 1-11 plus
NH,HI,AS,nM.Fixtures: the audit's
h1.fq/h2.fqonperf/hotpathshad 2 records against STAR's 3, unique 1 against 0, multiple loci 0 against 1. Here they are identical, in the same order. A crafted 11-pair fixture under 19 option sets is identical in the same order, with identicalLog.final.outcounts. On that fixtureperf/hotpathshad 20 records against STAR's 22, unique 10 against 4, and multiple loci 0 against 6.Fuzz: 4000 repeat-rich pairs. Reads differing from STAR, and records:
perf/hotpathsperf/hotpaths/ this branch--outFilterMultimapScoreRange 30--outSAMunmapped WithinWithin KeepPairs--outFilterType BySJout--outSAMmultNmax 2--peOverlapNbasesMinThe one
--peOverlapNbasesMinread (r2383) has flag 163 where STAR has 161, the proper-pair bit.perf/hotpathshas the same difference.Unmapped.out.mate*contains the same reads as STAR; the only difference is STAR's name comment (0:N: 10), already a row in #354.BAM Unsortedpassessamtools quickcheckwith 22 records, and I did not compare its fields.Deliberate divergences
None, so no
DIVERGENCE.mdentry and no sign-off needed for this. The differences listed next are not new choices, except theshortcut:one, which I flag for your review.Not the same as STAR, or not fixed here
Log.final.outsaysMismatch rate 0.00%where STAR saysnan%when no read is unique. Older than this PR.--outMultimapperOrder Randomdiffers from STAR, also onperf/hotpaths: another random number sequence.NHunder--outSAMmultNmaxstill reports the output count:NH:2where STAR hasNH:3. The pair path now follows STAR; the single-end builders were out of scope. It belongs in Tracking: fixes from the whole-repo audit (main at 32fbbc1) #354.vW),sp, or solo gene tags. Markedshortcut:insrc/lib.rs. I did not compare these with STAR.--outFilterMismatchNoverReadLmaxis refused by this binary, though STAR accepts it. Seen while testing, out of scope.Tests
tests/half_mapped_multimap.rs, all seven failing on the oldsrc/:mate_in_a_repeat_is_a_multimapper_on_every_copyunmapped_mate_record_only_on_requestsingle_mates_are_held_to_the_loci_and_mismatch_limitspair_and_single_mates_share_the_score_rangenh_counts_alignments_past_the_output_limitmates_that_cannot_pair_are_two_alignmentsrepeat_mate_counts_as_multimapping_in_gene_counts: its expected value is not from STAR, see below.Adapted in
src/io/sam.rs:test_build_half_mapped_flags,test_build_half_mapped_rnext_pnext,test_build_half_mapped_mate_order.cargo test --release(826 passed),cargo clippy --all-targetsandcargo fmt --checkare clean on macOS.Not checked
test/parity_suite.shwas not run.--quantModeand STARsolo cannot be compared here: on macOS STAR fails withcould not open input file /geneInfo.tab. SoReadsPerGene.out.taband solo counts on half-mapped reads are not checked against STAR.🤖 Generated with Claude Code