snplib 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env python
2
+ # coding: utf-8
3
+ __author__ = "Igor Loschinin (igor.loschinin@gmail.com)"
4
+
5
+ from .. import minor_allele_freq as maf
6
+
7
+ import pytest
8
+
9
+
10
+ class TestMinorAlleleFreq(object):
11
+
12
+ @pytest.mark.parametrize("value, res", [
13
+ (0.0, 0.0), (0.9, 0.1), (0.889, 0.111),
14
+ (0.714, 0.286), (0.22, 0.22), (0.45, 0.45), (0.6, 0.4)
15
+ ])
16
+ def test_minor_allele_freq(self, value: float, res: float) -> None:
17
+ assert maf(value) == res
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env python
2
+ # coding: utf-8
3
+ __author__ = "Igor Loschinin (igor.loschinin@gmail.com)"
4
+
5
+ from .. import hwe_test
6
+
7
+ import pytest
8
+ import pandas as pd
9
+
10
+
11
+ class TestHWE(object):
12
+
13
+ @pytest.mark.parametrize(
14
+ "seq, freq",
15
+ [
16
+ ('2212120', 0.714),
17
+ ('02011015010000500', 0.2),
18
+ ('01110152120222512', 0.6),
19
+ ('00005005005', 0.0),
20
+ ('22521212222', 0.9),
21
+ ('52221521222', 0.889)
22
+ ]
23
+ )
24
+ def test_hweT_true(self, seq: str, freq: float) -> None:
25
+ """
26
+ check snphwe gives expected p-values
27
+ """
28
+
29
+ _seq_snp = pd.Series(list(map(int, seq)))
30
+
31
+ assert hwe_test(_seq_snp, freq)
32
+
33
+ @pytest.mark.parametrize("seq, freq", [('000000000102', 0.125)])
34
+ def test_hweT_false(self, seq: str, freq: float) -> None:
35
+ """
36
+ check snphwe gives expected p-values
37
+ """
38
+
39
+ _seq_snp = pd.Series(list(map(int, seq)))
40
+
41
+ assert not hwe_test(_seq_snp, freq)
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env python
2
+ # coding: utf-8
3
+ __author__ = "Igor Loschinin (igor.loschinin@gmail.com)"
4
+
5
+ from .. import hwe
6
+
7
+ import pytest
8
+
9
+
10
+ class TestHWE(object):
11
+
12
+ def test_snphwe(self) -> None:
13
+ """
14
+ check snphwe gives expected p-values
15
+ """
16
+ assert hwe(500, 10, 5000) == 0.6515718999145375
17
+ assert hwe(1000, 20, 5000) == 1.2659849194317374e-05
18
+
19
+ def test_snphwe_odd_inputs(self) -> None:
20
+ """
21
+ check snphwe with odd inputs
22
+ """
23
+ # should raise errors with odd inputs
24
+
25
+ with pytest.raises(ValueError, match="snphwe: zero genotypes"):
26
+ hwe(0, 0, 0)
27
+
28
+ with pytest.raises(ValueError, match="snphwe: negative allele count"):
29
+ hwe(-5, 10, 1000)
30
+
31
+ def test_snphwe_large_input(self) -> None:
32
+ """
33
+ check snphwe doesn't give errors with large sample sizes
34
+ """
35
+ assert hwe(200000, 200000, 200000) == 0.0
36
+
37
+ def test_snphwe_uncertain_genotypes(self) -> None:
38
+ """
39
+ check uncertain genotypes give correct p-values
40
+ """
41
+ assert hwe(4989.99999, 494999.999, 9.9999999) == 0.5702231983054381