diff --git a/src/outils_annotate.py b/src/outils_annotate.py index 0f968a8e48a7254dc72ad44b6ba60c386eadab6d..810b78c28a4e220023232ee1384ac2353457b961 100644 --- a/src/outils_annotate.py +++ b/src/outils_annotate.py @@ -17,8 +17,8 @@ def get_propositions(process, tools = -1, commands = -1): #if(f"{tool}{character}" in process): temp.append(tool) if(commands!=-1): - for commands in commands: - tool, command = commands.split() + for c in commands: + tool, command = c.split() command = command.replace('+', '\+') for match in re.finditer(tool+r"\s+\-[^\s]+\s+"+command, process): temp.append(commands) @@ -70,7 +70,7 @@ def get_tools_commands_from_user_for_process(p, exiting_tools, existing_commands codes+=p.get_external_scripts_code() for c in codes: - print_colored_words(c, get_propositions(p, commands=existing_commands)+get_propositions(p, tools=exiting_tools)) + print_colored_words(c, get_propositions(c, commands=existing_commands)+get_propositions(c, tools=exiting_tools)) print("\nTOOLS") confirmation = 'a' while(confirmation!=""): @@ -89,113 +89,3 @@ def get_tools_commands_from_user_for_process(p, exiting_tools, existing_commands return tools_found, commands_found, exiting_tools, existing_commands - - -index = 0 -for process_id in process_2_annotations_pre_verification: - p = process_2_annotations_pre_verification[process_id]["process"] - try: - tmp = process_2_annotation[process_id] - except: - current_tools = process_2_annotations_pre_verification[process_id]["tools"] - current_commands = process_2_annotations_pre_verification[process_id]["commands"] - - print(f"\n* Current progess : {index/len(process_2_annotations_pre_verification)*100:.2f}% ({len(process_2_annotations_pre_verification)-index} left)") - print("--------------------------------------------------") - print_colored_words(p, current_commands+current_tools+get_propositions(p, commands=commands)+get_propositions(p, tools=tools)) - - validate_annoation = False - while(not validate_annoation): - print() - print_colored_words(f" - Current tools: {current_tools}", current_commands+current_tools) - print_colored_words(f" - Current commands: {current_commands}", current_commands+current_tools) - print() - annotation = input("Validate current annotations (press enter/ anykey otherwise):") - if(annotation==""): - validate_annoation = True - else: - print("\nTOOLS") - confirmation = 'a' - while(confirmation!=""): - propositions = get_propositions_from_user() - confirmation = input(f"Press 'ENTER' to validate this propostion of tools {propositions} (press any key otherwise) : ") - current_tools = propositions - print("\nCOMMANDS") - confirmation = 'a' - while(confirmation!=""): - propositions = get_propositions_from_user() - confirmation = input(f"Press 'ENTER' to validate this propostion of commands {propositions} (press any key otherwise) : ") - current_commands = propositions - - tools+=current_tools - commands+=current_commands - tools = list(set(tools)) - commands = list(set(commands)) - - ext_tools, ext_commands = [], [] - for ext in process_2_annotations_pre_verification[process_id]["external_scripts"]: - envs = ["env python", "env Rscript"] - show_it = True - for env in envs: - if(env in ext): - show_it = False - - if(show_it): - print("\n--------------------------------------------------") - propositions = get_propositions(ext, tools=tools) - print_colored_words(ext, propositions) - - print("\nTOOLS") - print_colored_words(f"Propositions are : {propositions}", propositions) - val = input("Press 'ENTER' to validate (press any key otherwise) : ") - if(val==''): - ext_tools+=propositions - else: - confirmation = 'a' - while(confirmation!=""): - propositions = get_propositions_from_user() - confirmation = input(f"Press 'ENTER' to validate this propostion of tools {propositions} (press any key otherwise) : ") - ext_tools+=propositions - - propositions = get_propositions(ext, commands=commands) - print_colored_words(ext, propositions) - print("\nCOMMANDS") - print_colored_words(f"Propositions are : {propositions}", propositions) - val = input("Press 'ENTER' to validate (press any key otherwise) : ") - if(val==''): - ext_commands+=propositions - else: - confirmation = 'a' - while(confirmation!=""): - propositions = get_propositions_from_user() - confirmation = input(f"Press 'ENTER' to validate this propostion of commands {propositions} (press any key otherwise) : ") - current_commands = propositions - ext_commands+=propositions - - current_tools+=ext_tools - current_commands+=ext_commands - current_tools = list(set(current_tools)) - current_commands = list(set(current_commands)) - - tools+=current_tools - commands+=current_commands - tools = list(set(tools)) - commands = list(set(commands)) - - process_2_annotation[process_id] = {} - process_2_annotation[process_id]['process'] = process_2_annotations_pre_verification[process_id]['process'] - process_2_annotation[process_id]['has_external_scripts'] = process_2_annotations_pre_verification[process_id]['has_external_scripts'] - process_2_annotation[process_id]['external_scripts'] = process_2_annotations_pre_verification[process_id]['external_scripts'] - process_2_annotation[process_id]['R_modules'] = process_2_annotations_pre_verification[process_id]['R_modules'] - process_2_annotation[process_id]['python_modules'] = process_2_annotations_pre_verification[process_id]['python_modules'] - process_2_annotation[process_id]['perl_modules'] = process_2_annotations_pre_verification[process_id]['perl_modules'] - process_2_annotation[process_id]['tools'] = current_tools - process_2_annotation[process_id]['commands'] = current_commands - - with open("process_2_annotation.json", "w") as outfile: - json.dump(process_2_annotation, outfile, indent=4) - - - index+=1 - - diff --git a/src/workflow.py b/src/workflow.py index 96bc4bbd22c19f73f24c66547e9336bae1152eee..3fa3c1fac4e23bd6c26db8b9489f3ee007725eec 100644 --- a/src/workflow.py +++ b/src/workflow.py @@ -49,7 +49,6 @@ class Workflow: processes_annotation = None, personnal_acces_token = None, processes_2_tools = None): - if(not os.path.isfile(file)): nextflow_files = glob.glob(f'{file}/*.nf') if(len(nextflow_files)==0): @@ -538,15 +537,23 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen self.nextflow_file.generate_user_view(relevant_processes = relevant_processes, render_graphs = render_graphs, processes_2_remove = tab_processes_2_remove) def build_processes_2_tools(self): + if(self.processes_2_tools==None): + print() + print("Let's extarct the tools from the processes") + print("------------------------------------------") + print() exiting_tools, existing_commands = [], [] - processes = self.get_processes_used() + processes = self.get_processes_called() dico = {} + index=0 for p in processes: + print(f"* {index/len(processes)*100:.2f}% ({index}) processes annotated") tools_found, commands_found, exiting_tools, existing_commands = get_tools_commands_from_user_for_process(p, exiting_tools, existing_commands) dico[p.get_code()] = {} dico[p.get_code()]["tools"] = tools_found dico[p.get_code()]["commands"] = commands_found + index+=1 self.processes_2_tools = dico with open(f"{self.get_output_dir()}/processes_2_tools.json", 'w') as output_file : json.dump(self.processes_2_tools, output_file, indent=2)