Back to index

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

List of all members.

Public Member Functions

def setUp
def tearDown
def test_seq_record
def test_seq
def test_convert
def test_addition
def test_seq_slicing
def test_seq_features

Public Attributes

 server
 db
 item

Detailed Description

Make sure the BioSQL objects implement the expected biopython interfaces

Definition at line 217 of file test_BioSQL.py.


Member Function Documentation

Load a database.

Definition at line 220 of file test_BioSQL.py.

00220 
00221     def setUp(self):
00222         """Load a database.
00223         """
00224         gb_file = os.path.join(os.getcwd(), "GenBank", "cor6_6.gb")
00225         gb_handle = open(gb_file, "r")
00226         load_database(gb_handle)
00227         gb_handle.close()
00228 
00229         self.server = BioSeqDatabase.open_database(driver = DBDRIVER,
00230                                               user = DBUSER, passwd = DBPASSWD,
00231                                               host = DBHOST, db = TESTDB)
00232         self.db = self.server["biosql-test"]
00233         self.item = self.db.lookup(accession = "X62281")

Here is the call graph for this function:

Definition at line 234 of file test_BioSQL.py.

00234 
00235     def tearDown(self):
00236         self.server.close()
00237         del self.db
00238         del self.item
00239         del self.server
    
Check can add DBSeq objects together.

Definition at line 282 of file test_BioSQL.py.

00282 
00283     def test_addition(self):
00284         """Check can add DBSeq objects together."""
00285         test_seq = self.item.seq
00286         for other in [Seq("ACGT",test_seq.alphabet),
00287                       MutableSeq("ACGT",test_seq.alphabet),
00288                       "ACGT",
00289                       test_seq]:
00290             test = test_seq + other
00291             self.assertEqual(str(test), str(test_seq) + str(other))
00292             self.assertTrue(isinstance(test, Seq))
00293             test = other + test_seq
00294             self.assertEqual(str(test), str(other) + str(test_seq))

Check can turn a DBSeq object into a Seq or MutableSeq.

Definition at line 268 of file test_BioSQL.py.

00268 
00269     def test_convert(self):
00270         """Check can turn a DBSeq object into a Seq or MutableSeq."""
00271         test_seq = self.item.seq
00272 
00273         other = test_seq.toseq()
00274         self.assertEqual(str(test_seq), str(other))
00275         self.assertEqual(test_seq.alphabet, other.alphabet)
00276         self.assertTrue(isinstance(other, Seq))
00277 
00278         other = test_seq.tomutable()
00279         self.assertEqual(str(test_seq), str(other))
00280         self.assertEqual(test_seq.alphabet, other.alphabet)
00281         self.assertTrue(isinstance(other, MutableSeq))

Make sure Seqs from BioSQL implement the right interface.

Definition at line 255 of file test_BioSQL.py.

00255 
00256     def test_seq(self):
00257         """Make sure Seqs from BioSQL implement the right interface.
00258         """
00259         test_seq = self.item.seq
00260         alphabet = test_seq.alphabet
00261         self.assertTrue(isinstance(alphabet, Alphabet.Alphabet))
00262         data = test_seq.data
00263         self.assertEqual(type(data), type(""))
00264         string_rep = test_seq.tostring()
00265         self.assertEqual(string_rep, str(test_seq)) #check __str__ too
00266         self.assertEqual(type(string_rep), type(""))
00267         self.assertEqual(len(test_seq), 880)
        
Check SeqFeatures of a sequence.

Definition at line 313 of file test_BioSQL.py.

00313 
00314     def test_seq_features(self):
00315         """Check SeqFeatures of a sequence.
00316         """
00317         test_features = self.item.features
00318         cds_feature = test_features[6]
00319         self.assertEqual(cds_feature.type, "CDS")
00320         self.assertEqual(str(cds_feature.location), "[103:579](+)")
00321         for sub_feature in cds_feature.sub_features:
00322             self.assertEqual(sub_feature.type, "CDS")
00323             self.assertEqual(sub_feature.location_operator, "join")
00324 
00325         try:
00326             self.assertEqual(cds_feature.qualifiers["gene"], ["kin2"])
00327             self.assertEqual(cds_feature.qualifiers["protein_id"], ["CAA44171.1"])
00328             self.assertEqual(cds_feature.qualifiers["codon_start"], ["1"])
00329         except KeyError:
00330             raise KeyError("Missing expected entries, have %s" \
00331                            % repr(cds_feature.qualifiers))
00332         
00333         self.assertTrue("db_xref" in cds_feature.qualifiers)
00334         multi_ann = cds_feature.qualifiers["db_xref"]
00335         self.assertEqual(len(multi_ann), 2)
00336         self.assertTrue("GI:16354" in multi_ann)
00337         self.assertTrue("SWISS-PROT:P31169" in multi_ann)

Make sure SeqRecords from BioSQL implement the right interface.

Definition at line 240 of file test_BioSQL.py.

00240 
00241     def test_seq_record(self):
00242         """Make sure SeqRecords from BioSQL implement the right interface.
00243         """
00244         test_record = self.item
00245         self.assertTrue(isinstance(test_record.seq, BioSeq.DBSeq))
00246         self.assertEqual(test_record.id, "X62281.1", test_record.id)
00247         self.assertEqual(test_record.name, "ATKIN2")
00248         self.assertEqual(test_record.description, "A.thaliana kin2 gene.")
00249         annotations = test_record.annotations
00250         # XXX should do something with annotations once they are like
00251         # a dictionary
00252         for feature in test_record.features:
00253             self.assertTrue(isinstance(feature, SeqFeature))
00254         s = str(test_record) #shouldn't cause any errors!

Check that slices of sequences are retrieved properly.

Definition at line 295 of file test_BioSQL.py.

00295 
00296     def test_seq_slicing(self):
00297         """Check that slices of sequences are retrieved properly.
00298         """
00299         test_seq = self.item.seq
00300         new_seq = test_seq[:10]
00301         self.assertTrue(isinstance(new_seq, BioSeq.DBSeq))
00302         # simple slicing
00303         self.assertEqual(test_seq[:5].tostring(), 'ATTTG')
00304         self.assertEqual(test_seq[0:5].tostring(), 'ATTTG')
00305         self.assertEqual(test_seq[2:3].tostring(), 'T')
00306         self.assertEqual(test_seq[2:4].tostring(), 'TT')
00307         self.assertEqual(test_seq[870:].tostring(), 'TTGAATTATA')
00308         # getting more fancy
00309         self.assertEqual(test_seq[-1], 'A')
00310         self.assertEqual(test_seq[1], 'T')
00311         self.assertEqual(test_seq[-10:][5:].tostring(), "TTATA")
00312         self.assertEqual(str(test_seq[-10:][5:]), "TTATA")

Here is the call graph for this function:


Member Data Documentation

Definition at line 231 of file test_BioSQL.py.

Definition at line 232 of file test_BioSQL.py.

Definition at line 228 of file test_BioSQL.py.


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