From c091a1c53e3dccd6b9f58b11ab79a9840e501b9d Mon Sep 17 00:00:00 2001
From: Juliette Luiselli <juliette.luiselli@inria.fr>
Date: Tue, 22 Nov 2022 17:21:27 +0100
Subject: [PATCH] assert positions are in the correct order for rearrangements

---
 src/libaevol/7/MutationEvent.cpp | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/libaevol/7/MutationEvent.cpp b/src/libaevol/7/MutationEvent.cpp
index 62cadca2a..7daa83f29 100644
--- a/src/libaevol/7/MutationEvent.cpp
+++ b/src/libaevol/7/MutationEvent.cpp
@@ -26,6 +26,7 @@
 
 
 #include "MutationEvent.h"
+#include <cassert>
 
 namespace aevol {
 
@@ -55,6 +56,9 @@ void MutationEvent::small_deletion(int32_t pos, int32_t number) {
 }
 
 void MutationEvent::duplication(int32_t pos1, int32_t pos2, int32_t pos3) {
+  #ifdef __EUKARYOTE
+    assert(pos1 < pos2);
+  #endif
   type_ = MutationEventType::DUPLICATION;
   pos_1_ = pos1;
   pos_2_ = pos2;
@@ -63,6 +67,9 @@ void MutationEvent::duplication(int32_t pos1, int32_t pos2, int32_t pos3) {
 
 void MutationEvent::translocation(int32_t pos1, int32_t pos2, int32_t pos3,
                                     int32_t pos4, bool invert) {
+  #ifdef __EUKARYOTE
+    assert(pos1 < pos2);
+  #endif
   type_ = MutationEventType::TRANSLOCATION;
   pos_1_ = pos1;
   pos_2_ = pos2;
@@ -72,12 +79,18 @@ void MutationEvent::translocation(int32_t pos1, int32_t pos2, int32_t pos3,
 }
 
 void MutationEvent::inversion(int32_t pos1, int32_t pos2) {
+  #ifdef __EUKARYOTE
+    assert(pos1 < pos2);
+  #endif
   type_ = MutationEventType::INVERSION;
   pos_1_ = pos1;
   pos_2_ = pos2;
 }
 
 void MutationEvent::deletion(int32_t pos1, int32_t pos2) {
+  #ifdef __EUKARYOTE
+    assert(pos1 < pos2);
+  #endif
   type_ = MutationEventType::DELETION;
   pos_1_ = pos1;
   pos_2_ = pos2;
-- 
GitLab