annotate clipkit_repo/tests/unit/test_modes.py @ 0:49b058e85902 draft

"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
author padge
date Fri, 25 Mar 2022 13:04:31 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
1 import pytest
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
2 from pathlib import Path
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
3
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
4 import numpy as np
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
5 from Bio import AlignIO
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
6 from clipkit.modes import TrimmingMode, trim, shouldKeep
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
7
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
8 here = Path(__file__)
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
9
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
10
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
11 class TestModes(object):
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
12 def test_shouldKeep_kpi_gappy_keep(self):
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
13 ## setup
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
14 mode = TrimmingMode.kpi_gappy
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
15 gappyness = 0.00
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
16 gaps = 0.9
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
17 parsimony_informative = True
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
18 constant_site = False
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
19
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
20 assert True == shouldKeep(
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
21 mode, parsimony_informative, constant_site, gappyness, gaps
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
22 )
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
23
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
24 def test_shouldKeep_kpi_gappy_trim(self):
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
25 ## setup
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
26 mode = TrimmingMode.kpi_gappy
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
27 gappyness = 0.00
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
28 gaps = 0.9
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
29 parsimony_informative = False
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
30 constant_site = False
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
31
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
32 assert False == shouldKeep(
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
33 mode, parsimony_informative, constant_site, gappyness, gaps
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
34 )
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
35
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
36 def test_shouldKeep_gappy_keep(self):
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
37 ## setup
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
38 mode = TrimmingMode.gappy
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
39 gappyness = 0.00
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
40 gaps = 0.9
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
41 parsimony_informative = True
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
42 constant_site = False
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
43
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
44 assert True == shouldKeep(
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
45 mode, parsimony_informative, constant_site, gappyness, gaps
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
46 )
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
47
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
48 def test_shouldKeep_gappy_trim(self):
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
49 ## setup
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
50 mode = TrimmingMode.gappy
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
51 gappyness = 0.95
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
52 gaps = 0.9
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
53 parsimony_informative = True
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
54 constant_site = False
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
55
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
56 assert False == shouldKeep(
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
57 mode, parsimony_informative, constant_site, gappyness, gaps
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
58 )
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
59
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
60 def test_shouldKeep_kpi_keep(self):
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
61 ## setup
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
62 mode = TrimmingMode.kpi
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
63 gappyness = 0.00
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
64 gaps = 0.9
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
65 parsimony_informative = True
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
66 constant_site = False
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
67
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
68 assert True == shouldKeep(
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
69 mode, parsimony_informative, constant_site, gappyness, gaps
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
70 )
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
71
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
72 def test_shouldKeep_kpi_trim(self):
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
73 ## setup
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
74 mode = TrimmingMode.kpi
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
75 gappyness = 0.95
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
76 gaps = 0.9
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
77 parsimony_informative = False
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
78 constant_site = False
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
79
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
80 assert False == shouldKeep(
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
81 mode, parsimony_informative, constant_site, gappyness, gaps
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
82 )
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
83
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
84 def test_shouldKeep_kpic_keep(self):
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
85 ## setup
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
86 mode = TrimmingMode.kpic
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
87 gappyness = 0.95
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
88 gaps = 0.9
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
89 parsimony_informative = False
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
90 constant_site = True
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
91
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
92 assert True == shouldKeep(
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
93 mode, parsimony_informative, constant_site, gappyness, gaps
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
94 )
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
95
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
96 def test_shouldKeep_kpic_trim(self):
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
97 ## setup
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
98 mode = TrimmingMode.kpic
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
99 gappyness = 0.95
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
100 gaps = 0.9
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
101 parsimony_informative = False
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
102 constant_site = False
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
103
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
104 assert False == shouldKeep(
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
105 mode, parsimony_informative, constant_site, gappyness, gaps
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
106 )
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
107
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
108 def test_shouldKeep_kpic_gappy_keep(self):
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
109 ## setup
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
110 mode = TrimmingMode.kpic_gappy
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
111 gappyness = 0.70
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
112 gaps = 0.9
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
113 parsimony_informative = False
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
114 constant_site = True
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
115
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
116 assert True == shouldKeep(
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
117 mode, parsimony_informative, constant_site, gappyness, gaps
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
118 )
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
119
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
120 def test_shouldKeep_kpic_gappy_trim(self):
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
121 ## setup
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
122 mode = TrimmingMode.kpic_gappy
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
123 gappyness = 0.95
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
124 gaps = 0.9
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
125 parsimony_informative = False
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
126 constant_site = True
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
127
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
128 assert False == shouldKeep(
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
129 mode, parsimony_informative, constant_site, gappyness, gaps
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
130 )
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
131
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
132 def test_gappy_mode(self):
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
133 ## setup
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
134 gappyness = 0.00
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
135 parsimony_informative = True
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
136 keepD = {}
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
137 trimD = {}
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
138 i = 2
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
139 gaps = 0.9
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
140 alignment = AlignIO.read(f"{here.parent}/examples/simple.fa", "fasta")
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
141 use_log = False
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
142 constant_site = False
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
143
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
144 for entry in alignment:
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
145 keepD[entry.description] = np.empty([6], dtype=str)
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
146 trimD = {}
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
147 for entry in alignment:
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
148 trimD[entry.description] = np.empty([6], dtype=str)
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
149
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
150 ## execution
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
151 keepD, trimD = trim(
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
152 gappyness,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
153 parsimony_informative,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
154 constant_site,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
155 keepD,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
156 trimD,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
157 i,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
158 gaps,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
159 alignment,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
160 TrimmingMode.gappy,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
161 use_log,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
162 )
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
163
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
164 ## check results
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
165 expected_keepD = {
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
166 "1": np.array(["", "", "G", "", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
167 "2": np.array(["", "", "G", "", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
168 "3": np.array(["", "", "G", "", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
169 "4": np.array(["", "", "A", "", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
170 "5": np.array(["", "", "a", "", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
171 }
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
172 expected_trimD = {
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
173 "1": np.array(["", "", "", "", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
174 "2": np.array(["", "", "", "", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
175 "3": np.array(["", "", "", "", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
176 "4": np.array(["", "", "", "", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
177 "5": np.array(["", "", "", "", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
178 }
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
179
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
180 assert expected_keepD.keys() == keepD.keys()
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
181 assert all(
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
182 np.array_equal(expected_keepD[key], keepD[key]) for key in expected_keepD
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
183 )
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
184 assert expected_trimD.keys() == trimD.keys()
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
185 assert all(
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
186 np.array_equal(expected_trimD[key], trimD[key]) for key in expected_trimD
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
187 )
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
188
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
189 def test_kpi_gappy_mode(self):
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
190 ## setup
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
191 gappyness = 0.6
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
192 parsimony_informative = False
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
193 constant_site = True
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
194 keepD = {}
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
195 trimD = {}
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
196 i = 1
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
197 gaps = 0.9
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
198 alignment = AlignIO.read(f"{here.parent}/examples/simple.fa", "fasta")
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
199 use_log = False
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
200
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
201 for entry in alignment:
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
202 keepD[entry.description] = np.empty([6], dtype=str)
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
203 trimD = {}
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
204 for entry in alignment:
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
205 trimD[entry.description] = np.empty([6], dtype=str)
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
206
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
207 ## execution
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
208 keepD, trimD = trim(
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
209 gappyness,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
210 parsimony_informative,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
211 constant_site,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
212 keepD,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
213 trimD,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
214 i,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
215 gaps,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
216 alignment,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
217 TrimmingMode.kpi_gappy,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
218 use_log,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
219 )
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
220
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
221 ## check results
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
222 expected_keepD = {
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
223 "1": np.array(["", "", "", "", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
224 "2": np.array(["", "", "", "", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
225 "3": np.array(["", "", "", "", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
226 "4": np.array(["", "", "", "", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
227 "5": np.array(["", "", "", "", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
228 }
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
229 expected_trimD = {
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
230 "1": np.array(["", "-", "", "", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
231 "2": np.array(["", "-", "", "", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
232 "3": np.array(["", "-", "", "", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
233 "4": np.array(["", "G", "", "", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
234 "5": np.array(["", "C", "", "", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
235 }
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
236
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
237 assert expected_keepD.keys() == keepD.keys()
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
238 assert all(
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
239 np.array_equal(expected_keepD[key], keepD[key]) for key in expected_keepD
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
240 )
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
241 assert expected_trimD.keys() == trimD.keys()
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
242 assert all(
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
243 np.array_equal(expected_trimD[key], trimD[key]) for key in expected_trimD
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
244 )
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
245
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
246 def test_kpi_mode(self):
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
247 ## setup
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
248 gappyness = 0.2
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
249 parsimony_informative = True
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
250 constant_site = False
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
251 keepD = {}
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
252 trimD = {}
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
253 i = 5
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
254 gaps = 0.9
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
255 alignment = AlignIO.read(f"{here.parent}/examples/simple.fa", "fasta")
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
256 use_log = False
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
257
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
258 for entry in alignment:
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
259 keepD[entry.description] = np.empty([6], dtype=str)
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
260 trimD = {}
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
261 for entry in alignment:
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
262 trimD[entry.description] = np.empty([6], dtype=str)
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
263
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
264 ## execution
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
265 keepD, trimD = trim(
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
266 gappyness,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
267 parsimony_informative,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
268 constant_site,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
269 keepD,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
270 trimD,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
271 i,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
272 gaps,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
273 alignment,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
274 TrimmingMode.kpi,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
275 use_log,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
276 )
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
277
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
278 ## check results
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
279 expected_keepD = {
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
280 "1": np.array(["", "", "", "", "", "T"]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
281 "2": np.array(["", "", "", "", "", "T"]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
282 "3": np.array(["", "", "", "", "", "A"]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
283 "4": np.array(["", "", "", "", "", "A"]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
284 "5": np.array(["", "", "", "", "", "-"]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
285 }
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
286 expected_trimD = {
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
287 "1": np.array(["", "", "", "", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
288 "2": np.array(["", "", "", "", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
289 "3": np.array(["", "", "", "", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
290 "4": np.array(["", "", "", "", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
291 "5": np.array(["", "", "", "", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
292 }
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
293
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
294 assert expected_keepD.keys() == keepD.keys()
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
295 assert all(
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
296 np.array_equal(expected_keepD[key], keepD[key]) for key in expected_keepD
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
297 )
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
298 assert expected_trimD.keys() == trimD.keys()
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
299 assert all(
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
300 np.array_equal(expected_trimD[key], trimD[key]) for key in expected_trimD
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
301 )
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
302
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
303 def test_kpic_mode(self):
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
304 ## setup
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
305 gappyness = 0.2
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
306 parsimony_informative = False
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
307 constant_site = True
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
308 keepD = {}
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
309 trimD = {}
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
310 i = 0
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
311 gaps = 0.9
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
312 alignment = AlignIO.read(f"{here.parent}/examples/simple.fa", "fasta")
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
313 use_log = False
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
314
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
315 for entry in alignment:
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
316 keepD[entry.description] = np.empty([6], dtype=str)
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
317 trimD = {}
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
318 for entry in alignment:
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
319 trimD[entry.description] = np.empty([6], dtype=str)
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
320
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
321 ## execution
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
322 keepD, trimD = trim(
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
323 gappyness,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
324 parsimony_informative,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
325 constant_site,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
326 keepD,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
327 trimD,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
328 i,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
329 gaps,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
330 alignment,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
331 TrimmingMode.kpic,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
332 use_log,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
333 )
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
334
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
335 ## check results
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
336 expected_keepD = {
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
337 "1": np.array(["A", "", "", "", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
338 "2": np.array(["A", "", "", "", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
339 "3": np.array(["A", "", "", "", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
340 "4": np.array(["A", "", "", "", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
341 "5": np.array(["A", "", "", "", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
342 }
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
343 expected_trimD = {
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
344 "1": np.array(["", "", "", "", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
345 "2": np.array(["", "", "", "", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
346 "3": np.array(["", "", "", "", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
347 "4": np.array(["", "", "", "", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
348 "5": np.array(["", "", "", "", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
349 }
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
350
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
351 assert expected_keepD.keys() == keepD.keys()
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
352 assert all(
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
353 np.array_equal(expected_keepD[key], keepD[key]) for key in expected_keepD
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
354 )
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
355 assert expected_trimD.keys() == trimD.keys()
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
356 assert all(
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
357 np.array_equal(expected_trimD[key], trimD[key]) for key in expected_trimD
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
358 )
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
359
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
360 def test_kpic_gappy_mode(self):
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
361 ## setup
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
362 gappyness = 0.2
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
363 parsimony_informative = False
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
364 constant_site = False
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
365 keepD = {}
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
366 trimD = {}
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
367 i = 3
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
368 gaps = 0.9
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
369 alignment = AlignIO.read(f"{here.parent}/examples/simple.fa", "fasta")
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
370 use_log = False
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
371
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
372 for entry in alignment:
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
373 keepD[entry.description] = np.empty([6], dtype=str)
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
374 trimD = {}
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
375 for entry in alignment:
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
376 trimD[entry.description] = np.empty([6], dtype=str)
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
377
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
378 ## execution
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
379 keepD, trimD = trim(
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
380 gappyness,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
381 parsimony_informative,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
382 constant_site,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
383 keepD,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
384 trimD,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
385 i,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
386 gaps,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
387 alignment,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
388 TrimmingMode.kpic_gappy,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
389 use_log,
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
390 )
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
391
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
392 ## check results
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
393 expected_keepD = {
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
394 "1": np.array(["", "", "", "", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
395 "2": np.array(["", "", "", "", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
396 "3": np.array(["", "", "", "", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
397 "4": np.array(["", "", "", "", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
398 "5": np.array(["", "", "", "", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
399 }
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
400 expected_trimD = {
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
401 "1": np.array(["", "", "", "T", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
402 "2": np.array(["", "", "", "-", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
403 "3": np.array(["", "", "", "-", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
404 "4": np.array(["", "", "", "-", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
405 "5": np.array(["", "", "", "-", "", ""]),
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
406 }
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
407
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
408 assert expected_keepD.keys() == keepD.keys()
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
409 assert all(
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
410 np.array_equal(expected_keepD[key], keepD[key]) for key in expected_keepD
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
411 )
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
412 assert expected_trimD.keys() == trimD.keys()
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
413 assert all(
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
414 np.array_equal(expected_trimD[key], trimD[key]) for key in expected_trimD
49b058e85902 "planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff changeset
415 )