Biopython - extracting query coverage from XML Blast output

I need to extract (or to calculate precisely) the query coverage from Blast output. I am using NCBIWWW.qblast to query Blast in XML format.

Is it possible to know the query coverage parsing the XML output? If yes, how?

result_handle_xml = NCBIWWW.qblast("blastp","pdb",my_query.seq,format_type='XML')


here it suggest to use '-6 qcovs', but only for BLAST command line version and only for tabular format

This is the fasta file that I open:

>sp|P02489|CRYAA_HUMAN Alpha-crystallin A chain OS=Homo sapiens
GN=CRYAA PE=1 SV=2
MDVTIQHPWFKRTLGPFYPSRLFDQFFGEGLFEYDLLPFLSSTISPYYRQSLFRTVLDSG
ISEVRSDRDKFVIFLDVKHFSPEDLTVKVQDDFVEIHGKHNERQDDHGYISREFHRRYRL

• Please edit your question and include an example of the file you are trying to parse. We can't really help you parse data you don't show. Dec 28 '17 at 10:30
• I see you edited, but you still haven't shown us the file you are trying to parse. Is the information even there? Please add an example so we know what you're working with. Dec 28 '17 at 16:55
• According to this, the answer is 'no'. Dec 28 '17 at 21:19

I had the same problem. I'm pretty sure you can calculate it yourself using the following:

1. The length of your sequence (seq_len)

2. The value from the <Hsp_query-from> tag from the hit (<Hsp_query-from>)

3. The value from the <Hsp_query-to> tag from the hit (<Hsp_query-to>)

It can be calculated by:

query_cover = (<Hsp_query-to> - <Hsp_query-from> + 1) / seq_len * 100


Please note that I did not get this from any documentation. I figured it out by staring at the xml output returned from the Biopython NCBIWWW.qblast() function. This solution seems to match with the results I get by blasting the same sequence on the interactive web portal.