diff --git a/src/workflow.py b/src/workflow.py index b9ae98f8818db9f4a97ef89f9b2b434cfdc2fd07..570f00561a28e6d56114a719ab31ba029b3d1f1d 100644 --- a/src/workflow.py +++ b/src/workflow.py @@ -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.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 @@ -948,7 +980,6 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen return broken_subworkflows broken_subworkflows = get_workflows_broken(subworkflow_2_executors, set_clusters_with_calls) - print(broken_subworkflows) #Rewrite broken subworkflows for sub in broken_subworkflows: code = self.rewrite_subworkflow_call(code, sub) @@ -1195,7 +1226,7 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen #Putting || back 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)