@@ -0,0 +1,1531 @@
+import os%0Aimport re%0Aimport sets%0Aimport glob%0Aimport logging%0Aimport MySQLdb%0Aimport library.genbank%0Alogging.basicConfig(level=logging.INFO)%0Afrom Bio import Entrez, SeqIO, SearchIO%0Afrom Bio.Blast import NCBIWWW, NCBIXML%0A%0A### A few import static variables%0Alibrary.genbank.email = 'me@my.address.com'    %0A%0Aprint %22%5Cn%5CnGetting a list of FASTA files...%22%0Afasta_files = glob.glob(%22fasta/*.FASTA%22) # get a list of all fasta files in /fasta%0Afile_count = len(fasta_files)%0Aprint %22%25s files successful found.%5Cn%22 %25file_count%0A%0Aprint %22WARNING:%5Cn%22%0Aprint %22There are %25s FASTA files to be processed.%22 %25file_count%0Aprint %22This process can take quite a long time.%5Cn%5Cn%22%0A%0Afor f in fasta_files:%0A%09print %22Reading original FASTA file %25s%22 %25f%5B7:%5D%0A%09with open (f, %22r%22) as fasta_file:%0A%09%09## parse input to get a clean file_id%0A%09%09sequences = fasta_file.read()%0A%09%09fasta_file.close()%0A%09%09print %22Done.%22%0A%0A%09%09print %22Starting BLASTN Search against %25s%22 %25f%5B7:%5D%0A%09%09print %22This may take awhile, and requires a presistant Internet connection...%22%0A%09%09## Blast using the FASTA set, and assing the XML string result to result_handle%0A%09%09result_handle = NCBIWWW.qblast(%22blastn%22, %22nt%22, sequences)%0A%09%09print %22Done.%22%0A%09%09print %22Writing results to a BLAST.XML file...%22%0A%09%09## write the XML string to a file for later parsing%0A%09%09blast_file_id = %22%22.join(%5B%22blast-temp/%22, f%5B7:-6%5D, %22.xml%22%5D)%0A%09%09save_result = open(blast_file_id, %22w%22)%0A%09%09save_result.write(result_handle.read())%0A%09%09save_result.close()%0A%09%09result_handle.close()%0A%09%09print %22Done.%22%0A%0A%0A%09print %22BLAST search successfully completed.%22%0A%0Aprint %22Process Complete.%22%0A%0A

Split the blast search functionality from the compare feature to compartmentalize time heavy features.