From 2c38cd8f39f7cfe7fc287b7199fd7cc44d665a1e Mon Sep 17 00:00:00 2001 From: George Marchment <georgemarchment@yahoo.fr> Date: Wed, 19 Mar 2025 14:00:35 +0100 Subject: [PATCH] small update to DSL1 to DSL2 conversion --- src/process.py | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/src/process.py b/src/process.py index d81cd61..c791e70 100644 --- a/src/process.py +++ b/src/process.py @@ -261,6 +261,7 @@ class Process(Nextflow_Building_Blocks): for line in code.split("\n"): + placed = False #Case there is a single channel as an input -> doesn't use from to import channel -> uses file (see https://github.com/nextflow-io/nextflow/blob/45ceadbdba90b0b7a42a542a9fc241fb04e3719d/docs/process.rst) patterns = [constant.FILE, constant.PATH] @@ -271,25 +272,30 @@ class Process(Nextflow_Building_Blocks): extracted = match.group(1).strip() except: extracted = match.group(2).strip() - + placed = True add_channel(extracted) self.raw_input_names.append(extracted) - - #Case there are multiple channels as input (e.g. channel1.mix(channel2)) - pattern = constant.FROM - for match in re.finditer(pattern, line+"\n"): - extracted = match.group(1).strip() - self.raw_input_names.append(extracted) - - if(bool(re.fullmatch(constant.WORD, extracted))): - add_channel(extracted) - else: - from .operation import Operation - operation = Operation(code=extracted, origin=self.origin) - operation.initialise() - operation.is_defined_in_process(self) - self.inputs+=operation.get_origins() + if(not placed): + #Case there are multiple channels as input (e.g. channel1.mix(channel2)) + pattern = constant.FROM + for match in re.finditer(pattern, line+"\n"): + extracted = match.group(1).strip() + self.raw_input_names.append(extracted) + placed = True + if(bool(re.fullmatch(constant.WORD, extracted))): + add_channel(extracted) + else: + from .operation import Operation + operation = Operation(code=extracted, origin=self.origin) + operation.initialise() + operation.is_defined_in_process(self) + self.inputs+=operation.get_origins() + + if(not placed): + if(re.fullmatch(constant.WORD, line.strip())): + add_channel(line) + self.raw_input_names.append(line) #self.inputs = list(set(self.inputs))#TODO Check this @@ -453,6 +459,7 @@ class Process(Nextflow_Building_Blocks): for line in code.split("\n"): temp = process_2_DSL2(line.split(" from ")[0]) lines.append(temp) + #TODO -> need to determine if it's on it's own is it either a path or val code = "\n".join(lines) return code -- GitLab