diff options
author | Frederick Muriuki Muriithi | 2024-01-04 02:03:28 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2024-01-04 02:03:28 +0300 |
commit | e587f67c73866d4edbf90e1a44b11074912df600 (patch) | |
tree | a5813c8028575b0d1c701ebce3d32a733ded2ec5 /tests | |
parent | 0f1dda20ea48f0fa411ff63f86b7e4b9c07e7c99 (diff) | |
download | gn-uploader-e587f67c73866d4edbf90e1a44b11074912df600.tar.gz |
Add tests for parsing 'phenocovar' files.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/r_qtl/test_files/test_phenocovar.zip | bin | 0 -> 516 bytes | |||
-rw-r--r-- | tests/r_qtl/test_files/test_phenocovar_transposed.zip | bin | 0 -> 567 bytes | |||
-rw-r--r-- | tests/r_qtl/test_r_qtl2_pheno.py | 26 |
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 Binary files differnew file mode 100644 index 0000000..7b8f079 --- /dev/null +++ b/tests/r_qtl/test_files/test_phenocovar.zip diff --git a/tests/r_qtl/test_files/test_phenocovar_transposed.zip b/tests/r_qtl/test_files/test_phenocovar_transposed.zip Binary files differnew file mode 100644 index 0000000..e3f9185 --- /dev/null +++ b/tests/r_qtl/test_files/test_phenocovar_transposed.zip 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 |