Skip to content

Pe overlap consolidation - #138

Merged
Psy-Fer merged 2 commits into
mainfrom
pe-overlap-consolidation
Jul 27, 2026
Merged

Pe overlap consolidation#138
Psy-Fer merged 2 commits into
mainfrom
pe-overlap-consolidation

Conversation

@Psy-Fer

@Psy-Fer Psy-Fer commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

--peOverlapNbasesMin mate-overlap merge-and-realign — consolidated + STAR-faithful filter stage (closes #119)

Consolidates BenjaminDEMAILLE's PE mate-overlap PR, with the review-flagged filter-stage divergence from real STAR fixed and the feature validated against STAR 2.7.11b on 10k yeast pairs.

When a fragment is shorter than mate1_len + mate2_len, the mates overlap in genome space. STAR (peOverlapMergeMap) merges them into one contiguous single-end read, aligns that, and converts the result back to a two-mate pair — often stitching cleanly across the overlap where separate-mate alignment fails.

Closes #119.

Fix: merged-read find must be filter-free (defer to the PE stage)

The port aligned the merged read with the full SE driver (align_read), which applies mappedFilter's read-length gates — outFilterMatchNminOverLread (default 0.66) and outFilterScoreMinOverLread — against the merged length. STAR's peMergeRA->mapOneRead() is a find step: it locates windows without those gates, converts every candidate to PE, and runs multMapSelect()/mappedFilter() only afterward at the PE level, on the reconstructed pair (ReadAlign_oneRead.cpp:87-91). Applying the SE gate to the longer merged read silently dropped merges the PE stage would keep.

Fixed: the merged-read find now runs with the length-relative gates disabled; the existing PE decision tree (filter_paired_transcripts, which already applies the combined-length match/score gates) does the real filtering after convert_merged_transcript_to_pe.

Validation (yeast PE, --peOverlapNbasesMin 10, vs STAR 2.7.11b)

both-mapped
peOverlap off (baseline) rustar 8390 = STAR 8390 (exact, unchanged)
peOverlap on — before fix rustar 8726 vs STAR 8812 → 86 pairs under-rescued
peOverlap on — after fix rustar 8823, STAR 8812

After the fix rustar is a strict superset of STAR's peOverlap rescues: 0 pairs mapped by STAR but not rustar, plus 11 extra — all verified legitimate (proper pairs, FLAG 99/147, nM 0–1) that STAR's peMerge heuristic misses, consistent with rustar's already-documented PE-improvement cases. CIGAR agreement 17367/17624 (98.5%).

Tests

  • New convert_reverse_strand_flips_mates_and_swaps_coords unit test — the review-flagged untested path: the reverse-strand m_sta = Lread − readLen − m_sta coordinate swap + the mate-strand flip (mate1 takes the fragment strand, mate2 the opposite). Asserts the strand flip, per-mate coverage, and the mirrored genomic spans.
  • Spliced / exon-split conversion paths are exercised end-to-end by the yeast run (e.g. a spliced merge in ERR12389696.16897393).

Gate: 574 tests pass · clippy --all-targets 0 warnings · fmt clean. --peOverlapNbasesMin defaults to 0 (off), so the default path is unchanged.

BenjaminDEMAILLE and others added 2 commits July 27, 2026 16:49
Port of STAR's ReadAlign::peMergeMates / peOverlapSEtoPE (STAR-rs
star_pe_overlap.rs): when mates overlap in genome space, merge them
into one SE read, realign through the existing SE pipeline, and
convert the result back into a two-mate pair, rescoring from scratch.
Unconditional overwrite of the separate-mate result on success, per
STAR semantics.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
(matches STAR); reverse-strand conversion test
@Psy-Fer Psy-Fer self-assigned this Jul 27, 2026
@Psy-Fer
Psy-Fer enabled auto-merge (squash) July 27, 2026 11:10
@Psy-Fer
Psy-Fer merged commit f53b4f8 into main Jul 27, 2026
10 checks passed
@Psy-Fer
Psy-Fer deleted the pe-overlap-consolidation branch July 27, 2026 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants