From d58d2d93489eb5159bb73cf71f7bc9d01aa30d4c Mon Sep 17 00:00:00 2001
From: David Parsons <david.parsons@inria.fr>
Date: Tue, 12 Dec 2023 18:36:37 +0100
Subject: [PATCH] fix position computation for small_insertion

---
 src/libaevol/7/Dna_7.cpp | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/libaevol/7/Dna_7.cpp b/src/libaevol/7/Dna_7.cpp
index 814713e05..6fb30c5d9 100644
--- a/src/libaevol/7/Dna_7.cpp
+++ b/src/libaevol/7/Dna_7.cpp
@@ -273,7 +273,14 @@ Mutation* Dna_7::do_small_deletion(size_type pos, int16_t nb_del) {
   auto old_pos = pos;
 
   // Remove promoters containing at least one nucleotide from the sequence to  delete
-    ann_chrsm_->promoter_list().remove_promoters_around(pos, Utils::mod(pos + nb_del, length_), length_);
+  auto end_del = size_type{0};
+  #ifdef __EUKARYOTE
+    end_del = std::min(length(), pos + nb_del);
+  #else
+    end_del = Utils::mod(pos + nb_del, length());
+  #endif
+
+  ann_chrsm_->promoter_list().remove_promoters_around(pos, end_del, length());
 
   // Do the deletion and update promoter list
   if (pos + nb_del <= length()) { // the deletion does not contain the origin of
-- 
GitLab