From e3542c323fa99ff4ba55b363cbf0b1856dfdf341 Mon Sep 17 00:00:00 2001
From: George Marchment <georgemarchment@yahoo.fr>
Date: Tue, 1 Apr 2025 10:25:57 +0200
Subject: [PATCH] Add filter "addParams" + upate position subworklfow anker +
 update 1 or 2 small bugs

---
 src/operation.py |  2 +-
 src/workflow.py  | 30 +++++++++++++++++++-----------
 2 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/src/operation.py b/src/operation.py
index 82b697b..ea2188b 100644
--- a/src/operation.py
+++ b/src/operation.py
@@ -1040,7 +1040,7 @@ class Operation(Executor):
                 #   a = ...
                 #}
                 #b = a -> when wanting to rewrite this operation
-                if(set(types)=={"Channel"}):
+                elif(set(types)=={"Channel"}):
                     None
                     #operations = {}
                     #for c in dico_origin_2_replace[origin]:
diff --git a/src/workflow.py b/src/workflow.py
index 9fc7469..9c0c736 100644
--- a/src/workflow.py
+++ b/src/workflow.py
@@ -506,7 +506,10 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen
         
         #Remove the includes
         for match in re.finditer(constant.FULL_INLCUDE_2, code):
-            code = re.sub(fr"{re.escape(match.group(0))}.*", "", code)
+            full_include = match.group(0)
+            for temp in re.finditer(fr"{re.escape(full_include)} *addParams\(", code):
+                raise BioFlowInsightError("There is an 'addParams' in an include. BioFlow-Insight doesn not how to rewrite this.")
+            code = re.sub(fr"{re.escape(full_include)}.*", "", code)
 
         processes, subworkflows, functions = [], [], []
         for c in self.get_workflow_main().get_all_calls_in_workflow():
@@ -807,20 +810,21 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen
         ternary_operation_dico = self.ternary_operation_dico
         map_element_dico = self.map_element_dico
 
-        if(self.get_DSL()=="DSL1"):
-            code = self.convert_to_DSL2()
-            self.rewrite_and_initialise(code, self.processes_2_remove, render_graphs=render_graphs, def_check_the_same = False)
-
-        if(self.get_DSL()=="DSL2"):
-            code = self.simplify_workflow_code()
-            self.rewrite_and_initialise(code, self.processes_2_remove, render_graphs=render_graphs)
         
 
-        if(self.duplicate):  
+        if(self.duplicate): 
             #First check if there are any duplicate operations
             #That method is in the "get_order_execution_executors" method -> so we just run that first
             self.get_order_execution_executors()  
-            
+
+            if(self.get_DSL()=="DSL1"):
+                code = self.convert_to_DSL2()
+                self.rewrite_and_initialise(code, self.processes_2_remove, render_graphs=render_graphs, def_check_the_same = False)
+
+            if(self.get_DSL()=="DSL2"):
+                code = self.simplify_workflow_code()
+                self.rewrite_and_initialise(code, self.processes_2_remove, render_graphs=render_graphs)
+                    
             
             #DETERMING WHICH SUBWORKFLOWS ARE BROKEN WITH THE CLUSTER
             def get_clusters_with_calls(clusters):
@@ -969,9 +973,13 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen
             #Adding the anker
             subworkflow_section = f"//ANKER 4 SUBWORKFLOW DEF"
             to_replace = ""
-            for match in re.finditer(r"workflow\s*\w*\s*\{", code):
+            for match in re.finditer(r"workflow\s+\w*\s*\{", code):
                 to_replace = match.group(0)
                 break
+            if(to_replace==""):
+                for match in re.finditer(r"workflow\s*\{", code):
+                    to_replace = match.group(0)
+                    break
             if(to_replace==""):
                 raise Exception("No call to a workflow")
             code = code.replace(to_replace, f"{subworkflow_section}\n\n{to_replace}")
-- 
GitLab