From 1990a8a27a405d34cf2f309d4eac217bea8fd07f Mon Sep 17 00:00:00 2001
From: George Marchment <georgemarchment@yahoo.fr>
Date: Fri, 7 Feb 2025 12:28:04 +0100
Subject: [PATCH] continued debugging a frw things

---
 src/call.py      |  4 ++++
 src/include.py   | 17 +++++++++++------
 src/main.py      |  3 +++
 src/operation.py |  2 ++
 src/process.py   |  3 ++-
 src/workflow.py  | 10 +++++++++-
 6 files changed, 31 insertions(+), 8 deletions(-)

diff --git a/src/call.py b/src/call.py
index ea7f061..abdd3ba 100644
--- a/src/call.py
+++ b/src/call.py
@@ -388,14 +388,18 @@ class Call(Executor):
             if(process!=None and subworkflow==None and fun==None):
                 #If the elements need to duplicated -> then we need to duplicate it
                 if(self.get_duplicate_status()):
+                    temp = process
                     process = process.copy()
+                    process.set_alias(temp.get_alias())
                 process.initialise()
                 self.first_element_called = process
                 self.origin.add_element_to_elements_being_called(process)
                 #temp.incremente_number_times_called()
             if(process==None and subworkflow!=None and fun==None):
                 if(self.get_duplicate_status()):
+                    temp = subworkflow
                     subworkflow = subworkflow.copy()
+                    subworkflow.set_alias(subworkflow.get_alias())
                 subworkflow.initialise()
                 self.first_element_called = subworkflow
                 self.origin.add_element_to_elements_being_called(subworkflow)
diff --git a/src/include.py b/src/include.py
index 4a92090..5e41903 100644
--- a/src/include.py
+++ b/src/include.py
@@ -29,6 +29,11 @@ class Include(Nextflow_Building_Blocks):
         self.defines = {}
         #self.initialise()
 
+    def get_string_line(self, bit_of_code):
+        return self.nextflow_file_origin.get_string_line(bit_of_code)
+    
+    def get_file_address(self):
+        return self.nextflow_file_origin.get_file_address()
 
     def get_duplicate_status(self):
         return self.nextflow_file_origin.get_duplicate_status()
@@ -111,12 +116,12 @@ class Include(Nextflow_Building_Blocks):
                     pattern_as = constant.INCLUDE_AS
                     for match in re.finditer(pattern_as, include):
                         found = True
-                        if(self.get_duplicate_status()):
-                            thing_as = self.nextflow_file.get_element_from_name(match.group(1)).copy()
-                            thing_as.set_alias(match.group(3))
-                            self.defines[match.group(3)] = thing_as
-                        else:
-                            self.defines[match.group(3)] = self.nextflow_file.get_element_from_name(match.group(1))
+                        #if(self.get_duplicate_status()):
+                        thing_as = self.nextflow_file.get_element_from_name(match.group(1)).copy()
+                        thing_as.set_alias(match.group(3))
+                        self.defines[match.group(3)] = thing_as
+                        #else:
+                        #    self.defines[match.group(3)] = self.nextflow_file.get_element_from_name(match.group(1))
                 
                 if(not found):
                     raise Exception(f"I was not able to import '{include}' from {self.nextflow_file.get_file_address()}")
diff --git a/src/main.py b/src/main.py
index 522bde7..f108590 100644
--- a/src/main.py
+++ b/src/main.py
@@ -17,6 +17,9 @@ class Main(Nextflow_Building_Blocks):
 
     def get_string_line(self, bit_of_code):
         return self.nextflow_file.get_string_line(bit_of_code)
+    
+    #def check_in_channels(self, channel):
+    #    return self.root.check_in_channels(channel)
 
     def get_modules_defined(self):
         return self.nextflow_file.get_modules_defined()
diff --git a/src/operation.py b/src/operation.py
index 0cbb3a5..b5add76 100644
--- a/src/operation.py
+++ b/src/operation.py
@@ -195,7 +195,9 @@ class Operation(Executor):
             raise Exception("This shoudn't happen! -> a call is taking a value")
         
         else:
+            print("here")
             channel = Channel(name=name, origin=self.origin)
+            print(self.get_code(), name, self.get_file_address())
             if(not self.origin.check_in_channels(channel)):
                 self.origin.add_channel(channel)
             else:
diff --git a/src/process.py b/src/process.py
index 6372e46..d65edfa 100644
--- a/src/process.py
+++ b/src/process.py
@@ -366,7 +366,8 @@ class Process(Nextflow_Building_Blocks):
             self.name = match.group(1)
             self.name = self.name.replace("'", "")
             self.name = self.name.replace('"', '')
-            self.alias = self.name
+            if(self.alias==""):
+               self.alias = self.name
             self.printed_name = self.name
 
     def get_name_to_print(self):
diff --git a/src/workflow.py b/src/workflow.py
index 0070f2b..5faf0d6 100644
--- a/src/workflow.py
+++ b/src/workflow.py
@@ -49,7 +49,15 @@ class Workflow:
                 with open(file, 'r') as f:
                     txt= f.read()
             except:
-                raise BioFlowInsightError("No 'main.nf' file found at the root of the prohject")
+                None
+                #raise BioFlowInsightError("No 'main.nf' file found at the root of the prohject")
+            if(len(nextflow_files)==1):
+                file = nextflow_files[0]
+                with open(file, 'r') as f:
+                    txt= f.read()
+            else:
+                raise BioFlowInsightError("Multiple Nextflow files found at the root with no 'main.nf' file: I don't know which want to select")
+
 
         
         self.duplicate = duplicate
-- 
GitLab