diff --git a/modules/bindings/tests/CMakeLists.txt b/modules/bindings/tests/CMakeLists.txt index dd257c1cb9819c3f71233d22216537ba9b68d6b9..b5a44d108f8d02e8c4a50df436c98ee469ae0110 100644 --- a/modules/bindings/tests/CMakeLists.txt +++ b/modules/bindings/tests/CMakeLists.txt @@ -5,6 +5,7 @@ set(OST_BINDINGS_UNIT_TESTS test_blast.py test_kclust.py test_naccess.py + test_cadscore.py ) ost_unittest(MODULE bindings diff --git a/modules/bindings/tests/test_cadscore.py b/modules/bindings/tests/test_cadscore.py new file mode 100644 index 0000000000000000000000000000000000000000..be3bab50d0bc59943d760bb5dcc86054f479bc3c --- /dev/null +++ b/modules/bindings/tests/test_cadscore.py @@ -0,0 +1,74 @@ +import unittest +from ost import * +from ost import settings +from ost.bindings import cadscore +from ost import testutils + +class TestCADBindings(unittest.TestCase): + + def setUp(self): + self.protein = io.LoadEntity("testfiles/testprotein.pdb") + + + def testCADClassic(self): + + try: + # all of the following need to be present + cad_calc_path = settings.Locate('CADscore_calc.bash') + cad_read_g_path = settings.Locate('CADscore_read_global_scores.bash') + cad_read_l_path = settings.Locate('CADscore_read_local_scores.bash') + executable_path = settings.Locate('voroprot2') + except: + print("Could not find CAD score classic executables: ignoring unit tests") + return + + cad_result = cadscore.CADScore(self.protein, self.protein, + label="cad_classic") + + # model and reference are the same, we expect a global CAD score of 1 + self.assertEqual(cad_result.globalAA, 1.0) + + # one score per residue + self.assertEqual(len(cad_result.localAA), len(self.protein.residues)) + + # model and reference are the same, we expect local CAD scores of 0.0 + for score in cad_result.localAA.values(): + self.assertEqual(score, 0.0) + + # check whether this score is assigned to each residue as float property + for r in self.protein.residues: + self.assertTrue(r.HasProp("cad_classic")) + self.assertEqual(r.GetFloatProp("cad_classic"), 0.0) + + + def testCADVoronota(self): + + try: + # all of the following need to be present + voronota_cadscore_path = settings.Locate("voronota-cadscore") + executable_path = settings.Locate("voronota") + except: + print("Could not find CAD score voronota executables: ignoring unit tests") + return + + cad_result = cadscore.CADScore(self.protein, self.protein, mode="voronota", + label="cad_voronota") + + # model and reference are the same, we expect a global CAD score of 1 + self.assertEqual(cad_result.globalAA, 1.0) + + # one score per residue + self.assertEqual(len(cad_result.localAA), len(self.protein.residues)) + + # model and reference are the same, we expect local CAD scores of 1.0 + for score in cad_result.localAA.values(): + self.assertEqual(score, 1.0) + + # check whether this score is assigned to each residue as float property + for r in self.protein.residues: + self.assertTrue(r.HasProp("cad_voronota")) + self.assertEqual(r.GetFloatProp("cad_voronota"), 1.0) + + +if __name__ == "__main__": + testutils.RunTests()