From 14e6ee30e2e476966158e60d7ee9a2199790bf50 Mon Sep 17 00:00:00 2001
From: George Marchment <georgemarchment@yahoo.fr>
Date: Thu, 20 Mar 2025 11:52:03 +0100
Subject: [PATCH] Updated the identification of the scripts within a process +
 added a merge operator

---
 src/constant.py |  4 ++--
 src/process.py  | 10 ++++++++++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/constant.py b/src/constant.py
index b672359..e1e55a5 100644
--- a/src/constant.py
+++ b/src/constant.py
@@ -109,7 +109,7 @@ DOUBLE_DOT_TUPLE = r"\(\s*\w+\s*(,\s*\w+\s*)+\)\s*=\s*([^\?\n]+)\s*\?([^\n]+)"
 END_OPERATOR = r' *(\(|{)'
 ILLEGAL_CHARCTER_BEFORE_POTENTIAL_CHANNELS = r"\w|\'|\"|\."
 ILLEGAL_CHARCTER_AFTER_POTENTIAL_CHANNELS = r"\w"
-MERGE_OPERATIONS = r'\.\s*((merge|mix|concat|spread|join|phase|cross|combine|fromList|collect|fromPath|value|from|map)\s*(\(|\{))'#I've added map to this list cause channels can appear in map can concatenating channels -> it's a strange way of doing it
+MERGE_OPERATIONS = r'\.\s*((merge|mix|concat|spread|join|phase|cross|combine|fromList|collect|fromPath|value|from|map|fromFilePairs)\s*(\(|\{))'#I've added map to this list cause channels can appear in map can concatenating channels -> it's a strange way of doing it
 OPERATOR_IN_PIPE = r"\w+ *{[^}]*}|\w+ *\([^\)]*\)|\w+"
 SET_OPERATORS = ["choice", "separate", "tap", "into", "set"]
 TUPLE_EQUALS = r'\( *\w+( *, *\w+)+ *\) *=\s*(\w+)\s*\.'
@@ -131,7 +131,7 @@ INTO = r'into +([\w, ]+)'
 INTO_2 = r'into +\(?( *\w+ *(, *\w+)*) *\)?'
 OUTPUT = r"\n\s*output *:"
 PROCESS_HEADER = r'process\s+(\w+|\'[\w ]+\'|\"[\w ]+\")\s*{'
-SCRIPT = r"\n\s*script *:|shell *:|exec *:|\"\"\"|\'\'\'"
+SCRIPT = r"\n\s*script *:|shell *:|exec *:|\"\"\"\s|\'\'\'\s"
 WHEN = r"\n\s*when *:"
 
 
diff --git a/src/process.py b/src/process.py
index c791e70..07ff0b1 100644
--- a/src/process.py
+++ b/src/process.py
@@ -419,6 +419,8 @@ class Process(Nextflow_Building_Blocks):
             self.name = match.group(1)
             self.name = self.name.replace("'", "")
             self.name = self.name.replace('"', '')
+            if(self.name=="process"):
+                raise Exception("Process is names 'process'")
             if(self.alias==""):
                self.alias = self.name
             self.printed_name = self.alias
@@ -512,9 +514,17 @@ class Process(Nextflow_Building_Blocks):
             code = self.get_code()
             call = [f"{self.get_name()}({self.get_parameters_call()})"]
             if(self.input_code!=""):
+                temp = code
                 code = code.replace(self.input_code, self.convert_input_code_to_DSL2())
+                if(temp==code):
+                    raise Exception("This souldn't happen")
             if(self.output_code!=""):
+                temp = code
                 code = code.replace(self.output_code, self.convert_output_code_to_DSL2())
+                if(temp==code):
+                    print(f'"{self.output_code}"')
+                    print(f'"{self.convert_output_code_to_DSL2()}"')
+                    raise Exception("This souldn't happen")
             channels_to_flatten = self.get_channels_to_flatten()
  
 
-- 
GitLab