diff --git a/src/constant.py b/src/constant.py index c8a56f6f8d6c8c4270ae7c1be9d3ca1dfc2276a8..8b7ab2bc545e12f8aab1805d67b6c9515d46f6bf 100644 --- a/src/constant.py +++ b/src/constant.py @@ -124,7 +124,7 @@ END_PIPE_OPERATOR = r"\s*(\s*\|\s*\w+)+" # PROCESS #-------------------------- FILE = r'file +(\w+) *\n' -FROM = r'from([^\n]+)\n' +FROM = r' from ([^\n]+)\n' INPUT = r"\n\s*input *:" INTO = r'into +([\w, ]+)' INTO_2 = r'into +\(?( *\w+ *(, *\w+)*) *\)?' diff --git a/src/nextflow_building_blocks.py b/src/nextflow_building_blocks.py index 82a782269820625db1d8e5db1f37196df6c60c0d..af0bc0b307ee6839376a7c174f554f868e57e84e 100644 --- a/src/nextflow_building_blocks.py +++ b/src/nextflow_building_blocks.py @@ -348,8 +348,9 @@ class Nextflow_Building_Blocks: parenthese_left, parenthese_right = get_parenthese_count(text[:start]), get_parenthese_count(text[end:]) #if(curly_left==0 and curly_right==0 and parenthese_left==0 and parenthese_right==0 and (start, end) not in searched): - if(parenthese_left==0 and parenthese_right==0 and (start, end) not in searched): - searched.append((start, end)) + #if(parenthese_left==0 and parenthese_right==0 and (start, end, temp) not in searched): + if(parenthese_left==0 and parenthese_right==0): + try: pot = extract_executor_from_middle(text, start, end) @@ -361,37 +362,39 @@ class Nextflow_Building_Blocks: raise BioFlowInsightError(f"Failed to extract the operation or call{self.get_string_line(temp)}. Try rewriting it in a simplified version.", num = 11, origin=self) pot = expand_to_pipe_operators(text, pot) - - #If the thing which is extracted is not in the conditon of an if - if(not checks_in_condition_if(text, pot) and not checks_in_string(text, pot)): - if(self.get_DSL()=="DSL2"): - to_call = self.get_list_name_processes()+self.get_list_name_subworkflows()+self.get_list_name_includes() - if(pot.find("|")!=-1): - if(not checks_in_condition_if(pot, '|') and not checks_in_string(pot, '|')):#TODO checks_in_string is the first occurance - first_thing_called = pot.split('|')[-1].strip() - if(first_thing_called in to_call): - call = Call(code =pot, origin =self) - self.executors.append(call) - elif(first_thing_called in constant.LIST_OPERATORS): - ope = Operation(code =pot, origin =self) - self.executors.append(ope) + #IF the exact potential hasn't already been searched, then we don't do it + if((start, end, pot) not in searched): + searched.append((start, end, pot)) + #If the thing which is extracted is not in the conditon of an if + if(not checks_in_condition_if(text, pot) and not checks_in_string(text, pot)): + if(self.get_DSL()=="DSL2"): + to_call = self.get_list_name_processes()+self.get_list_name_subworkflows()+self.get_list_name_includes() + if(pot.find("|")!=-1): + if(not checks_in_condition_if(pot, '|') and not checks_in_string(pot, '|')):#TODO checks_in_string is the first occurance + first_thing_called = pot.split('|')[-1].strip() + if(first_thing_called in to_call): + call = Call(code =pot, origin =self) + self.executors.append(call) + elif(first_thing_called in constant.LIST_OPERATORS): + ope = Operation(code =pot, origin =self) + self.executors.append(ope) + else: + raise BioFlowInsightError(f"'{first_thing_called}' is neither a process, subworkflow or an operator. In the executor '{pot}'{self.get_string_line(pot)}.", num=14,origin=self)#TODO -> try rewriting the operation using the standard syntaxe + else: - raise BioFlowInsightError(f"'{first_thing_called}' is neither a process, subworkflow or an operator. In the executor '{pot}'{self.get_string_line(pot)}.", num=14,origin=self)#TODO -> try rewriting the operation using the standard syntaxe + from .executor import Executor + executor = Executor(pot, self) + self.executors.append(executor.return_type()) else: from .executor import Executor executor = Executor(pot, self) self.executors.append(executor.return_type()) - else: - from .executor import Executor - executor = Executor(pot, self) - self.executors.append(executor.return_type()) - else: - ope = Operation(pot, self) - self.executors.append(ope) - searching = True - break + ope = Operation(pot, self) + self.executors.append(ope) + searching = True + break #--------------------------------------------------------------- diff --git a/src/process.py b/src/process.py index 522a02afde4f967080aad36e1546fc9182a5a9ff..33122ac347103d381fa80bfce91e0c038c8190f9 100644 --- a/src/process.py +++ b/src/process.py @@ -585,12 +585,12 @@ class Process(Nextflow_Building_Blocks): lines.append(line) code = "\n".join(lines) #Removing the extra emits - #For it to only have one + #For it to only have one, for line in self.outputs_per_line: def replacer(match): - return "" + return match.group(1) for o in line[1:]: - code = re.sub(fr"\,\s*{re.escape(o.get_code())}", replacer, code) + code = re.sub(fr"\,\s*{re.escape(o.get_code())}(\s|\,|\))", replacer, code) return code