I have written the script to run locally the needle program for a query against the subject files. It returns the highest percentage result file as a string. In addition it also converts to html file (write_html function).
Can you help me to improve the script?
subject_path = settings.MEDIA_ROOT+"subject_files/" query_path = settings.MEDIA_ROOT+"query_file/" def run_bug(): """The script runs the needle program for a query file against all the subject files in a folder and keeps only the highest identity score alignments. """ query_list_fastafiles, subject_list_fastafiles = start_function() files_ending_with_one = filter_files_ending_with_one(subject_list_fastafiles) for j in range(len(query_list_fastafiles)): initial = 0 needle_alignment_result = '' #take the scaffold sequence one by one for i in range(len(files_ending_with_one)): #path of the files file1 = query_path+ordered_query_fastafiles[j] file1 = subject_path+files[i] needle_output = run_needle_two_sequences(file1, file2) if needle_output == None: return needle_alignment_result = needle_output else: #print(ordered_query_fastafiles[j],ordered_scaffold_fastafiles[i]) identity_percentage, result_file_as_string = needle_output #print(identity_percentage, results) identity_percentage = float(identity_percentage) if identity_percentage > initial: #keeps the highest percentage result among the files initial = identity_percentage needle_alignment_result = result_file_as_string write_html(needle_alignment_result) return needle_alignment_result