Question: How to parse NCBI Blast XML to retrieve "hsp_query-from in Biopython?
gravatar for philipp
4.1 years ago by
philipp10 wrote:


I have a question concerning parsng NCBI BLAST XML outputs. I can parse the hsp score of the BLAST results. Unfortunately, I face difficulties parsing other entries in the XML.

I need to parse hsp_query-from, hsp_query-to, hsp_align-len, and hsp_identity.

This code works:

    for record in NCBIXML.parse(result_handle):
    for alignment in record.alignments:
        for hsp in alignment.hsps:
            hsp_score = hsp.score

How can I get the other entries? Especially hsp_query-from seems to be tricky because "from" is reserved by python.

I appreciate your help a lot!

Best, Philipp

biopython parse xml • 2.0k views
ADD COMMENTlink modified 4.1 years ago by Markus300 • written 4.1 years ago by philipp10
gravatar for Markus
4.1 years ago by
Markus300 wrote:
  • hsp_query-from: hsp.query_start
  • hsp_query-to: hsp.query_end
  • hsp_align-len: hsp.align_length
  • hsp_identity: hsp.identities

You can lookup the keywords in the source code of the NCBIXML parser at to find the respective parameters.

ADD COMMENTlink written 4.1 years ago by Markus300
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1394 users visited in the last hour