diff --git a/src/call.py b/src/call.py index 7a1190928f19642b2b16be604bdbbc36284427d4..41bba12b1f9329966c5ad3d55c0a1d78c02b0f69 100644 --- a/src/call.py +++ b/src/call.py @@ -175,7 +175,6 @@ class Call(Executor): # channels = self.origin.get_channels_from_name_inside_level(param) #if(channels==[]): # channels = self.origin.get_channels_from_name_above_level(param) - # print(param, channels) #if(channels==[]): # channels = self.origin.get_channels_from_name_other_blocks_on_same_level(param) if(channels==[]): diff --git a/src/code_.py b/src/code_.py index b256be2915eecbdecc433ea37bdad9dd10d3838e..98417e078b06d01ba089d8651517ef78a458bbf9 100644 --- a/src/code_.py +++ b/src/code_.py @@ -1,4 +1,4 @@ -from .outils import remove_comments +from .outils import remove_comments, get_parenthese_count, get_curly_count from .bioflowinsighterror import BioFlowInsightError import re from . import constant @@ -46,7 +46,7 @@ class Code: #This methods rewrite ternary operation into "normal" conditions #variable = (condition) ? Expression2 : Expression3; def rewrite_ternary_operation_to_normal_condition(self, code): - pattern = r"(\w+) *\= *([\w][^?\n]+) *\? *([^:\n]+) *\: *([^\n]+)\n" + pattern = r"(\w+) *\= *([^?\n]+) *\? *([^:\n]+) *\: *([^\n]+)\n" to_replace = [] for match in re.finditer(pattern, code): variable = match.group(1) @@ -56,7 +56,9 @@ class Code: new = f"if ({condition}) {{\n{variable} = {exp1}\n}}\n\n" new += f"if (!({condition})) {{\n{variable} = {exp2}\n}}\n\n" #else {{\n{variable} = {exp2}\n}}\n" - to_replace.append((old, new)) + #Here we check that it's worked correctly -> that we have done a good parsing + if(get_parenthese_count(condition)==0 and get_parenthese_count(exp1)==0 and get_parenthese_count(exp2)==0 and get_curly_count(condition)==0 and get_curly_count(exp1)==0 and get_curly_count(exp2)==0): + to_replace.append((old, new)) for r in to_replace: old, new = r code = code.replace(old, new) diff --git a/src/workflow.py b/src/workflow.py index e4ecebc6e28a960e892fbbd3e8a63f43b69f3822..eea41a2cc0df329ebb384abdb19294f6050e4f12 100644 --- a/src/workflow.py +++ b/src/workflow.py @@ -59,7 +59,11 @@ class Workflow: 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 one to select") + #If there are multiple files and no main -> we just choose one at random + file = nextflow_files[0] + with open(file, 'r') as f: + txt= f.read() + #raise BioFlowInsightError("Multiple Nextflow files found at the root with no 'main.nf' file: I don't know which one to select")