3
3
from numpy .testing import assert_array_equal
4
4
5
5
# FIXME - quick hacks here to get tests working
6
- from sc2ts import alignments as convert
6
+ from sc2ts import alignments as sa
7
7
from sc2ts import core
8
8
9
+
9
10
def test_get_gene_coordinates ():
10
11
d = core .get_gene_coordinates ()
11
12
assert len (d ) == 11
@@ -29,26 +30,26 @@ class TestEncodeAligment:
29
30
)
30
31
def test_examples (self , hap , expected ):
31
32
h = np .array (list (hap ), dtype = "U1" )
32
- a = convert .encode_alignment (h )
33
+ a = sa .encode_alignment (h )
33
34
assert_array_equal (a , expected )
34
- assert_array_equal (h , convert .decode_alignment (a ))
35
+ assert_array_equal (h , sa .decode_alignment (a ))
35
36
36
37
@pytest .mark .parametrize ("hap" , "RYSWKMDHVN." )
37
38
def test_iupac_uncertain_missing (self , hap ):
38
39
h = np .array (list (hap ), dtype = "U1" )
39
- a = convert .encode_alignment (h )
40
+ a = sa .encode_alignment (h )
40
41
assert_array_equal (a , [- 1 ])
41
42
42
43
@pytest .mark .parametrize ("hap" , "XZxz" )
43
44
def test_other_missing (self , hap ):
44
45
h = np .array (list (hap ), dtype = "U1" )
45
- a = convert .encode_alignment (h )
46
+ a = sa .encode_alignment (h )
46
47
assert_array_equal (a , [- 1 ])
47
48
48
49
@pytest .mark .parametrize ("hap" , "acgt" )
49
50
def test_lowercase_nucleotide_missing (self , hap ):
50
51
h = np .array (list (hap ), dtype = "U1" )
51
- a = convert .encode_alignment (h )
52
+ a = sa .encode_alignment (h )
52
53
assert_array_equal (a , [- 1 ])
53
54
54
55
@pytest .mark .parametrize (
@@ -63,13 +64,10 @@ def test_lowercase_nucleotide_missing(self, hap):
63
64
)
64
65
def test_examples (self , a ):
65
66
with pytest .raises (ValueError ):
66
- convert .decode_alignment (np .array (a ))
67
+ sa .decode_alignment (np .array (a ))
67
68
68
69
69
- # TODO fixup these tests
70
- @pytest .mark .skip
71
70
class TestMasking :
72
-
73
71
# Window size of 1 is weird because we have to have two or more
74
72
# ambiguous characters. That means we only filter if something is
75
73
# surrounded.
@@ -85,11 +83,11 @@ class TestMasking:
85
83
)
86
84
def test_examples_w1 (self , hap , expected , masked ):
87
85
hap = np .array (list (hap ), dtype = "U1" )
88
- a = convert .encode_alignment (hap )
86
+ a = sa .encode_alignment (hap )
89
87
expected = np .array (list (expected ), dtype = "U1" )
90
- m = convert .mask_alignment (a , 1 )
91
- assert np . sum (m ) == masked
92
- assert_array_equal (expected , convert .decode_alignment (a ))
88
+ m = sa .mask_alignment (a , window_size = 1 )
89
+ assert len (m ) == masked
90
+ assert_array_equal (expected , sa .decode_alignment (a ))
93
91
94
92
@pytest .mark .parametrize (
95
93
["hap" , "expected" , "masked" ],
@@ -104,15 +102,14 @@ def test_examples_w1(self, hap, expected, masked):
104
102
)
105
103
def test_examples_w2 (self , hap , expected , masked ):
106
104
hap = np .array (list (hap ), dtype = "U1" )
107
- a = convert .encode_alignment (hap )
105
+ a = sa .encode_alignment (hap )
108
106
expected = np .array (list (expected ), dtype = "U1" )
109
- m = convert .mask_alignment (a , 2 )
110
- assert np . sum (m ) == masked
111
- assert_array_equal (expected , convert .decode_alignment (a ))
107
+ m = sa .mask_alignment (a , window_size = 2 )
108
+ assert len (m ) == masked
109
+ assert_array_equal (expected , sa .decode_alignment (a ))
112
110
113
111
@pytest .mark .parametrize ("w" , [0 , - 1 , - 2 ])
114
112
def test_bad_window_size (self , w ):
115
113
a = np .zeros (2 , dtype = np .int8 )
116
114
with pytest .raises (ValueError ):
117
- convert .mask_alignment (a , w )
118
-
115
+ sa .mask_alignment (a , window_size = w )
0 commit comments