Beispiel #1
0
 def testAddSameSubjectLeavesDatabaseSizeTheSame(self):
     """
     If an identical subject is added multiple times, the database size
     does not increase.
     """
     dbParams = DatabaseParameters(landmarks=[AlphaHelix], trigPoints=[])
     db = Database(dbParams)
     db.addSubject(AARead('id', 'FRRRFRRRF'))
     self.assertEqual(1, db.subjectCount())
     db.addSubject(AARead('id', 'FRRRFRRRF'))
     self.assertEqual(1, db.subjectCount())
Beispiel #2
0
 def testInitialStatistics(self):
     """
     The database statistics must be initially correct.
     """
     dbParams = DatabaseParameters()
     db = Database(dbParams)
     self.assertEqual(0, db.subjectCount())
     self.assertEqual(0, db.totalResidues())
     self.assertEqual(0, db.totalCoveredResidues())
Beispiel #3
0
 def testOneReadTwoLandmarksStatistics(self):
     """
     If one subject is added, the database statistics must be correct.
     """
     dbParams = DatabaseParameters(landmarks=[AlphaHelix], trigPoints=[])
     db = Database(dbParams)
     db.addSubject(AARead('id', 'FRRRFRRRFAAAAAAAAAAAAAAFRRRFRRRFRRRF'))
     self.assertEqual(1, db.subjectCount())
     self.assertEqual(36, db.totalResidues())
     self.assertEqual(22, db.totalCoveredResidues())
Beispiel #4
0
 def testTwoReadsTwoLandmarksStatistics(self):
     """
     If two identical reads are added, the database statistics must be
     correct.
     """
     dbParams = DatabaseParameters(landmarks=[AlphaHelix], trigPoints=[])
     db = Database(dbParams)
     db.addSubject(AARead('id1', 'FRRRFRRRFAAAAAAAAAAAAAAFRRRFRRRFRRRF'))
     db.addSubject(AARead('id2', 'FRRRFRRRFAAAAAAAAAAAAAAFRRRFRRRFRRRF'))
     self.assertEqual(2, db.subjectCount())
     self.assertEqual(72, db.totalResidues())
     self.assertEqual(44, db.totalCoveredResidues())
Beispiel #5
0
 def testSaveRestoreNonEmpty(self):
     """
     When asked to save and then restore a non-empty database, the correct
     database must result.
     """
     dbParams = DatabaseParameters(landmarks=[AlphaHelix, BetaStrand],
                                   trigPoints=[Peaks, Troughs])
     db = Database(dbParams)
     db.addSubject(AARead('id', 'FRRRFRRRFASAASA'))
     fp = StringIO()
     db.save(fp)
     fp.seek(0)
     result = db.restore(fp)
     self.assertIs(None, dbParams.compare(result.dbParams))
     self.assertEqual(db.subjectCount(), result.subjectCount())
     self.assertEqual(db.totalCoveredResidues(),
                      result.totalCoveredResidues())
     self.assertEqual(db.totalResidues(), result.totalResidues())
     self.assertEqual(db.checksum(), result.checksum())