aboutsummaryrefslogtreecommitdiff
path: root/tests/r_qtl/test_r_qtl2_geno.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-12-27 12:12:33 +0300
committerFrederick Muriuki Muriithi2023-12-27 12:14:53 +0300
commitc687f9460ca071c714cdc9cba62449b59b001de8 (patch)
tree48ad3343cbea9dddaa0e374a38cd11cb38c26fe5 /tests/r_qtl/test_r_qtl2_geno.py
parent3294adc11ada56046ff748c08b97faf0eeed11b2 (diff)
downloadgn-uploader-c687f9460ca071c714cdc9cba62449b59b001de8.tar.gz
Tests: Test parsing of non-transposed geno files.
Check that the parsing of non-transposed geno files. Leave in failing test for transposed geno files.
Diffstat (limited to 'tests/r_qtl/test_r_qtl2_geno.py')
-rw-r--r--tests/r_qtl/test_r_qtl2_geno.py182
1 files changed, 182 insertions, 0 deletions
diff --git a/tests/r_qtl/test_r_qtl2_geno.py b/tests/r_qtl/test_r_qtl2_geno.py
new file mode 100644
index 0000000..5ebb5a9
--- /dev/null
+++ b/tests/r_qtl/test_r_qtl2_geno.py
@@ -0,0 +1,182 @@
+"""Test the parsing of the R/qtl2 geno files."""
+from pathlib import Path
+
+import pytest
+from zipfile import ZipFile
+
+from r_qtl import r_qtl2 as rqtl2
+
+@pytest.mark.unit_test
+@pytest.mark.parametrize(
+ "relpath,expected",
+ (
+ ("tests/r_qtl/test_files/test_geno.zip",
+ ({
+ "id": "1",
+ "PVV4": 1,
+ "AXR-1": 1,
+ "HH.335C-Col/PhyA": 1,
+ "EC.480C": 1,
+ "EC.66C": 1
+ },
+ {
+ "id": "2",
+ "PVV4": 1,
+ "AXR-1": 1,
+ "HH.335C-Col/PhyA": 1,
+ "EC.480C": 1,
+ "EC.66C": 1
+ },
+ {
+ "id": "3",
+ "PVV4": 2,
+ "AXR-1": 2,
+ "HH.335C-Col/PhyA": None,
+ "EC.480C": 1,
+ "EC.66C": 1
+ },
+ {
+ "id": "4",
+ "PVV4": 1,
+ "AXR-1": 1,
+ "HH.335C-Col/PhyA": 1,
+ "EC.480C": 1,
+ "EC.66C": 1
+ },
+ {
+ "id": "5",
+ "PVV4": 2,
+ "AXR-1": 2,
+ "HH.335C-Col/PhyA": 2,
+ "EC.480C": 2,
+ "EC.66C": 2
+ },
+ {
+ "id": "6",
+ "PVV4": 2,
+ "AXR-1": 2,
+ "HH.335C-Col/PhyA": 2,
+ "EC.480C": 2,
+ "EC.66C": 2
+ },
+ {
+ "id": "7",
+ "PVV4": 1,
+ "AXR-1": 1,
+ "HH.335C-Col/PhyA": 1,
+ "EC.480C": 1,
+ "EC.66C": 1
+ },
+ {
+ "id": "8",
+ "PVV4": 2,
+ "AXR-1": 2,
+ "HH.335C-Col/PhyA": 2,
+ "EC.480C": 1,
+ "EC.66C": 1
+ },
+ {
+ "id": "9",
+ "PVV4": None,
+ "AXR-1": 2,
+ "HH.335C-Col/PhyA": 2,
+ "EC.480C": 2,
+ "EC.66C": 2
+ },
+ {
+ "id": "10",
+ "PVV4": 2,
+ "AXR-1": 2,
+ "HH.335C-Col/PhyA": 2,
+ "EC.480C": 2,
+ "EC.66C": 2
+ })),
+ ("tests/r_qtl/test_files/test_geno_transposed.zip",
+ ({
+ "id": "1",
+ "PVV4": 1,
+ "AXR-1": 1,
+ "HH.335C-Col/PhyA": 1,
+ "EC.480C": 1,
+ "EC.66C": 1
+ },
+ {
+ "id": "2",
+ "PVV4": 1,
+ "AXR-1": 1,
+ "HH.335C-Col/PhyA": 1,
+ "EC.480C": 1,
+ "EC.66C": 1
+ },
+ {
+ "id": "3",
+ "PVV4": 2,
+ "AXR-1": 2,
+ "HH.335C-Col/PhyA": None,
+ "EC.480C": 1,
+ "EC.66C": 1
+ },
+ {
+ "id": "4",
+ "PVV4": 1,
+ "AXR-1": 1,
+ "HH.335C-Col/PhyA": 1,
+ "EC.480C": 1,
+ "EC.66C": 1
+ },
+ {
+ "id": "5",
+ "PVV4": 2,
+ "AXR-1": 2,
+ "HH.335C-Col/PhyA": 2,
+ "EC.480C": 2,
+ "EC.66C": 2
+ },
+ {
+ "id": "6",
+ "PVV4": 2,
+ "AXR-1": 2,
+ "HH.335C-Col/PhyA": 2,
+ "EC.480C": 2,
+ "EC.66C": 2
+ },
+ {
+ "id": "7",
+ "PVV4": 1,
+ "AXR-1": 1,
+ "HH.335C-Col/PhyA": 1,
+ "EC.480C": 1,
+ "EC.66C": 1
+ },
+ {
+ "id": "8",
+ "PVV4": 2,
+ "AXR-1": 2,
+ "HH.335C-Col/PhyA": 2,
+ "EC.480C": 1,
+ "EC.66C": 1
+ },
+ {
+ "id": "9",
+ "PVV4": None,
+ "AXR-1": 2,
+ "HH.335C-Col/PhyA": 2,
+ "EC.480C": 2,
+ "EC.66C": 2
+ },
+ {
+ "id": "10",
+ "PVV4": 2,
+ "AXR-1": 2,
+ "HH.335C-Col/PhyA": 2,
+ "EC.480C": 2,
+ "EC.66C": 2
+ }))))
+def test_parse_geno_files(relpath,expected):
+ """
+ GIVEN: Path to a zip file with R/qtl2 data
+ WHEN: we parse the geno file
+ THEN: ensure that the data we get is as expected
+ """
+ with ZipFile(Path(relpath).absolute(), "r") as zfile:
+ assert tuple(rqtl2.genotype_data(zfile, rqtl2.control_data(zfile))) == expected