Created
May 20, 2012 20:36
-
-
Save bow/2759448 to your computer and use it in GitHub Desktop.
Quick script to compare SearchIO and NCBIXML blast xml parser performance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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