From 475398d0e831afa43abc53327abb14135df40aea Mon Sep 17 00:00:00 2001 From: Manuel Holtgrewe Date: Fri, 24 Mar 2023 10:48:25 +0100 Subject: [PATCH] fix: issue with out of bounds deletion (#59) --- src/mapper/altseq.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/mapper/altseq.rs b/src/mapper/altseq.rs index d4070ec..1080588 100644 --- a/src/mapper/altseq.rs +++ b/src/mapper/altseq.rs @@ -324,12 +324,16 @@ impl AltSeqBuilder { _ => panic!("invalid variant"), } + let seq = self.reference_data.transcript_sequence.to_owned(); + let start = std::cmp::min(start_end[0], seq.len()); + let end = std::cmp::min(start_end[1] + 1, seq.len()); + ( - self.reference_data.transcript_sequence.to_owned(), + seq, self.reference_data.cds_start, self.reference_data.cds_stop, - start_end[0], - start_end[1] + 1, + start, + end, ) }