diff --git a/src/operation.py b/src/operation.py index 8927f0b8007d4f9b115e9d6fac21c0d4eac9c453..47a9fd3915028b1f4f9d8dc561616aec7b9d85ba 100644 --- a/src/operation.py +++ b/src/operation.py @@ -739,6 +739,13 @@ class Operation(Executor): def check_if_empty_call(self): return self.get_code()=="" + #This method returns the element which is defined after the call + def get_element_after_call(self, call): + for match in re.finditer(str(call)+r"\s*\.\s*(\w+)\s*\.", self.get_code()): + return match.group(1) + + + def initialise_from_call(self): @@ -806,7 +813,24 @@ class Operation(Executor): if(sub.get_nb_emit()==0): raise BioFlowInsightError(f"The subworkflow '{sub.get_name()}' doesn't emit anything. It is given to an operation{self.get_string_line(call.get_code())}.", num=20, origin=self) elif(sub.get_nb_emit()>1): - raise BioFlowInsightError(f"To much to unpack : The subworkflow '{sub.get_name()}' emits over one channel in a operation{self.get_string_line(call.get_code())}.", num=20, origin=self) + #In the case test().a.view() and test is a subworkflow + added = False + element_after_call = self.get_element_after_call(o) + emits = sub.get_emit() + for e in emits: + if(e.get_gives()==[]): + for o in e.get_origins(): + if(o.get_code()==element_after_call): + dico["edges"].append({'A':str(e), 'B':str(self), "label":e.get_code()}) + added =True + else: + for g in e.get_gives(): + if(g.get_code()==element_after_call): + dico["edges"].append({'A':str(e), 'B':str(self), "label":e.get_code()}) + added =True + + if(not added): + raise BioFlowInsightError(f"To much to unpack : The subworkflow '{sub.get_name()}' emits over one channel in a operation{self.get_string_line(call.get_code())}.", num=20, origin=self) #TODO recommendation -> try using an emit subworkflow.out else: emit = sub.get_emit()[0] diff --git a/src/process.py b/src/process.py index 12b3eea5ba2267967c1269837da08b6119f52bab..ef3d22233b8f77adad3512ebaedbe7b0210e922e 100644 --- a/src/process.py +++ b/src/process.py @@ -31,6 +31,9 @@ class Process(Nextflow_Building_Blocks): def get_alias(self): return self.alias + def get_script_code(self): + return self.script_code + def get_name(self): return self.name