Skip to content

Commit 6165b22

Browse files
pinin4fjordsclaude
andcommitted
fix(score): score_annotated_junction helper uses replacement not addition
The helper at src/align/score.rs:137-143 had the same additive bug as the stitch-time call site this PR fixes — adding sjdb_score to the motif score rather than replacing it. Currently only called from its own tests, but a landmine if any other caller picks it up. Switch to replacement semantics matching the stitch path. Update the tests that locked in the old (wrong) additive result. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent e09748b commit 6165b22

1 file changed

Lines changed: 5 additions & 15 deletions

File tree

src/align/score.rs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -126,19 +126,12 @@ impl AlignmentScorer {
126126
((genomic_span as f64).log2() * self.score_genomic_length_log2_scale - 0.5).ceil() as i32
127127
}
128128

129-
/// Apply annotation bonus to junction score
130-
///
131-
/// # Arguments
132-
/// * `base_score` - Base score from motif
133-
/// * `annotated` - Whether the junction is annotated in GTF
134-
///
135-
/// # Returns
136-
/// Adjusted score with annotation bonus applied
137-
pub fn score_annotated_junction(&self, base_score: i32, annotated: bool) -> i32 {
129+
/// Annotated junctions score `sjdb_score`; unannotated junctions score `motif_score`.
130+
pub fn score_annotated_junction(&self, motif_score: i32, annotated: bool) -> i32 {
138131
if annotated {
139-
base_score + self.sjdb_score
132+
self.sjdb_score
140133
} else {
141-
base_score
134+
motif_score
142135
}
143136
}
144137

@@ -959,17 +952,14 @@ mod tests {
959952
out_filter_score_min_over_lread: 0.66,
960953
};
961954

962-
// Annotated junction should get bonus
963955
let annotated_score = scorer.score_annotated_junction(0, true);
964956
assert_eq!(annotated_score, 2);
965957

966-
// Novel junction should not get bonus
967958
let novel_score = scorer.score_annotated_junction(0, false);
968959
assert_eq!(novel_score, 0);
969960

970-
// Bonus applies to any base score
971961
let annotated_noncanon = scorer.score_annotated_junction(-8, true);
972-
assert_eq!(annotated_noncanon, -6); // -8 + 2
962+
assert_eq!(annotated_noncanon, 2);
973963
}
974964

975965
#[test]

0 commit comments

Comments
 (0)