Back to index

python-biopython  1.60
Public Member Functions | Public Attributes
test_SCOP_Cla.ClaTests Class Reference

List of all members.

Public Member Functions

def setUp
def testParse
def testStr
def testError
def testRecord
def testIndex

Public Attributes

 filename

Detailed Description

Definition at line 18 of file test_SCOP_Cla.py.


Member Function Documentation

Definition at line 20 of file test_SCOP_Cla.py.

00020 
00021     def setUp(self):
00022         self.filename = './SCOP/dir.cla.scop.txt_test'

Test if a corrupt record raises the appropriate exception

Definition at line 60 of file test_SCOP_Cla.py.

00060 
00061     def testError(self):
00062         """Test if a corrupt record raises the appropriate exception"""
00063         corruptRec = "49268\tsp\tb.1.2.1\t-\n"
00064         self.assertRaises(ValueError, Cla.Record, corruptRec)

Test CLA file indexing

Definition at line 83 of file test_SCOP_Cla.py.

00083 
00084     def testIndex(self):
00085         """Test CLA file indexing"""
00086         index = Cla.Index(self.filename)
00087         
00088         self.assertEqual(len(index), 14)
00089         self.assertTrue('d4hbia_' in index)
00090 
00091         rec = index['d1hbia_']
00092         self.assertEqual(rec.sunid, 14996)
00093 
00094 

Test if all records in a CLA file are being read

Definition at line 23 of file test_SCOP_Cla.py.

00023 
00024     def testParse(self):
00025         """Test if all records in a CLA file are being read"""
00026         f=open(self.filename)
00027         try: 
00028             count = 0
00029             records = Cla.parse(f)
00030             for record in records:
00031                 count +=1
00032             self.assertEqual(count, 14)
00033         finally:
00034             f.close()
    

Here is the call graph for this function:

Test one record in detail

Definition at line 65 of file test_SCOP_Cla.py.

00065 
00066     def testRecord(self):
00067         """Test one record in detail"""
00068         recLine = 'd1dan.1\t1dan\tT:,U:91-106\tb.1.2.1\t21953\tcl=48724,cf=48725,sf=49265,fa=49266,dm=49267,sp=49268,px=21953'
00069 
00070         record = Cla.Record(recLine)
00071         self.assertEqual(record.sid, 'd1dan.1')
00072         self.assertEqual(record.residues.pdbid, '1dan')
00073         self.assertEqual(record.residues.fragments, (('T','',''),('U','91','106')))
00074         self.assertEqual(record.sccs, 'b.1.2.1')
00075         self.assertEqual(record.sunid, 21953)
00076         self.assertEqual(record.hierarchy, {'cl' : 48724,
00077                                             'cf' : 48725,
00078                                             'sf' : 49265,
00079                                             'fa' : 49266,
00080                                             'dm' : 49267,
00081                                             'sp' : 49268,
00082                                             'px' : 21953})

Test if we can convert each record to a string correctly

Definition at line 35 of file test_SCOP_Cla.py.

00035 
00036     def testStr(self):
00037         """Test if we can convert each record to a string correctly"""
00038         f = open(self.filename)
00039         try: 
00040             for line in f:
00041                 record = Cla.Record(line)
00042                 # The SCOP Classification file format which can be found at
00043                 # http://scop.mrc-lmb.cam.ac.uk/scop/release-notes.html states
00044                 # that the list of classification hierarchy key-value pairs is
00045                 # unordered, therefore we need only check that they are all
00046                 # there, NOT that they are in the same order.
00047                 #End of line is platform dependent. Strip it off
00048                 expected_hierarchy = line.rstrip().split('\t')[5].split(',')
00049                 expected_hierarchy = dict(pair.split('=') for pair
00050                                           in expected_hierarchy)
00051                 actual_hierarchy = str(record).rstrip().split('\t')[5].split(',')
00052                 actual_hierarchy = dict(pair.split('=') for pair
00053                                         in actual_hierarchy)
00054                 self.assertEqual(len(actual_hierarchy),
00055                                   len(expected_hierarchy))
00056                 for key, actual_value in actual_hierarchy.iteritems():
00057                     self.assertEqual(actual_value, expected_hierarchy[key])
00058         finally:
00059             f.close()        

Here is the call graph for this function:


Member Data Documentation

Definition at line 21 of file test_SCOP_Cla.py.


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