Skip to content

Commit a26d636

Browse files
ewelsclaude
andcommitted
chore(simplify): collapse try_pair_transcripts now that all callers supply the combined score
After merging dev's combined-cluster PE stitching (commit 45792dd), the only caller of `try_pair_transcripts` always supplies a combined WT score — the per-mate fallback path that drove the `Option<i32>` override was removed with the merge. - Collapse `combined_wt_score_override: Option<i32>` → `combined_wt_score: i32`. - Drop the `scorer` parameter (its only use was in the fallback closure). - Delete the dead per-mate fallback that recomputed the score from t1.score + t2.score - p1 - p2 + combined_p. - Fold identical `thresh1` / `thresh2` half-mapped thresholds into a single `single_mate_threshold` variable (both expressions were verbatim identical post-merge). Net -19 lines; same test pass-count (340), same STAR diff-script baseline (9/10 byte-identical). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 45792dd commit a26d636

1 file changed

Lines changed: 8 additions & 27 deletions

File tree

src/align/read_align.rs

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -798,8 +798,7 @@ pub fn align_paired_read(
798798

799799
let combined_span =
800800
t1.genome_end.max(t2.genome_end) - t1.genome_start.min(t2.genome_start);
801-
let combined_score_override =
802-
Some(wt.score + scorer.genomic_length_penalty(combined_span));
801+
let combined_wt_score = wt.score + scorer.genomic_length_penalty(combined_span);
803802

804803
if let Some(pair) = try_pair_transcripts(
805804
&t1,
@@ -808,8 +807,7 @@ pub fn align_paired_read(
808807
len2,
809808
params,
810809
combined_score_threshold,
811-
&scorer,
812-
combined_score_override,
810+
combined_wt_score,
813811
) {
814812
joint_pairs.push(pair);
815813
}
@@ -1021,19 +1019,17 @@ pub fn align_paired_read(
10211019
}
10221020

10231021
// Half-mapped fallback: report the best-scoring single-mate transcript.
1024-
// STAR applies quality filter to the COMBINED read (Lread-1 = len1+len2), so use the
1025-
// same combined_score_threshold here. This matches STAR's behavior where a single-mate
1026-
// alignment that falls below the combined threshold is not output at all.
1027-
let thresh1 = combined_score_threshold.max(params.out_filter_score_min);
1028-
let thresh2 = combined_score_threshold.max(params.out_filter_score_min);
1022+
// STAR applies the quality filter to the COMBINED read (Lread-1 = len1+len2), so we
1023+
// use the same threshold for each mate here.
1024+
let single_mate_threshold = combined_score_threshold.max(params.out_filter_score_min);
10291025

10301026
let best_m1 = single_mate1_transcripts
10311027
.into_iter()
1032-
.filter(|t| t.score >= thresh1)
1028+
.filter(|t| t.score >= single_mate_threshold)
10331029
.max_by_key(|t| t.score);
10341030
let best_m2 = single_mate2_transcripts
10351031
.into_iter()
1036-
.filter(|t| t.score >= thresh2)
1032+
.filter(|t| t.score >= single_mate_threshold)
10371033
.max_by_key(|t| t.score);
10381034

10391035
match (best_m1, best_m2) {
@@ -1091,8 +1087,7 @@ fn try_pair_transcripts(
10911087
len2: usize,
10921088
params: &Parameters,
10931089
combined_score_threshold: i32,
1094-
scorer: &AlignmentScorer,
1095-
combined_wt_score_override: Option<i32>,
1090+
combined_wt_score: i32,
10961091
) -> Option<PairedAlignment> {
10971092
// Must be same chromosome
10981093
if t1.chr_idx != t2.chr_idx {
@@ -1127,20 +1122,6 @@ fn try_pair_transcripts(
11271122
return None;
11281123
}
11291124

1130-
// Combined score: use override if provided (combined-read path supplies the original
1131-
// stitch_recurse score + combined-span penalty, which correctly includes mismatch
1132-
// penalties). Fallback formula (per-mate path) undoes per-mate span penalties and
1133-
// applies a single combined-span penalty.
1134-
let combined_span = right.genome_end - left.genome_start;
1135-
let combined_wt_score = combined_wt_score_override.unwrap_or_else(|| {
1136-
let t1_span = t1.genome_end - t1.genome_start;
1137-
let t2_span = t2.genome_end - t2.genome_start;
1138-
let p1 = scorer.genomic_length_penalty(t1_span);
1139-
let p2 = scorer.genomic_length_penalty(t2_span);
1140-
let combined_p = scorer.genomic_length_penalty(combined_span);
1141-
t1.score + t2.score - p1 - p2 + combined_p
1142-
});
1143-
11441125
// SCORE-GATE: reject pairs where score is below the absolute floor
11451126
if combined_wt_score + params.out_filter_multimap_score_range < combined_score_threshold {
11461127
return None;

0 commit comments

Comments
 (0)