From 7be99f6bcbb0c69b09cb50faaa3e2ee17b568648 Mon Sep 17 00:00:00 2001 From: Gabriel Studer <gabriel.studer@unibas.ch> Date: Wed, 20 Nov 2019 15:38:30 +0100 Subject: [PATCH] basic unit tests for TMAlign and TMScore --- modules/bindings/tests/CMakeLists.txt | 1 + modules/bindings/tests/test_tmtools.py | 59 ++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 modules/bindings/tests/test_tmtools.py diff --git a/modules/bindings/tests/CMakeLists.txt b/modules/bindings/tests/CMakeLists.txt index b5a44d108..089f1ae9b 100644 --- a/modules/bindings/tests/CMakeLists.txt +++ b/modules/bindings/tests/CMakeLists.txt @@ -6,6 +6,7 @@ set(OST_BINDINGS_UNIT_TESTS test_kclust.py test_naccess.py test_cadscore.py + test_tmtools.py ) ost_unittest(MODULE bindings diff --git a/modules/bindings/tests/test_tmtools.py b/modules/bindings/tests/test_tmtools.py new file mode 100644 index 000000000..148e6263c --- /dev/null +++ b/modules/bindings/tests/test_tmtools.py @@ -0,0 +1,59 @@ +import unittest +from ost import * +from ost import settings +from ost import testutils +from ost.seq.alg import SequenceIdentity +from ost.bindings import tmtools + +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) + + +if __name__ == "__main__": + testutils.RunTests() -- GitLab