File: test_pyspoa.py

package info (click to toggle)
python-pyspoa 0.2.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 156 kB
  • sloc: python: 148; sh: 65; makefile: 37; cpp: 35
file content (47 lines) | stat: -rw-r--r-- 1,715 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
38
39
40
41
42
43
44
45
46
47
#!/usr/env/bin python3

from spoa import poa
from unittest import TestCase, main


class Tests(TestCase):

    def test_bindings(self):
        """ simple poa to check bindings"""
        consensus, msa = poa(['AACTTATA', 'AACTTATG', 'AACTATA'])
        self.assertEqual(consensus, 'AACTTATA')
        self.assertEqual(len(msa), 3)

    def test_bindings_no_msa(self):
        """ simple poa to check bindings with msa generation"""
        consensus, msa = poa(['AACTTATA', 'AACTTATG', 'AACTATA'], genmsa=False)
        self.assertEqual(consensus, 'AACTTATA')
        self.assertEqual(len(msa), 0)

    def test_bindings_min_coverage(self):
        """ simple poa to check bindings with `min_coverage` param"""
        consensus, msa = poa(['AACTTATA', 'AACTTATG', 'AACTATA'], min_coverage=3)
        self.assertEqual(consensus, 'AACTAT')
        self.assertEqual(len(msa), 3)

    def test_bindings_min_coverage_None(self):
        """ simple poa to check bindings with `min_coverage=None`"""
        consensus, msa = poa(['AACTTATA', 'AACTTATG', 'AACTATA'], min_coverage=None)
        self.assertEqual(consensus, 'AACTTATA')
        self.assertEqual(len(msa), 3)

    def test_bindings_min_coverage_wrong_type_string(self):
        """ check that bindings with `min_coverage=str` throw error"""
        self.assertRaises(
            RuntimeError, poa, ["AACTTATA", "AACTTATG", "AACTATA"], min_coverage="x"
        )

    def test_bindings_min_coverage_wrong_type_float(self):
        """ check that bindings with `min_coverage=float` throw error"""
        self.assertRaises(
            RuntimeError, poa, ["AACTTATA", "AACTTATG", "AACTATA"], min_coverage=1.5
        )


if __name__ == '__main__':
    main()