File: test_alignment.py

package info (click to toggle)
python-modelcif 1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 688 kB
  • sloc: python: 6,746; makefile: 14; sh: 6
file content (37 lines) | stat: -rw-r--r-- 1,240 bytes parent folder | download
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
import utils
import os
import unittest

TOPDIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
utils.set_search_paths(TOPDIR)
import modelcif.alignment


class Tests(unittest.TestCase):
    def test_identity(self):
        """Test sequence identity classes"""
        ident = modelcif.alignment.ShorterSequenceIdentity(42.0)
        self.assertEqual(ident.denominator, "Length of the shorter sequence")
        self.assertIsNone(ident.other_details)
        self.assertAlmostEqual(ident.value, 42.0, delta=1e-4)
        ident = modelcif.alignment.AlignedPositionsIdentity(42.0)
        ident = modelcif.alignment.AlignedResiduePairsIdentity(42.0)
        ident = modelcif.alignment.MeanSequenceIdentity(42.0)

        # generic "other" identity
        ident = modelcif.alignment.Identity(42.0)
        self.assertEqual(ident.denominator, "Other")
        self.assertIsNone(ident.other_details)

        # custom "other" identity
        class CustomIdentity(modelcif.alignment.Identity):
            """foo
               bar"""

        ident = CustomIdentity(42.0)
        self.assertEqual(ident.denominator, "Other")
        self.assertEqual(ident.other_details, "foo")


if __name__ == '__main__':
    unittest.main()