diff --git a/src/block.py b/src/block.py index 8287f90be843a5d08a3745a951983d552351d0dd..77bb9c95ad5fe36cb611e3dbe23fcce1de5cb5a7 100644 --- a/src/block.py +++ b/src/block.py @@ -88,7 +88,7 @@ class Block(Root): ############# # CHANNELS ############# - def get_channels_above_level_rec(self, dico = {}): + def get_channels_above_level_rec(self, dico): for c in self.channels: dico[c] = '' self.origin.get_channels_above_level_rec(dico) @@ -107,6 +107,9 @@ class Block(Root): tab+=block.get_channels_same_level() tab+=block.get_channels_inside_level() return tab + + def get_channels_from_name_all_channels(self, name): + return self.origin.get_channels_from_name_all_channels(name) #def check_in_channels(self, channel): # for c in self.get_channels(): diff --git a/src/call.py b/src/call.py index d885469b740024c10f3ab845705db964b1bd1c63..19fdfc452d2b338ad1019a1b4adc427d957c4e5f 100644 --- a/src/call.py +++ b/src/call.py @@ -157,7 +157,7 @@ class Call(Executor): #Case it's a channel if(re.fullmatch(constant.WORD, param) and not analysed_param): #if(re.fullmatch(constant.WORD, param) and not analysed_param or param in ['[]'] or param[:7]=="params."): - + #TODO this needs to be updated to proper formalise how you search for channels channels = self.origin.get_channels_from_name_same_level(param) if(channels==[]): channels = self.origin.get_channels_from_name_inside_level(param) @@ -165,6 +165,8 @@ class Call(Executor): channels = self.origin.get_channels_from_name_above_level(param) if(channels==[]): channels = self.origin.get_channels_from_name_other_blocks_on_same_level(param) + if(channels==[]): + channels = self.origin.get_channels_from_name_all_channels(param) if(channels==[]): from .channel import Channel channel = Channel(name=param, origin=self.origin) diff --git a/src/executor.py b/src/executor.py index 5bcb33ab94d1cf891829877cfc5b79fdd9fad0a2..985c15e45e5543075bea02324af1b7832c9d3186 100644 --- a/src/executor.py +++ b/src/executor.py @@ -78,6 +78,10 @@ class Executor(Nextflow_Building_Blocks): def get_channels_from_name_above_level(self, name): return self.origin.get_channels_from_name_above_level(name) + def get_channels_from_name_all_channels(self, name): + return self.origin.get_channels_from_name_all_channels(name) + + def get_channels_from_name_other_blocks_on_same_level(self, name): return self.origin.get_channels_from_name_other_blocks_on_same_level(name) diff --git a/src/root.py b/src/root.py index 763f8aa31f0422c1c7174ed962d48bbb6a170bf8..85d37088d74a28eb438909990d7acddbcdeefce0 100644 --- a/src/root.py +++ b/src/root.py @@ -107,6 +107,14 @@ class Root(Nextflow_Building_Blocks): if(c.get_name()==name): tab.append(c) return tab + + def get_channels_from_name_all_channels(self, name): + channels = self.get_channels_same_level()+self.get_channels_inside_level() + tab = [] + for c in channels: + if(c.get_name()==name): + tab.append(c) + return tab diff --git a/src/workflow.py b/src/workflow.py index 24b72fc597aad8c53219033250cac034bfc6cb8c..e6e82262a44f9f7c799f8aace201a42c598019b9 100644 --- a/src/workflow.py +++ b/src/workflow.py @@ -382,10 +382,13 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen raise BioFlowInsightError("alpha is not in the interval [0; 1]") processes_called = [] - for c in self.get_workflow_main().get_all_calls_in_workflow(): - p = c.get_first_element_called() - if(p.get_type()=="Process"): - processes_called.append(p) + if(self.get_DSL()=="DSL2"): + for c in self.get_workflow_main().get_all_calls_in_workflow(): + p = c.get_first_element_called() + if(p.get_type()=="Process"): + processes_called.append(p) + else: + processes_called = self.get_first_file().get_processes() nb_2_select = int(alpha*len(processes_called)) sampled = random.sample(set(processes_called), nb_2_select) name_select = [] @@ -636,6 +639,10 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen #Method which rewrites the workflow follwong the user view #Conert workflow to user_view only makes sense when the option duplicate is activated -> otherwise is doesn't make sense + it makes the analysis way more complicated def convert_workflow_2_user_view(self, relevant_processes = []): + if(self.get_DSL()=="DSL1"): + code = self.convert_to_DSL2() + self.rewrite_and_initialise(code) + if(self.duplicate): code = self.simplify_workflow_code() self.rewrite_and_initialise(code) @@ -709,8 +716,7 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen #Get the clusters and the code self.generate_user_view(relevant_processes = relevant_processes, processes_2_remove = []) clusters = self.graph.get_clusters_from_user_view() - - + #Get the clsuters with the corresponding operations inside #for i in range(len(clusters)): # c = clusters[i] @@ -935,7 +941,7 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen #Add anker subworkflow_section = f"//ANKER 4 SUBWORKFLOW DEF" to_replace = "" - for match in re.finditer(r"workflow\s+\w*\s*\{", code): + for match in re.finditer(r"workflow\s*\w*\s*\{", code): to_replace = match.group(0) break if(to_replace==""):