diff --git a/src/code_.py b/src/code_.py index fb3400143058bdf54d6c08c6f12c2609c4128864..c59e14d0359891c4d1719d9273c0c223845089c9 100644 --- a/src/code_.py +++ b/src/code_.py @@ -148,25 +148,32 @@ class Code: for match in re.finditer(pattern, code): connector = match.group(1) start_map, end = match.span(0) + new = f"¤{id(self)}_{index}¤" if(end_char=="{"): end_map = extract_curly(code, end) old = code[end:end_map-1] + new_code = f"{connector}{word}_modified {{ {new} }}" else: + new_code = f"{connector}{word}_modified ({new})" old = get_code_until_parenthese_count(code[end:], -1) end_map = end+len(old) old = old.strip()[:-1] - new = f"¤{id(self)}_{index}¤" - self.add_map_element(old, new) + + if(old[:-1].strip()!=''): + self.add_map_element(old, new) - old_code = code[start_map:end_map] - new_code = f"{connector}{word}_modified {{ {new} }}" - code = code.replace(old_code, new_code) + old_code = code[start_map:end_map] + + temp =code + code = code.replace(old_code, new_code) + if(old_code!=new_code and code==temp): + raise Exception("The code was no updated") - searching = True - index+=1 - break + searching = True + index+=1 + break #For reduce - for match in re.finditer(r"(\.|\|)\s*reduce[^{]+{", code): + for match in re.finditer(r"(\.|\|)\s*reduce\s+\{", code): connector = match.group(1) start_map, end = match.span(0) end_map = extract_curly(code, end) @@ -175,7 +182,10 @@ class Code: self.add_map_element(old, new) old_code = code[start_map:end_map] new_code = f"{connector}reduce_modified {{ {new} }}" + temp =code code = code.replace(old_code, new_code) + if(old_code!=new_code and code==temp): + raise Exception("The code was no updated") searching = True index+=1 break @@ -183,7 +193,6 @@ class Code: if(timeout>=constant.WHILE_UPPER_BOUND): raise BioFlowInsightError(f"The WHILE_UPPER_BOUND was exceeded. BioFlow-Insight was unable to extract the inside of a 'map' operator. Make sure the workflow uses correct Nextflow syntaxe (https://www.nextflow.io/docs/latest/index.html).", type="Unable to extract the inside of a 'map' operator") - return code def add_to_ternary_operation_dico(self, old, new): diff --git a/src/graph.py b/src/graph.py index 15930408acb990e3886195e4f2590091fcce4b09..6be771ce09be2957d0f6747148957634f4d49fa7 100644 --- a/src/graph.py +++ b/src/graph.py @@ -285,8 +285,8 @@ class Graph(): for sub in dico['subworkflows']: add_edges_flow_edges(dico["subworkflows"][sub], added_in_condition) - if(self.workflow.get_duplicate_status()): - #if(False):#Right now not generating the colored edges + #if(self.workflow.get_duplicate_status()): + if(False):#Right now not generating the colored edges checking_conditions = True most_influential_conditions = self.workflow.get_most_influential_conditions() list_most_influential_conditions = list(most_influential_conditions.keys()) diff --git a/src/outils.py b/src/outils.py index 6d23850a316cd3111b14b260f44c7fa410048a3e..a69da0eb919dced0f258fc756b1e1688d6427bed 100644 --- a/src/outils.py +++ b/src/outils.py @@ -1495,7 +1495,10 @@ def extract_tools(script, extract_general_tools = False): searching = False for match in re.finditer(r'\'', script): start, end = match.span(0) - end = extract_single_quote(script+"\n\n\n\n", start+1) + try: + end = extract_single_quote(script+"\n\n\n\n", start+1) + except: + break inside_single_quote = script[start:end] script = script.replace(inside_single_quote, "") searching = True @@ -1507,7 +1510,10 @@ def extract_tools(script, extract_general_tools = False): searching = False for match in re.finditer(r'\"', script): start, end = match.span(0) - end = extract_double_quote(script+"\n\n\n\n", start+1) + try: + end = extract_double_quote(script+"\n\n\n\n", start+1) + except: + break inside_double_quote = script[start:end] script = script.replace(inside_double_quote, "") searching = True diff --git a/src/workflow.py b/src/workflow.py index 878d5652d49339780ba15a59144952b39e6187d8..5a48035ffa6aa984d16fdf159d49af1501f5c7fa 100644 --- a/src/workflow.py +++ b/src/workflow.py @@ -680,8 +680,13 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen processes_called = self.get_processes_called() number_processes_called = len(processes_called) processes_2_tools = {} + print("Extracting the tools from the processes") + print('-'*len(processes_called)+">") for p in processes_called: + print('.', end='') processes_2_tools[p.get_code()] = p.get_tools() + print("\n") + print("Testing different combinations") print('-'*number_of_tries+">") for i in range(number_of_tries): print('.', end='') @@ -731,12 +736,12 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen if(len(cluster_organisation)>=reduction_alpha*number_processes_called and len(cluster_organisation)<=reduction_beta*number_processes_called and score<min_score): - print() - print("concordance", np.max(np.array(tab_nb_conditions_per_cluster)/np.array(tab_nb_executors_per_cluster)) ) - print("uniformity", (uniformity_variance / number_processes_called) ) - print("min_nb_clusters", (nb_clusters / number_processes_called) ) - print("min_nb_non_relevant_cluster", (nb_non_relevant_clusters / nb_clusters)) - print("score", score) + #print() + #print("concordance", np.max(np.array(tab_nb_conditions_per_cluster)/np.array(tab_nb_executors_per_cluster)) ) + #print("uniformity", (uniformity_variance / number_processes_called) ) + #print("min_nb_clusters", (nb_clusters / number_processes_called) ) + #print("min_nb_non_relevant_cluster", (nb_non_relevant_clusters / nb_clusters)) + #print("score", score) min_processes = random_relevant_processes min_score = score return min_processes @@ -1036,9 +1041,9 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen #code = code.replace(old, new) code = replace_group1(code, fr"({re.escape(old)})[^\w]", new) if(temp_code==code): - #print(code) - #print("old", f'"{old}"') - #print("new", f'"{new}"') + print(code) + print("old", f'"{old}"') + print("new", f'"{new}"') raise Exception("Something went wrong: The code hasn't changed") return code