File: test_tmtools.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 (78 lines) | stat: -rw-r--r-- 2,691 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
73
74
75
76
77
78
import unittest
from ost import *
from ost import settings
from ost import testutils
from ost.seq.alg import SequenceIdentity
from ost.bindings import tmtools
from ost.bindings import WrappedTMAlign

class TestTMBindings(unittest.TestCase):
  
  def setUp(self):
    self.protein = io.LoadEntity("testfiles/testprotein.pdb")


  def testTMAlign(self):

    try:
      cad_calc_path = settings.Locate('tmalign')  
    except:
      print("Could not find tmalign executable: ignoring unit tests")
      return

    tm_result = tmtools.TMAlign(self.protein, self.protein)

    # model and reference are the same, we expect pretty good results
    self.assertEqual(tm_result.rmsd, 0.0)
    self.assertEqual(tm_result.tm_score, 1.0)
    self.assertEqual(tm_result.aligned_length, len(self.protein.chains[0].residues))
    self.assertEqual(SequenceIdentity(tm_result.alignment), 100.0)

    # transformation should be identity matrix (no transformation at all...)
    identity = geom.Mat4(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1)
    self.assertEqual(tm_result.transform, identity)


  def testTMScore(self):

    try:
      cad_calc_path = settings.Locate('tmscore')  
    except:
      print("Could not find tmalign executable: ignoring unit tests")
      return

    tm_result = tmtools.TMScore(self.protein, self.protein)

    # model and reference are the same, we expect pretty good results
    self.assertEqual(tm_result.rmsd_common, 0.0)
    self.assertEqual(tm_result.tm_score, 1.0)
    self.assertEqual(tm_result.max_sub, 1.0)
    self.assertEqual(tm_result.gdt_ts, 1.0)
    self.assertEqual(tm_result.gdt_ha, 1.0)
    self.assertEqual(tm_result.rmsd_below_five, 0.0)

    # transformation should be identity matrix (no transformation at all...)
    identity = geom.Mat4(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1)
    self.assertEqual(tm_result.transform, identity)

  def testWrappedTMAlign(self):

    tm_result = WrappedTMAlign(self.protein.CreateFullView().chains[0],
                               self.protein.CreateFullView().chains[0])

    # model and reference are the same, we expect pretty good results
    self.assertAlmostEqual(tm_result.rmsd, 0.0, places=4)
    self.assertAlmostEqual(tm_result.tm_score, 1.0, places=4)
    self.assertEqual(tm_result.aligned_length, len(self.protein.chains[0].residues))
    self.assertEqual(SequenceIdentity(tm_result.alignment), 100.0)

    # transformation should be identity matrix (no transformation at all...)
    identity = geom.Mat4(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1)
    for i in range(4):
      for j in range(4):
        self.assertAlmostEqual(tm_result.transform[i,j], identity[i,j])



if __name__ == "__main__":
  testutils.RunTests()