def testStr(self):
     """Test if we can convert each record to a string correctly"""
     f = open(self.filename)
     try:
         for line in f:
             record = Cla.Record(line)
             # The SCOP Classification file format which can be found at
             # http://scop.mrc-lmb.cam.ac.uk/scop/release-notes.html states
             # that the list of classification hierarchy key-value pairs is
             # unordered, therefore we need only check that they are all
             # there, NOT that they are in the same order.
             #End of line is platform dependent. Strip it off
             expected_hierarchy = line.rstrip().split('\t')[5].split(',')
             expected_hierarchy = dict(
                 pair.split('=') for pair in expected_hierarchy)
             actual_hierarchy = str(record).rstrip().split('\t')[5].split(
                 ',')
             actual_hierarchy = dict(
                 pair.split('=') for pair in actual_hierarchy)
             self.assertEqual(len(actual_hierarchy),
                              len(expected_hierarchy))
             for key, actual_value in actual_hierarchy.iteritems():
                 self.assertEqual(actual_value, expected_hierarchy[key])
     finally:
         f.close()
Example #2
0
    def testError(self) :
        corruptRec = "49268\tsp\tb.1.2.1\t-\n"

        try:
            record = Cla.Record(corruptRec)
            assert False, "Should never get here"
        except ValueError, e :
            pass
Example #3
0
 def testStr(self):
     f = open(self.filename)
     try: 
         for line in f:
             record = Cla.Record(line)
             #End of line is platform dependent. Strip it off
             assert str(record).rstrip() == line.rstrip()
     finally:
         f.close()        
Example #4
0
    def testRecord(self) :
        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'

        record = Cla.Record(recLine)
        assert record.sid =='d1dan.1'
        assert record.residues.pdbid =='1dan'
        assert record.residues.fragments ==(('T','',''),('U','91','106'))
        assert record.sccs == 'b.1.2.1'
        assert record.sunid == 21953
        assert record.hierarchy == [['cl',48724],['cf',48725],['sf',49265],
             ['fa',49266],['dm',49267],['sp',49268],
             ['px',21953]], record.hierarchy
Example #5
0
    def testRecord(self):
        """Test one record in detail"""
        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'

        record = Cla.Record(recLine)
        self.assertEqual(record.sid, 'd1dan.1')
        self.assertEqual(record.residues.pdbid, '1dan')
        self.assertEqual(record.residues.fragments, (('T','',''),('U','91','106')))
        self.assertEqual(record.sccs, 'b.1.2.1')
        self.assertEqual(record.sunid, 21953)
        self.assertEqual(record.hierarchy, {'cl' : 48724,
                                            'cf' : 48725,
                                            'sf' : 49265,
                                            'fa' : 49266,
                                            'dm' : 49267,
                                            'sp' : 49268,
                                            'px' : 21953})
Example #6
0
    def testRecord(self):
        """Test one record in detail."""
        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"

        record = Cla.Record(recLine)
        self.assertEqual(record.sid, "d1dan.1")
        self.assertEqual(record.residues.pdbid, "1dan")
        self.assertEqual(record.residues.fragments,
                         (("T", "", ""), ("U", "91", "106")))
        self.assertEqual(record.sccs, "b.1.2.1")
        self.assertEqual(record.sunid, 21953)
        self.assertEqual(
            record.hierarchy, {
                "cl": 48724,
                "cf": 48725,
                "sf": 49265,
                "fa": 49266,
                "dm": 49267,
                "sp": 49268,
                "px": 21953
            })