Skip to content

Instantly share code, notes, and snippets.

@bow
Created May 20, 2012 20:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bow/2759448 to your computer and use it in GitHub Desktop.
Save bow/2759448 to your computer and use it in GitHub Desktop.
Quick script to compare SearchIO and NCBIXML blast xml parser performance
#!/usr/bin/env python
# quick script to compare SearchIO and NCBIXML blast xml parser performance
searchio="""
from Bio import SearchIO
for result in SearchIO.parse('%s', 'blast-xml'):
query_id = result.id
"""
ncbixml="""
from Bio.Blast import NCBIXML
with open('%s', 'r') as xmlfile:
for result in NCBIXML.parse(xmlfile):
query_id = result.query_id
"""
import timeit
repeat = 10
xmlfile = 'tblastx_human_wnts.xml'
searchio_time = timeit.timeit(searchio % xmlfile, number=repeat)
ncbixml_time = timeit.timeit(ncbixml % xmlfile, number=repeat)
searchio_avg = searchio_time / float(repeat)
ncbixml_avg = ncbixml_time / float(repeat)
print "Repeats : %i" % repeat
print "SearchIO : %.3f (%.3f)" % (searchio_time, searchio_avg)
print "NCBXIML : %.3f (%.3f)" % (ncbixml_time, ncbixml_avg)
print "Difference : %.3f (%.3f)" % (searchio_time - ncbixml_time, \
searchio_avg - ncbixml_avg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment