aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-01-04 02:18:58 +0300
committerFrederick Muriuki Muriithi2024-01-04 02:18:58 +0300
commit1c847583e22b47c7b51632c13a4e2fc18e90e02b (patch)
treea68082aa2d48aa43f35fbeb9981cb0eb69a8bb02
parente587f67c73866d4edbf90e1a44b11074912df600 (diff)
downloadgn-uploader-1c847583e22b47c7b51632c13a4e2fc18e90e02b.tar.gz
Add tests for parsing cross information (covar) files.
-rw-r--r--tests/r_qtl/test_files/test_covar.zipbin0 -> 490 bytes
-rw-r--r--tests/r_qtl/test_files/test_covar_transposed.zipbin0 -> 541 bytes
-rw-r--r--tests/r_qtl/test_r_qtl2_cross_information.py36
3 files changed, 36 insertions, 0 deletions
diff --git a/tests/r_qtl/test_files/test_covar.zip b/tests/r_qtl/test_files/test_covar.zip
new file mode 100644
index 0000000..6fbb5e9
--- /dev/null
+++ b/tests/r_qtl/test_files/test_covar.zip
Binary files differ
diff --git a/tests/r_qtl/test_files/test_covar_transposed.zip b/tests/r_qtl/test_files/test_covar_transposed.zip
new file mode 100644
index 0000000..5e933cc
--- /dev/null
+++ b/tests/r_qtl/test_files/test_covar_transposed.zip
Binary files differ
diff --git a/tests/r_qtl/test_r_qtl2_cross_information.py b/tests/r_qtl/test_r_qtl2_cross_information.py
new file mode 100644
index 0000000..f004fd3
--- /dev/null
+++ b/tests/r_qtl/test_r_qtl2_cross_information.py
@@ -0,0 +1,36 @@
+"""Test parsing of cross-information 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(
+ "filepath,expected",
+ (("tests/r_qtl/test_files/test_covar.zip",
+ ({"id": "1", "sex": "m", "cross_direction": "(BxS)x(BxS)"},
+ {"id": "2", "sex": "m", "cross_direction": "(BxS)x(BxS)"},
+ {"id": "3", "sex": "m", "cross_direction": "(BxS)x(BxS)"},
+ {"id": "146", "sex": "f", "cross_direction": "(BxS)x(BxS)"},
+ {"id": "147", "sex": "f", "cross_direction": "(BxS)x(BxS)"},
+ {"id": "148", "sex": "f", "cross_direction": "(BxS)x(BxS)"})),
+ ("tests/r_qtl/test_files/test_covar_transposed.zip",
+ ({"id": "1", "sex": "m", "cross_direction": "(BxS)x(BxS)"},
+ {"id": "2", "sex": "m", "cross_direction": "(BxS)x(BxS)"},
+ {"id": "3", "sex": "m", "cross_direction": "(BxS)x(BxS)"},
+ {"id": "146", "sex": "f", "cross_direction": "(BxS)x(BxS)"},
+ {"id": "147", "sex": "f", "cross_direction": "(BxS)x(BxS)"},
+ {"id": "148", "sex": "f", "cross_direction": "(BxS)x(BxS)"})),
+ ))
+def test_parse_covar_files(filepath, expected):
+ """Test parsing of 'covar' files from the R/qtl2 bundle.
+
+ GIVEN: path to a R/qtl2 bundle
+ WHEN: the 'covar' file is parsed
+ THEN: verify the parsed data is as expected
+ """
+ with ZipFile(Path(filepath).absolute(), "r") as zfile:
+ cdata = rqtl2.control_data(zfile)
+ assert tuple(rqtl2.file_data(zfile, "covar", cdata)) == expected