From 54231b983b1cbc4480631bde05ab55e2a668ed72 Mon Sep 17 00:00:00 2001 From: Manuel Holtgrewe Date: Fri, 24 Mar 2023 13:24:59 +0100 Subject: [PATCH] fix: truncate AA insertion at stop codon (#60) --- src/mapper/altseq.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/mapper/altseq.rs b/src/mapper/altseq.rs index 1080588..b05607f 100644 --- a/src/mapper/altseq.rs +++ b/src/mapper/altseq.rs @@ -947,6 +947,15 @@ impl AltSeqToHgvsp { ) -> Result { assert!(start.is_some() == end.is_some()); + // If the `alternative` contains a stop codon (`*`/`X`) then we have to truncate + // after it. + let alternative = if let Some(pos) = alternative.find('*').or_else(|| alternative.find('X')) + { + &alternative[..=pos] + } else { + alternative + }; + let loc_edit = if is_init_met { ProtLocEdit::InitiationUncertain } else if is_ambiguous {