Back to index

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

List of all members.

Public Member Functions

def setUp
def tearDown
def test_transfer
def test_reload
def test_record_loading
def test_seq_feature

Public Attributes

 server
 db

Detailed Description

Make sure we are loading and retreiving in a semi-lossless fashion.

Definition at line 587 of file test_BioSQL.py.


Member Function Documentation

Definition at line 590 of file test_BioSQL.py.

00590 
00591     def setUp(self):
00592         gb_file = os.path.join(os.getcwd(), "GenBank", "cor6_6.gb")
00593         gb_handle = open(gb_file, "r")
00594         load_database(gb_handle)
00595         gb_handle.close()
00596 
00597         self.server = BioSeqDatabase.open_database(driver = DBDRIVER,
00598                                               user = DBUSER, passwd = DBPASSWD,
00599                                               host = DBHOST, db = TESTDB)
00600         self.db = self.server["biosql-test"]

Here is the call graph for this function:

Definition at line 601 of file test_BioSQL.py.

00601 
00602     def tearDown(self):
00603         self.server.close()
00604         del self.db
00605         del self.server

Make sure all records are correctly loaded.

Definition at line 637 of file test_BioSQL.py.

00637 
00638     def test_record_loading(self):
00639         """Make sure all records are correctly loaded.
00640         """
00641         test_record = self.db.lookup(accession = "X55053")
00642         self.assertEqual(test_record.name, "ATCOR66M")
00643         self.assertEqual(test_record.id, "X55053.1")
00644         self.assertEqual(test_record.description, "A.thaliana cor6.6 mRNA.")
00645         self.assertTrue(isinstance(test_record.seq.alphabet, Alphabet.DNAAlphabet))
00646         self.assertEqual(test_record.seq[:10].tostring(), 'AACAAAACAC')
00647 
00648         test_record = self.db.lookup(accession = "X62281")
00649         self.assertEqual(test_record.name, "ATKIN2")
00650         self.assertEqual(test_record.id, "X62281.1")
00651         self.assertEqual(test_record.description, "A.thaliana kin2 gene.")
00652         self.assertTrue(isinstance(test_record.seq.alphabet, Alphabet.DNAAlphabet))
00653         self.assertEqual(test_record.seq[:10].tostring(), 'ATTTGGCCTA')

Here is the call graph for this function:

Make sure can't reimport existing records.

Definition at line 616 of file test_BioSQL.py.

00616 
00617     def test_reload(self):
00618         """Make sure can't reimport existing records."""
00619         gb_file = os.path.join(os.getcwd(), "GenBank", "cor6_6.gb")
00620         gb_handle = open(gb_file, "r")
00621         record = SeqIO.parse(gb_handle, "gb").next()
00622         gb_handle.close()
00623         #Should be in database already...
00624         db_record = self.db.lookup(accession = "X55053")
00625         self.assertEqual(db_record.id, record.id)
00626         self.assertEqual(db_record.name, record.name)
00627         self.assertEqual(db_record.description, record.description)
00628         self.assertEqual(str(db_record.seq), str(record.seq))
00629         #Good... now try reloading it!
00630         try:
00631             count = self.db.load([record])
00632         except Exception, err:
00633             #Good!
00634             self.assertEqual("IntegrityError", err.__class__.__name__)
00635             return
00636         raise Exception("Should have failed! Loaded %i records" % count)

Here is the call graph for this function:

Indepth check that SeqFeatures are transmitted through the db.

Definition at line 654 of file test_BioSQL.py.

00654 
00655     def test_seq_feature(self):
00656         """Indepth check that SeqFeatures are transmitted through the db.
00657         """
00658         test_record = self.db.lookup(accession = "AJ237582")
00659         features = test_record.features
00660         self.assertEqual(len(features), 7)
00661        
00662         # test single locations
00663         test_feature = features[0]
00664         self.assertEqual(test_feature.type, "source")
00665         self.assertEqual(str(test_feature.location), "[0:206](+)")
00666         self.assertEqual(len(test_feature.qualifiers.keys()), 3)
00667         self.assertEqual(test_feature.qualifiers["country"], ["Russia:Bashkortostan"])
00668         self.assertEqual(test_feature.qualifiers["organism"], ["Armoracia rusticana"])
00669         self.assertEqual(test_feature.qualifiers["db_xref"], ["taxon:3704"])
00670 
00671         # test split locations
00672         test_feature = features[4]
00673         self.assertEqual(test_feature.type, "CDS")
00674         self.assertEqual(str(test_feature.location), "[0:206](+)")
00675         self.assertEqual(len(test_feature.sub_features), 2)
00676         self.assertEqual(str(test_feature.sub_features[0].location), "[0:48](+)")
00677         self.assertEqual(test_feature.sub_features[0].type, "CDS")
00678         self.assertEqual(test_feature.sub_features[0].location_operator, "join")
00679         self.assertEqual(str(test_feature.sub_features[1].location), "[142:206](+)")
00680         self.assertEqual(test_feature.sub_features[1].type, "CDS")
00681         self.assertEqual(test_feature.sub_features[1].location_operator, "join")
00682         self.assertEqual(len(test_feature.qualifiers.keys()), 6)
00683         self.assertEqual(test_feature.qualifiers["gene"], ["csp14"])
00684         self.assertEqual(test_feature.qualifiers["codon_start"], ["2"])
00685         self.assertEqual(test_feature.qualifiers["product"],
00686                          ["cold shock protein"])
00687         self.assertEqual(test_feature.qualifiers["protein_id"], ["CAB39890.1"])
00688         self.assertEqual(test_feature.qualifiers["db_xref"], ["GI:4538893"])
00689         self.assertEqual(test_feature.qualifiers["translation"],
00690                          ["DKAKDAAAAAGASAQQAGKNISDAAAGGVNFVKEKTG"])
00691 
00692         # test passing strand information
00693         # XXX We should be testing complement as well
00694         test_record = self.db.lookup(accession = "AJ237582")
00695         test_feature = test_record.features[4] # DNA, no complement
00696         self.assertEqual(test_feature.strand, 1)
00697         for sub_feature in test_feature.sub_features:
00698             self.assertEqual(sub_feature.strand, 1)
00699 
00700         test_record = self.db.lookup(accession = "X55053")
00701         test_feature = test_record.features[0]
00702         # mRNA, so really cDNA, so the strand should be 1 (not complemented)
00703         self.assertEqual(test_feature.strand, 1)
00704 
00705 #Some of the unit tests don't create their own database,
00706 #so just in case there is no database already:
00707 create_database()

Here is the call graph for this function:

Make sure can load record into another namespace.

Definition at line 606 of file test_BioSQL.py.

00606 
00607     def test_transfer(self):
00608         """Make sure can load record into another namespace."""
00609         #Should be in database already...
00610         db_record = self.db.lookup(accession = "X55053")
00611         #Make a new namespace
00612         db2 = self.server.new_database("biosql-test-alt")
00613         #Should be able to load this DBSeqRecord there...
00614         count = db2.load([db_record])
00615         self.assertEqual(count,1)


Member Data Documentation

Definition at line 599 of file test_BioSQL.py.

Definition at line 596 of file test_BioSQL.py.


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