From cb3851a91d63a29b808f44eb91c00df91641e380 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Fri, 2 Feb 2024 14:22:06 +0300 Subject: Ensure control file defaults are set up in code. --- tests/r_qtl/test_files/empty_control_file_json.zip | Bin 0 -> 251 bytes tests/r_qtl/test_files/empty_control_file_yaml.zip | Bin 0 -> 245 bytes tests/r_qtl/test_r_qtl2_control_file.py | 38 +++++++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 tests/r_qtl/test_files/empty_control_file_json.zip create mode 100644 tests/r_qtl/test_files/empty_control_file_yaml.zip create mode 100644 tests/r_qtl/test_r_qtl2_control_file.py (limited to 'tests') diff --git a/tests/r_qtl/test_files/empty_control_file_json.zip b/tests/r_qtl/test_files/empty_control_file_json.zip new file mode 100644 index 0000000..94cab39 Binary files /dev/null and b/tests/r_qtl/test_files/empty_control_file_json.zip differ diff --git a/tests/r_qtl/test_files/empty_control_file_yaml.zip b/tests/r_qtl/test_files/empty_control_file_yaml.zip new file mode 100644 index 0000000..daf607f Binary files /dev/null and b/tests/r_qtl/test_files/empty_control_file_yaml.zip differ diff --git a/tests/r_qtl/test_r_qtl2_control_file.py b/tests/r_qtl/test_r_qtl2_control_file.py new file mode 100644 index 0000000..316307d --- /dev/null +++ b/tests/r_qtl/test_r_qtl2_control_file.py @@ -0,0 +1,38 @@ +"""Test the parsing of control file""" +from pathlib import Path + +import pytest +from zipfile import ZipFile + +from r_qtl import r_qtl2 as rqtl2 + +__DEFAULTS__ = { + "description": "Empty control file to test defaults", + "sep": ",", + "na.strings": ["NA"], + "comment.char": "#", + "geno_transposed": False, + "founder_geno_transposed": False, + "pheno_transposed": False, + "covar_transposed": False, + "phenocovar_transposed": False, + "gmap_transposed": False, + "pmap_transposed": False, + "phenose_transposed": False +} + +@pytest.mark.unit_test +@pytest.mark.parametrize( + "filepath,expected", + (("tests/r_qtl/test_files/empty_control_file_yaml.zip", + __DEFAULTS__), + ("tests/r_qtl/test_files/empty_control_file_json.zip", + __DEFAULTS__))) +def test_defaults_are_set(filepath, expected): + """ + GIVEN: path to a R/qtl2 bundle with an empty control file + WHEN: the control data is parsed + THEN: ensure all the defaults are set up correctly + """ + with ZipFile(Path(filepath).absolute(), "r") as zfile: + assert rqtl2.control_data(zfile) == expected -- cgit v1.2.3