Skip to content

Commit c029f15

Browse files
Fixup alignment tests
1 parent 02ee0b8 commit c029f15

File tree

1 file changed

+17
-20
lines changed

1 file changed

+17
-20
lines changed

tests/test_convert.py

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
from numpy.testing import assert_array_equal
44

55
# FIXME - quick hacks here to get tests working
6-
from sc2ts import alignments as convert
6+
from sc2ts import alignments as sa
77
from sc2ts import core
88

9+
910
def test_get_gene_coordinates():
1011
d = core.get_gene_coordinates()
1112
assert len(d) == 11
@@ -29,26 +30,26 @@ class TestEncodeAligment:
2930
)
3031
def test_examples(self, hap, expected):
3132
h = np.array(list(hap), dtype="U1")
32-
a = convert.encode_alignment(h)
33+
a = sa.encode_alignment(h)
3334
assert_array_equal(a, expected)
34-
assert_array_equal(h, convert.decode_alignment(a))
35+
assert_array_equal(h, sa.decode_alignment(a))
3536

3637
@pytest.mark.parametrize("hap", "RYSWKMDHVN.")
3738
def test_iupac_uncertain_missing(self, hap):
3839
h = np.array(list(hap), dtype="U1")
39-
a = convert.encode_alignment(h)
40+
a = sa.encode_alignment(h)
4041
assert_array_equal(a, [-1])
4142

4243
@pytest.mark.parametrize("hap", "XZxz")
4344
def test_other_missing(self, hap):
4445
h = np.array(list(hap), dtype="U1")
45-
a = convert.encode_alignment(h)
46+
a = sa.encode_alignment(h)
4647
assert_array_equal(a, [-1])
4748

4849
@pytest.mark.parametrize("hap", "acgt")
4950
def test_lowercase_nucleotide_missing(self, hap):
5051
h = np.array(list(hap), dtype="U1")
51-
a = convert.encode_alignment(h)
52+
a = sa.encode_alignment(h)
5253
assert_array_equal(a, [-1])
5354

5455
@pytest.mark.parametrize(
@@ -63,13 +64,10 @@ def test_lowercase_nucleotide_missing(self, hap):
6364
)
6465
def test_examples(self, a):
6566
with pytest.raises(ValueError):
66-
convert.decode_alignment(np.array(a))
67+
sa.decode_alignment(np.array(a))
6768

6869

69-
# TODO fixup these tests
70-
@pytest.mark.skip
7170
class TestMasking:
72-
7371
# Window size of 1 is weird because we have to have two or more
7472
# ambiguous characters. That means we only filter if something is
7573
# surrounded.
@@ -85,11 +83,11 @@ class TestMasking:
8583
)
8684
def test_examples_w1(self, hap, expected, masked):
8785
hap = np.array(list(hap), dtype="U1")
88-
a = convert.encode_alignment(hap)
86+
a = sa.encode_alignment(hap)
8987
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))
9391

9492
@pytest.mark.parametrize(
9593
["hap", "expected", "masked"],
@@ -104,15 +102,14 @@ def test_examples_w1(self, hap, expected, masked):
104102
)
105103
def test_examples_w2(self, hap, expected, masked):
106104
hap = np.array(list(hap), dtype="U1")
107-
a = convert.encode_alignment(hap)
105+
a = sa.encode_alignment(hap)
108106
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))
112110

113111
@pytest.mark.parametrize("w", [0, -1, -2])
114112
def test_bad_window_size(self, w):
115113
a = np.zeros(2, dtype=np.int8)
116114
with pytest.raises(ValueError):
117-
convert.mask_alignment(a, w)
118-
115+
sa.mask_alignment(a, window_size=w)

0 commit comments

Comments
 (0)