Search code examples
pythonxmlblast

parsing BLAST.xml with python-format required lower case string


Returns value error: Format required (lower case string) for line 25 in get_processor for searchIO_utils.py.
AtCBL1_CDS.txt is a file containing a protein sequence in fasta format.
I would like to know how to correctly access my BLAST output.

from Bio.Blast import NCBIWWW
from Bio.Blast import NCBIXML
from Bio import SearchIO
#open query file as fasta_file
fasta_file= open("AtCBL1_CDS.txt").read()

#set up blast parameters
result = NCBIWWW.qblast ("blastp", "prot", fasta_file)


#run and create my_blast as output file
with open("my_blast.xml", "w") as out_handle:
    out_handle.write(result.read())

#close file
result.close()
out_handle.close()

result_handle=open("my_blast.xml")

blastp_result=SearchIO.read(result_handle)
print(blastp_result)

Solution

  • The second parameter to SearchIO.read should be a lowercase format parameter:

    • format - lower case string denoting one of the supported formats. For instance blast-xml for XML blast format.

    In your case the line should read:

    blastp_result=SearchIO.read(result_handle,'blast-xml')