Question: Parsing Standalone Blast XML Output with Biopython on Linux
gravatar for maximilian.mayerhofer
2.1 years ago by
maximilian.mayerhofer20 wrote:


I want to parse my blast XML results and extract a few things and put them into a new multifasta file as following:

. >[alignment.title][hsp.expect][align_length][hsp.sbjct]

from Bio.Blast import NCBIXML
results=open('./results.xml', 'r' )

save_file = open("./presults.fasta", "w")

for blast_record in records:
        for alignment in blast_record.alignments:
                for hsp in alignment.hsps:
                        save_file.write('>%s\n' % (alignment.title, hsp.expect, align_length, hsp.sbjct))

But thats the error I get.

  File "", line 10, in <module>
    save_file.write('>%s\n' % (alignment.title, hsp.expect, hsp.sbjct))
TypeError: not all arguments converted during string formatting

It is important that I get the complete subject sequences out of this.

Best regards

blast biopython parse xml • 1.2k views
ADD COMMENTlink modified 2.1 years ago by Pierre Lindenbaum127k • written 2.1 years ago by maximilian.mayerhofer20
gravatar for Pierre Lindenbaum
2.1 years ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum127k wrote:



there is only one palceholder '%s' while there are 4 arguments.

ADD COMMENTlink written 2.1 years ago by Pierre Lindenbaum127k

Ok, I see that. But how do I get this to work?

EDIT:nevermind. I got it.

ADD REPLYlink modified 2.1 years ago • written 2.1 years ago by maximilian.mayerhofer20
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: 2098 users visited in the last hour