result_handle = open("ali.xml") from Bio.Blast import NCBIXML blast_records = NCBIXML.parse(result_handle) E_VALUE_THRESH = 0.01 for blast_record in blast_records: for alignment in blast_record.alignments: for hsp in alignment.hsps: if hsp.expect < E_VALUE_THRESH: 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] + '...' print hsp.score