File: test_cadscore.py

package info (click to toggle)
openstructure 2.11.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 206,240 kB
  • sloc: cpp: 188,571; python: 36,686; ansic: 34,298; fortran: 3,275; sh: 312; xml: 146; makefile: 29
file content (72 lines) | stat: -rw-r--r-- 2,594 bytes parent folder | download | duplicates (2)
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()