Skip to content
Snippets Groups Projects
Commit 40ab502b authored by George Marchment's avatar George Marchment
Browse files

Added start most influential conditions + such a weird bug fixed with...

Added start most influential conditions + such a weird bug fixed with 'get_above_executors' -> when using a dictionnary -> some weird things stuff happens in memory (try woorkflow 17)
parent 65fac481
No related branches found
No related tags found
No related merge requests found
Pipeline #14351 failed with stage
in 2 minutes and 20 seconds
......@@ -13,6 +13,14 @@ class Block(Root):
def get_type(self):
return "Block"
#This method returns returns all the conditions above the block
#Basically everything which needs to be true for the block to exist
def get_all_conditions(self, conditions = {}):
conditions[self.condition] = ''
self.origin.get_all_conditions(conditions = conditions)
return conditions
def same_condition(self, block):
return self.condition.same_condition(block.condition)
......@@ -47,7 +55,8 @@ class Block(Root):
dico[e] = ''
self.origin.get_above_executors_rec(dico)
def get_above_executors(self, dico = {}):
def get_above_executors(self):
dico = {}
self.origin.get_above_executors_rec(dico)
return list(dico.keys())
......@@ -81,7 +90,7 @@ class Block(Root):
dico[c] = ''
self.origin.get_channels_above_level_rec(dico)
def get_channels_above_level(self, dico = {}):
def get_channels_above_level(self):
dico = {}
self.origin.get_channels_above_level_rec(dico)
return list(dico.keys())
......
......@@ -7,6 +7,9 @@ class Condition:
self.value = condition
#self.initialise()
def get_value(self):
return self.value
def same_condition(self, condition):
return self.value == condition.value
......@@ -74,6 +74,11 @@ class Executor(Nextflow_Building_Blocks):
return self.origin.get_channels_from_name_other_blocks_on_same_level(name)
def get_block(self):
if(self.origin.get_type() in ['Root', "Block"]):
return self.origin
else:
return self.origin.get_block()
#def get_channels(self):
......
......@@ -41,7 +41,10 @@ class Main(Nextflow_Building_Blocks):
def get_type(self):
return "Main"
def get_all_calls(self):
dico = {}
self.root.get_all_calls(calls = dico)
return list(dico.keys())
def check_includes(self):
......
......@@ -32,6 +32,7 @@ class Root(Nextflow_Building_Blocks):
def add_element_to_elements_being_called(self, element):
self.elements_being_called.append(element)
#Does this on the same level
def get_blocks_with_same_conditions(self, searching_block):
tab = []
for block in self.blocks:
......@@ -39,6 +40,11 @@ class Root(Nextflow_Building_Blocks):
if(block.same_condition(searching_block)):
tab.append(block)
return tab
#This method returns returns all the conditions above the block
#Basically everything which needs to be true for the block to exist
def get_all_conditions(self, conditions = {}):
return conditions
#############
......@@ -201,6 +207,15 @@ class Root(Nextflow_Building_Blocks):
def get_calls_from_other_blocks_on_same_level(self):
return []
def get_all_calls(self, calls = {}):
all_calls = self.get_calls_same_level()+self.get_calls_inside_level()
for call in all_calls:
for c in call.get_all_calls():
calls[c] = ''
if(c.get_first_element_called().get_type()=="Subworkflow"):
c.get_first_element_called().root.get_all_calls(calls = calls)
......
......@@ -176,4 +176,39 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen
self.graph.initialise(processes_2_remove = self.processes_2_remove)
self.graph.get_specification_graph(render_graphs = render_graphs)
#Returns a dico of number of processes called per each condition
#For example : {condition1: 14, condition2: 10, condition:3}
#14 process calls depend on condition1
#10 process calls depend on condition2
#3 process calls depend on condition3
def get_most_influential_conditions(self, show_values = True):
most_influential_conditions = {}
if(self.get_duplicate_status()):
all_calls = self.get_workflow_main().get_all_calls()
for c in all_calls:
if(c.get_first_element_called().get_type()=="Process"):
for condition in c.get_block().get_all_conditions(conditions = {}):
try:
temp = most_influential_conditions[condition]
except:
most_influential_conditions[condition] = 0
most_influential_conditions[condition]+=1
#If show values then we replace the the conditions ids with their values
if(show_values):
most_influential_conditions_values = {}
for condition in most_influential_conditions:
try:
t = most_influential_conditions_values[condition.get_value()]
except:
most_influential_conditions_values[condition.get_value()] = 0
most_influential_conditions_values[condition.get_value()] += most_influential_conditions[condition]
most_influential_conditions = most_influential_conditions_values
#Sort the dico
most_influential_conditions = {k: v for k, v in sorted(most_influential_conditions.items(), key=lambda item: item[1], reverse=True)}
return most_influential_conditions
else:
BioFlowInsightError("Need to activate 'duplicate' mode to use this method.")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment