From 72f3e1baecc94c2bcf44954f9d8d775a850586d5 Mon Sep 17 00:00:00 2001
From: George Marchment <georgemarchment@yahoo.fr>
Date: Thu, 12 Dec 2024 12:38:30 +0100
Subject: [PATCH] Fixed duplicate problem

---
 src/call.py    | 17 ++++++++++++-----
 src/process.py |  7 +++++++
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/src/call.py b/src/call.py
index 44077b4..079cb9e 100644
--- a/src/call.py
+++ b/src/call.py
@@ -1,5 +1,6 @@
 import re
 import json
+import copy
 
 
 from .code_ import Code
@@ -376,11 +377,17 @@ class Call(Executor):
             subworkflow = self.get_subworkflow_from_name(tab_call[0])
             fun = self.get_function_from_name(tab_call[0])
             if(process!=None and subworkflow==None and fun==None):
-                #temp = process
-                ##If the lements need to duplicated -> then we need to duplicate it
-                #if(self.get_duplicate_status()):
-                self.first_element_called = process
-                #print(process.get_name(), process.call)
+                #If the lements need to duplicated -> then we need to duplicate it
+                temp = process
+                if(self.get_duplicate_status()):
+                    print(process.get_number_times_called())
+                    if(process.get_number_times_called()>0):
+                        print("here")
+                        temp = copy.deepcopy(process)
+                        temp.set_alias(f"{process.get_name()}_{process.get_number_times_called()}")
+                self.first_element_called = temp
+                temp.incremente_number_times_called()
+                print(process.get_name(), process.call)
             if(process==None and subworkflow!=None and fun==None):
                 self.first_element_called = subworkflow
             if(process==None and subworkflow==None and fun!=None):
diff --git a/src/process.py b/src/process.py
index 3d7a1c8..44c2ad8 100644
--- a/src/process.py
+++ b/src/process.py
@@ -30,11 +30,18 @@ class Process(Nextflow_Building_Blocks):
         self.initialise()
         self.initialised = True
         self.call = []
+        self.number_times_called = 0
         ##It's important this is last
         #self.condition = Condition(self)
 
     def set_alias(self, alias):
         self.alias = alias
+
+    def get_number_times_called(self):
+        return self.number_times_called
+    
+    def incremente_number_times_called(self):
+        self.number_times_called+=1
     
     def set_call(self, call):
         self.call.append(call)
-- 
GitLab