Back to index

python-biopython  1.60
biosql_performance_read.py
Go to the documentation of this file.
00001 #/usr/bin/env python
00002 """Small script to test timing of getting records from a BioSQL database.
00003 """
00004 import time
00005 # set up the connection
00006 from BioSQL import BioSeqDatabase
00007 server = BioSeqDatabase.open_database (host = "192.168.0.192", user = "root", 
00008                                        passwd = "", db = "test_biosql")
00009 db = server["embl_rod"]
00010 
00011 # -- do the fasta-only timing part
00012 start_time = time.time()
00013 all_records = db.items()
00014 for junk_id, record in all_records:
00015     sequence = record.seq.data
00016     d = record.description
00017     i = record.id
00018     n = record.name 
00019 
00020 end_time = time.time()
00021 num_records = len(all_records)
00022 elapsed_time = end_time - start_time
00023 print "Fasta"
00024 print "\tDid %s records in %s seconds for\n\t%f records per second" % \
00025       (num_records, elapsed_time, float(num_records) / float(elapsed_time))
00026 
00027 # -- do the "EMBL" timing part
00028 start_time = time.time()
00029 all_records = db.items()
00030 for junk_id, record in all_records:
00031     sequence = record.seq.data
00032     d = record.description
00033     i = record.id
00034     n = record.name
00035     features = record.features
00036     anns = record.annotations
00037     dates = record.dates
00038     species = record.species
00039     keywords = record.keywords
00040 end_time = time.time()
00041 num_records = len(all_records)
00042 elapsed_time = end_time - start_time
00043 print "EMBL"
00044 print "\tDid %s records in %s seconds for\n\t%f records per second" % \
00045       (num_records, elapsed_time, float(num_records) / float(elapsed_time))