[Biopython] help with NCBIXML.parse

ferreirafm at usp.br ferreirafm at usp.br
Wed Mar 28 08:54:44 EDT 2012


Hi there,
What I'm doing wrong in the following piece of code?
Thanks in advance,
Fred

#### CODE ####
def blast_cmd(query_seq):
     outf = open('blast_out.xml', 'w')
     for subj_seq in glob.iglob('emm*.fasta'):
         blast_cline = NcbiblastpCommandline(cmd = "blastp", task =  
"blastp-short",
                                             query = query_seq,  
subject = subj_seq,
                                             ungapped = True,  
comp_based_stats = "0",
                                             max_target_seqs = "1",  
matrix = "PAM30",
                                             outfmt = "5")
         stdout, stderr = blast_cline()
         outf.write(stdout)
     outf.close()
     handle = open("blast_out.xml")
     blast_records = NCBIXML.parse(handle)
     for record in blast_records:
         print record

#### RESULTS ####
$ run_blast.py --blast query.fasta
Traceback (most recent call last):
   File "/home/ferreirafm/bin/redundancy.py", line 121, in <module>
     main()
   File "/home/ferreirafm/bin/redundancy.py", line 106, in main
     blast_cmd(query_seq)
   File "/home/ferreirafm/bin/redundancy.py", line 63, in blast_cmd
     for record in blast_records:
   File "/usr/lib64/python2.7/site-packages/Bio/Blast/NCBIXML.py",  
line 652, in parse
     expat_parser.Parse(text, False)
xml.parsers.expat.ExpatError: junk after document element: line 88, column 14




More information about the Biopython mailing list