From e587f67c73866d4edbf90e1a44b11074912df600 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Thu, 4 Jan 2024 02:03:28 +0300 Subject: Add tests for parsing 'phenocovar' files. --- tests/r_qtl/test_files/test_phenocovar.zip | Bin 0 -> 516 bytes .../test_files/test_phenocovar_transposed.zip | Bin 0 -> 567 bytes tests/r_qtl/test_r_qtl2_pheno.py | 26 +++++++++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 tests/r_qtl/test_files/test_phenocovar.zip create mode 100644 tests/r_qtl/test_files/test_phenocovar_transposed.zip (limited to 'tests') 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 Binary files /dev/null and b/tests/r_qtl/test_files/test_phenocovar.zip 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 Binary files /dev/null and b/tests/r_qtl/test_files/test_phenocovar_transposed.zip 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 -- cgit v1.2.3