diff --git a/src/operation.py b/src/operation.py index 37c20af95edfb3d162860a48c1843eb6211a5865..bd5a006a6071267e255f87b4ad16b234029011c9 100644 --- a/src/operation.py +++ b/src/operation.py @@ -28,6 +28,7 @@ class Operation(Executor): self.operation_type = None #Artificial means that it is created by the analysis -> it is not native in the code self.artificial = False + self.create_loop_with_call = False #It's important this is last #self.condition = Condition(self) @@ -42,6 +43,8 @@ class Operation(Executor): return self.artificial + def get_create_loop_with_call_status(self): + return self.create_loop_with_call def add_element_gives(self, ele): self.gives.append(ele) @@ -815,6 +818,21 @@ class Operation(Executor): else: return False + #This method is to flag cases of ch = call(ch) or call(ch)\n ch = emit.call.out + def check_that_operation_does_not_create_loop_with_call(self): + for o in self.origins: + if(o.get_type()=='Call' or o.get_type()=='Emitted'): + if(o.get_type()=='Emitted'): + call = o.emitted_by + else: + call = o + for param in call.get_parameters(): + for g in self.gives: + if(g.get_code(get_OG = True)==param.get_code(get_OG = True)): + self.create_loop_with_call = True + + + def initialise(self): #If the operation is a double dot consition thing if(self.check_if_double_dot()): @@ -825,6 +843,7 @@ class Operation(Executor): self.extract_calls() self.initialise_origins() self.initialise_gives() + self.check_that_operation_does_not_create_loop_with_call() self.write_summary(self.get_output_dir() / "debug/operations.nf") diff --git a/src/outils.py b/src/outils.py index 83b420f68c8f09e53117fd22aa7c26612250c7a5..1cb91902626cde87f5f896faf078c038d34c438f 100644 --- a/src/outils.py +++ b/src/outils.py @@ -1355,7 +1355,9 @@ def get_channels_to_add_in_false_conditions(body, emitted_channels): #For the remaining condition in the list -> need to create an empty channel in the case of the negation for condition in channels_2_conditions[channel]: condition = condition.split("$$__$$")[0] - body += f"\nif(!({condition})) {{\n{channel} = Channel.empty()\n}}" + #TODO -> check this doesn't fuck anything up -> see number 75 + #Originally it is not commented + #body += f"\nif(!({condition})) {{\n{channel} = Channel.empty()\n}}" return body diff --git a/src/workflow.py b/src/workflow.py index 27a2fd963a681383ef1f24269769298b22220c61..3aacb389ea5341688586f2f214e98c1c7f527673 100644 --- a/src/workflow.py +++ b/src/workflow.py @@ -1081,6 +1081,8 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen tab = [] for ele in c: if(ele.get_type()=="Operation"): + if(ele.get_create_loop_with_call_status()): + raise BioFlowInsightError(f'BioFlow-Insight cannot rewrite the workflows since the operation "{ele.get_code(get_OG = True)}" creates the channel on which it depends.', type="Rewrite Error") if(ele.get_artificial_status()==False): tab.append(ele) else: