File: test_aaindex.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 (49 lines) | stat: -rw-r--r-- 1,701 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
import sys
import unittest
from ost.seq.alg import aaindex

class TestAAIndex(unittest.TestCase):
  
    
  def testStuff(self):
      index = aaindex.AAIndex()

      # test some random aaindex annotations from all three files
      # the files themselves are lazy loaded until the required
      # annotation is found

      # entry from aaindex1
      self.assertEqual(index["BHAR880101"].GetScore("C"), 0.346)

      # entries from aaindex2
      # symmetric one:
      self.assertEqual(index["HENS920102"].GetPairScore("C", "A"), -1.0)
      self.assertEqual(index["HENS920102"].GetPairScore("A", "C"), -1.0)
      # non-symmetric one:
      self.assertEqual(index["LINK010101"].GetPairScore("C", "A"), 0.035)
      self.assertEqual(index["LINK010101"].GetPairScore("A", "C"), 0.000)


      # entries from aaindex3
      # symmetric one
      self.assertEqual(index["TANS760102"].GetPairScore("H", "R"), 17)
      self.assertEqual(index["TANS760102"].GetPairScore("R", "H"), 17)
      # non symmetric one
      self.assertEqual(index["ZHAC000102"].GetPairScore("H", "R"), 2.19)
      self.assertEqual(index["ZHAC000102"].GetPairScore("R", "H"), 0.94)

      # depending on annotation type (single amino acids or pairs), we need
      # to call the right functions
      with self.assertRaises(RuntimeError):
          index["TANS760102"].GetScore("H")

      with self.assertRaises(RuntimeError):
          index["BHAR880101"].GetPairScore("H", "R")


if __name__ == "__main__":
  from ost import testutils
  # the function below indirectly enables GetSharedDataPath when
  # calling stuff from python which is the case in unit tests
  testutils.DefaultCompoundLibIsSet()
  testutils.RunTests()