1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
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 settings.FileNotFound:
self.skipTest("Could not find CAD score classic executables: ignoring unit tests")
cad_result = cadscore.CADScore(self.protein, self.protein, mode="classic",
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 settings.FileNotFound:
self.skipTest("Could not find CAD score voronota executables: ignoring unit tests")
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()
|