aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-01-04 02:03:28 +0300
committerFrederick Muriuki Muriithi2024-01-04 02:03:28 +0300
commite587f67c73866d4edbf90e1a44b11074912df600 (patch)
treea5813c8028575b0d1c701ebce3d32a733ded2ec5
parent0f1dda20ea48f0fa411ff63f86b7e4b9c07e7c99 (diff)
downloadgn-uploader-e587f67c73866d4edbf90e1a44b11074912df600.tar.gz
Add tests for parsing 'phenocovar' files.
-rw-r--r--tests/r_qtl/test_files/test_phenocovar.zipbin0 -> 516 bytes
-rw-r--r--tests/r_qtl/test_files/test_phenocovar_transposed.zipbin0 -> 567 bytes
-rw-r--r--tests/r_qtl/test_r_qtl2_pheno.py26
3 files changed, 26 insertions, 0 deletions
diff --git a/tests/r_qtl/test_files/test_phenocovar.zip b/tests/r_qtl/test_files/test_phenocovar.zip
new file mode 100644
index 0000000..7b8f079
--- /dev/null
+++ b/tests/r_qtl/test_files/test_phenocovar.zip
Binary files differ
diff --git a/tests/r_qtl/test_files/test_phenocovar_transposed.zip b/tests/r_qtl/test_files/test_phenocovar_transposed.zip
new file mode 100644
index 0000000..e3f9185
--- /dev/null
+++ b/tests/r_qtl/test_files/test_phenocovar_transposed.zip
Binary files differ
diff --git a/tests/r_qtl/test_r_qtl2_pheno.py b/tests/r_qtl/test_r_qtl2_pheno.py
index 46be469..66850a0 100644
--- a/tests/r_qtl/test_r_qtl2_pheno.py
+++ b/tests/r_qtl/test_r_qtl2_pheno.py
@@ -31,3 +31,29 @@ def test_parse_pheno_files(filepath, expected):
with ZipFile(Path(filepath).absolute(), "r") as zfile:
cdata = rqtl2.control_data(zfile)
assert tuple(rqtl2.file_data(zfile, "pheno", cdata)) == expected
+
+@pytest.mark.unit_test
+@pytest.mark.parametrize(
+ "filepath,expected",
+ (("tests/r_qtl/test_files/test_phenocovar.zip",
+ ({"pheno": "T0", "time (hrs)": "0"},
+ {"pheno": "T2", "time (hrs)": "0.0333333333333333"},
+ {"pheno": "T4", "time (hrs)": "0.0666666666666667"},
+ {"pheno": "T6", "time (hrs)": "0.1"},
+ {"pheno": "T8", "time (hrs)": "0.133333333333333"})),
+ ("tests/r_qtl/test_files/test_phenocovar_transposed.zip",
+ ({"pheno": "T0", "time (hrs)": "0"},
+ {"pheno": "T2", "time (hrs)": "0.0333333333333333"},
+ {"pheno": "T4", "time (hrs)": "0.0666666666666667"},
+ {"pheno": "T6", "time (hrs)": "0.1"},
+ {"pheno": "T8", "time (hrs)": "0.133333333333333"}))))
+def test_parse_phenocovar_files(filepath, expected):
+ """Test parsing of 'phenocovar' files from the R/qtl2 bundle.
+
+ GIVEN: path to a R/qtl2 bundle
+ WHEN: the 'phenocovar' 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, "phenocovar", cdata)) == expected