Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Fix overflow bugs in VDJ FR3 start identification. (#316)
Browse files Browse the repository at this point in the history
Consistently handle FR3 start window bounds in the face of sequences that are possibly shorter than the window we're searching in. Bail out early if the full search window does not overlap with the sequence, to ensure that the FR3 start computed based on a given contig is the same irrespective of the amount of prefix clipped in the contig.
  • Loading branch information
macklin-10x authored Jan 23, 2024
1 parent 305edf9 commit 6856c58
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions vdj_ann/src/vdj_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,9 +466,11 @@ pub fn fr3_start(aa: &[u8], chain_type: &str, verbose: bool) -> Option<usize> {
];

// Score positions.

if cdr3_start < 42 - 2 {
return None;
}
let mut score_pos = Vec::<(usize, isize)>::with_capacity(42 - 32 + 1);
for j in cdr3_start.saturating_sub(42 - 2)..=cdr3_start.saturating_sub(32 - 2) {
for j in cdr3_start - (42 - 2)..=cdr3_start - (32 - 2) {
let mut score = 0;
for (p, wm) in pwm.iter().enumerate() {
for l in wm {
Expand Down Expand Up @@ -525,7 +527,9 @@ pub fn fr3_start(aa: &[u8], chain_type: &str, verbose: bool) -> Option<usize> {
];

// Score positions.

if cdr3_start < 36 {
return None;
}
let mut score_pos = Vec::<(usize, usize)>::with_capacity(36 - 33 + 1);
for j in cdr3_start - 36..=cdr3_start - 33 {
let mut score = 0;
Expand Down Expand Up @@ -569,7 +573,9 @@ pub fn fr3_start(aa: &[u8], chain_type: &str, verbose: bool) -> Option<usize> {
];

// Score positions.

if cdr3_start < 38 {
return None;
}
let mut score_pos = Vec::<(usize, usize)>::with_capacity(38 - 35 + 1);
for j in cdr3_start - 38..=cdr3_start - 35 {
let mut score = 0;
Expand Down

0 comments on commit 6856c58

Please sign in to comment.