Skip to content

Commit

Permalink
fix: out of bounds issue on 5'-to-3' shifting beyond CDS (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
holtgrewe authored Apr 6, 2023
1 parent a40a5f5 commit 4fccdb8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/mapper/altseq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,17 @@ impl AltSeqToHgvsp {
is_frameshift,
} = &record;

// Handle the case of the variant being after the end of the protein sequence. This can
// happen when the variant is 5'-to-3' shifted beyond the stop codon. In this case, we
// can simply return `ProtLocEdit::NoChange` which will display as `p.=`.
if *start as usize > self.ref_seq().len() {
return Ok(HgvsVariant::ProtVariant {
accession: Accession::new(protein_accession),
gene_symbol: None,
loc_edit: ProtLocEdit::NoChange,
});
}

// defaults
let mut is_dup = false; // assume no dup
let mut fsext_len = UncertainLengthChange::default(); // fs or ext length
Expand Down
2 changes: 1 addition & 1 deletion src/normalizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ impl<'a> Normalizer<'a> {
if stop < ref_seq.len().try_into()? || start == orig_start {
break;
}
// If stop at the end of the window, try to extend teh shuffling to the right.
// If stop at the end of the window, try to extend the shuffling to the right.
base += start - orig_start;
stop -= start - orig_start;
start = orig_start;
Expand Down

0 comments on commit 4fccdb8

Please sign in to comment.