from Bio import Entrez, SeqIO from Bio.Blast import NCBIWWW, NCBIXML Entrez.email = "ethan.white@usu.edu" #Download a sequence from GenBank gb_web_file = Entrez.efetch(db="nucleotide", id="281371607", rettype="gb") gb_record = SeqIO.read(gb_web_file, "genbank") print gb_record.annotations['accessions'] print gb_record.annotations['taxonomy'] print len(gb_record.seq) #Run BLASTs result_handle = NCBIWWW.qblast("blastn", "nr", "8332116") blast_record = NCBIXML.read(result_handle) E_VALUE_THRESH = 0.004 for alignment in blast_record.alignments: for hsp in alignment.hsps: if hsp.expect < E_VALUE_THRESH: print print '****Alignment****' print 'sequence:', alignment.title print 'length:', alignment.length print 'e value:', hsp.expect print hsp.query[0:75] + '...' print hsp.match[0:75] + '...' print hsp.sbjct[0:75] + '...'