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

Add method to automatically generate random relevant processes

parent a9d6be89
No related branches found
No related tags found
No related merge requests found
Pipeline #14308 failed with stage
in 2 minutes and 45 seconds
...@@ -879,6 +879,38 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen ...@@ -879,6 +879,38 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen
self.__init__(str(temp_file), display_info = False, duplicate=True) self.__init__(str(temp_file), display_info = False, duplicate=True)
self.initialise(create_rocrate=False) self.initialise(create_rocrate=False)
def generate_random_relevant_processes(self, alpha = -1):
import random
#Random value between 0 and 1, centered at 0.5
def get_value():
check = True
val = -1
while(check):
check = False
val = random.gauss(0.5, 0.1)
if(val<0 or val>1):
check = True
return val
if(self.duplicate):
if(alpha == -1):
alpha = get_value()
else:
if(0<=alpha and alpha<=1):
None
else:
raise BioFlowInsightError("alpha is not in the interval [0; 1]")
processes_called = self.get_processes_called()
nb_2_select = int(alpha*len(processes_called))
sampled = random.sample(set(processes_called), nb_2_select)
name_select = []
for p in sampled:
name_select.append(p.get_alias())
return name_select
else:
raise BioFlowInsightError("Trying to generate random relevant processes however option 'duplicate' is not activated.")
#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 #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
...@@ -948,7 +980,6 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen ...@@ -948,7 +980,6 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen
return broken_subworkflows return broken_subworkflows
broken_subworkflows = get_workflows_broken(subworkflow_2_executors, set_clusters_with_calls) broken_subworkflows = get_workflows_broken(subworkflow_2_executors, set_clusters_with_calls)
print(broken_subworkflows)
#Rewrite broken subworkflows #Rewrite broken subworkflows
for sub in broken_subworkflows: for sub in broken_subworkflows:
code = self.rewrite_subworkflow_call(code, sub) code = self.rewrite_subworkflow_call(code, sub)
...@@ -1195,7 +1226,7 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen ...@@ -1195,7 +1226,7 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen
#Putting || back #Putting || back
code = code.replace("$OR$", "||") code = code.replace("$OR$", "||")
print(remove_extra_jumps(format_with_tabs(code))) return remove_extra_jumps(format_with_tabs(code))
#So basically when retriving a thing (process or subworkflow) #So basically when retriving a thing (process or subworkflow)
......
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