Back to index

python-biopython  1.60
Public Member Functions | Public Attributes
test_BioSQL.LoaderTest Class Reference

List of all members.

Public Member Functions

def setUp
def tearDown
def test_load_database

Public Attributes

 server
 db
 iterator

Detailed Description

Load a database from a GenBank file.

Definition at line 338 of file test_BioSQL.py.


Member Function Documentation

Definition at line 341 of file test_BioSQL.py.

00341 
00342     def setUp(self):
00343         # create TESTDB
00344         create_database()
00345         
00346         # load the database
00347         db_name = "biosql-test"
00348         self.server = BioSeqDatabase.open_database(driver = DBDRIVER,
00349                                               user = DBUSER, passwd = DBPASSWD,
00350                                               host = DBHOST, db = TESTDB)
00351         
00352         # remove the database if it already exists
00353         try:
00354             self.server[db_name]
00355             self.server.remove_database(db_name)
00356         except KeyError:
00357             pass
00358         
00359         self.db = self.server.new_database(db_name)
00360 
00361         # get the GenBank file we are going to put into it
00362         input_file = os.path.join(os.getcwd(), "GenBank", "cor6_6.gb")
00363         handle = open(input_file, "r")
00364         self.iterator = SeqIO.parse(handle, "gb")

Here is the call graph for this function:

Definition at line 365 of file test_BioSQL.py.

00365 
00366     def tearDown(self):
00367         self.server.close()
00368         del self.db
00369         del self.server

Load SeqRecord objects into a BioSQL database.

Definition at line 370 of file test_BioSQL.py.

00370 
00371     def test_load_database(self):
00372         """Load SeqRecord objects into a BioSQL database.
00373         """
00374         self.db.load(self.iterator)
00375 
00376         # do some simple tests to make sure we actually loaded the right
00377         # thing. More advanced tests in a different module.
00378         items = self.db.values()
00379         self.assertEqual(len(items), 6)
00380         self.assertEqual(len(self.db), 6)
00381         item_names = []
00382         item_ids = []
00383         for item in items:
00384             item_names.append(item.name)
00385             item_ids.append(item.id)
00386         item_names.sort()
00387         item_ids.sort()
00388         self.assertEqual(item_names, ['AF297471', 'ARU237582', 'ATCOR66M',
00389                                       'ATKIN2', 'BNAKINI', 'BRRBIF72'])
00390         self.assertEqual(item_ids, ['AF297471.1', 'AJ237582.1', 'L31939.1',
00391                                     'M81224.1', 'X55053.1', 'X62281.1'])


Member Data Documentation

Definition at line 358 of file test_BioSQL.py.

Definition at line 363 of file test_BioSQL.py.

Definition at line 347 of file test_BioSQL.py.


The documentation for this class was generated from the following file: