Wasp consolidation - #137
Merged
Merged
Conversation
Port STAR's WASP filter (--waspOutputMode SAMtag, --varVCFfile) from STAR-rs `crates/star-align/src/star_wasp.rs`. A uniquely-mapped read overlapping heterozygous SNVs is re-mapped with every alternative-allele combination; if all re-maps land on the identical locus it passes (vW:i:1), otherwise a failure code (2..7) is reported. Emits vW, and vA/vG when requested in --outSAMattributes. - src/wasp/mod.rs: load_vcf, wasp_type (re-map decision), wasp_variants (vG/vA), and record annotation. Works in base-code space; variant/read overlap is computed by walking the transcript CIGAR (same convention as build_md_tag), so it does not depend on the exon read-coordinate frame. - src/params: add --waspOutputMode (None|SAMtag) and --varVCFfile, validation (SAMtag requires a VCF), and vW/vA/vG in --outSAMattributes. - src/lib.rs: load the VCF once per run, re-map with a WASP-relaxed parameter set (match_nmin=0, multimap_score_range=1, multimap_nmax=10, matching STAR), and stamp vW/vA/vG onto the SAM records in the single-end path. Paired-end WASP is a follow-up. See docs-old/dev/porting-from-star-rs.md. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Complete the WASP filter for paired-end reads, the documented follow-up to the single-end port (3e84d97). Ports STAR-rs `wasp_type_pe` / `wasp_variants_pe` into rustar-aligner's two-transcript-per-pair model. - src/wasp/mod.rs: add wasp_variants_pe (combined vG/vA over mate1 then mate2, STAR's `mate1 ++ rc(mate2)` combined-transcript order), wasp_type_pe (single vW code: walk each mate's variants in its SAM frame, apply every allele combination, map back to forward mates, and re-map the pair via align_paired_read with the WASP-relaxed params; a combination passes only if exactly one both-mapped pair lands on the same exons for both mates), and annotate_records_pe (both mate records share vW/vA/vG; multimapped pairs overlapping variants get vW:i:2). - src/lib.rs: build the WaspContext once in align_reads_paired_end and stamp vW/vA/vG onto the built pair records, mirroring the single-end path. Gate green: cargo build, clippy -D warnings, fmt, 464 tests (2 new PE variant-frame unit tests). Byte-level validation against native STAR via the test/ harness is a separate step. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
(matches STAR); wire into pipelined loop
Psy-Fer
enabled auto-merge (squash)
July 27, 2026 06:39
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.
WASP allele-specific-mapping filter (
--waspOutputMode SAMtag) — consolidated + STAR-faithful (closes #108)Consolidates BenjaminDEMAILLE's WASP PR, with the two review-flagged divergences from real STAR fixed and the feature validated byte-for-byte against STAR 2.7.11b.
WASP (van de Geijn et al. 2015) removes reference-mapping bias: a read overlapping a heterozygous SNV is re-mapped with the allele swapped; if it no longer maps to the same locus, it's flagged. rustar emits STAR's
vW(pass/fail code) plus opt-invA/vGtags.Closes #108.
Fixes vs the original port (verified against
ReadAlign_waspMap.cpp)1. Re-map used relaxed filters (STAR-rs quirk) → now uses the user's params unmodified.
The port's
wasp_remap_paramssetout_filter_match_nmin = 0,out_filter_match_nmin_over_lread = 0.0,out_filter_multimap_score_range = 1,out_filter_multimap_nmax = 10. STAR's WASP re-map iswaspRA = new ReadAlign(Pin,…)sharing the sameP, running the normalmapOneRead()→multMapSelect()→mappedFilter(); a swapped read failingmappedFilterunder the user's own thresholds becomeswaspType=4. Relaxing the filters lets swapped reads pass WASP that STAR would reject. Fixed:wasp_remap_paramsreturnsparams.clone()verbatim.2. Multimapper
vWsemantics were per-locus → now keyed off the primary alignment.STAR computes one
waspTypefromtrBest(the primary): if the primary overlaps ≥1 variant and the read multimaps →waspType=2stamped on all of the read's records; if the primary overlaps no variant → novWon any record (even if a secondary locus does). The port stampedvW:2per-record only where that record's own locus overlapped a variant. Fixed for both SE and PE (vA/vGstay per-record, matching STAR's per-alignmentvariationAdjust).Integration into the current pipeline
The PR was written against the old single-threaded loop; it's now wired into the pipelined SE + PE drivers — the VCF is loaded once per run into a shared read-only
WaspContext, andannotate_records_se/_perun per mapped read/pair in the align stage. ThevW/vA/vGattribute flags also collided with the recently-landedGX/GN/nM(NMM) flags; WASP tags were moved to bits 12–14.Validation (vs STAR 2.7.11b, 10k yeast SE + a 60-SNV het VCF over covered loci)
vWdistribution byte-exact: rustar and STAR both236 × vW:i:1,59 × vW:i:2,9 × vW:i:6.vW:2for its own mapping; not a WASP-logic difference.--waspOutputMode SAMtag).test_wasp_samtagintegration test (synthetic genome + planted het SNV → all 10 unique overlapping reads getvW:i:1).Gate: 569 tests pass ·
clippy --all-targets0 warnings ·fmtclean.Note: STAR requires
--outSAMtype BAMwith--waspOutputMode; rustar also accepts SAM output.