How to parse xml file with many xml BLAST outputs pasted into one file one by one Python. I pasted each blast output into one xml file. They are seperated with:
<?xml version="1.0"?>
<!DOCTYPE BlastOutput PUBLIC "-//NCBI//NCBI BlastOutput/EN"
"http://www.ncbi.nlm.nih.gov/dtd/NCBI_BlastOutput.dtd">
And each blast output starts with a root:
<BlastOutput>
My code that parse only the first blast result:
with open(xml, 'r') as out_handle:
blast_records = NCBIXML.parse(out_handle)
blast_record = next(blast_records)
eval_tresh = 0.04
for alignment in blast_record.alignments:
for hsp in alignment.hsps:
if hsp.expect < eval_tresh:
print('***Alignment***')
print('Sequence:', alignment.title)
# print('Length:', alignment.length)
# print('E value:', hsp.expect)
Does anyone know how I could parse those blast results one by one with bio.python?