From 5f5cc8503ec10319ee4d9e7d6bd739cc6190561c Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Thu, 4 Jan 2024 17:35:48 +0300 Subject: Parse sex information from R/qtl bundle. --- tests/r_qtl/test_files/test_cross_info_01.zip | Bin 597 -> 594 bytes tests/r_qtl/test_files/test_cross_info_02.zip | Bin 778 -> 775 bytes tests/r_qtl/test_files/test_sex_info_01.zip | Bin 0 -> 589 bytes tests/r_qtl/test_files/test_sex_info_02.zip | Bin 0 -> 773 bytes tests/r_qtl/test_r_qtl2_sex_information.py | 35 ++++++++++++++++++++++++++ 5 files changed, 35 insertions(+) create mode 100644 tests/r_qtl/test_files/test_sex_info_01.zip create mode 100644 tests/r_qtl/test_files/test_sex_info_02.zip create mode 100644 tests/r_qtl/test_r_qtl2_sex_information.py (limited to 'tests/r_qtl') diff --git a/tests/r_qtl/test_files/test_cross_info_01.zip b/tests/r_qtl/test_files/test_cross_info_01.zip index 1211f96..6143a9f 100644 Binary files a/tests/r_qtl/test_files/test_cross_info_01.zip and b/tests/r_qtl/test_files/test_cross_info_01.zip differ diff --git a/tests/r_qtl/test_files/test_cross_info_02.zip b/tests/r_qtl/test_files/test_cross_info_02.zip index dddd281..7e23fc4 100644 Binary files a/tests/r_qtl/test_files/test_cross_info_02.zip and b/tests/r_qtl/test_files/test_cross_info_02.zip differ diff --git a/tests/r_qtl/test_files/test_sex_info_01.zip b/tests/r_qtl/test_files/test_sex_info_01.zip new file mode 100644 index 0000000..bc60d84 Binary files /dev/null and b/tests/r_qtl/test_files/test_sex_info_01.zip differ diff --git a/tests/r_qtl/test_files/test_sex_info_02.zip b/tests/r_qtl/test_files/test_sex_info_02.zip new file mode 100644 index 0000000..c862b73 Binary files /dev/null and b/tests/r_qtl/test_files/test_sex_info_02.zip differ diff --git a/tests/r_qtl/test_r_qtl2_sex_information.py b/tests/r_qtl/test_r_qtl2_sex_information.py new file mode 100644 index 0000000..90eae8d --- /dev/null +++ b/tests/r_qtl/test_r_qtl2_sex_information.py @@ -0,0 +1,35 @@ +"""Test loading of sex information.""" + +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_sex_info_01.zip", + ({"id": "1", "sex": "male"}, + {"id": "2", "sex": "male"}, + {"id": "3", "sex": "male"}, + {"id": "71", "sex": "male"}, + {"id": "72", "sex": "male"}, + {"id": "146", "sex": "female"}, + {"id": "147", "sex": "female"}, + {"id": "148", "sex": "female"})), + ("tests/r_qtl/test_files/test_sex_info_02.zip", + ({"id": "1", "sex": "male"}, + {"id": "2", "sex": "male"}, + {"id": "3", "sex": "male"}, + {"id": "71", "sex": "male"}, + {"id": "72", "sex": "male"}, + {"id": "146", "sex": "female"}, + {"id": "147", "sex": "female"}, + {"id": "148", "sex": "female"})))) +def test_parse_sex_info(filepath, expected): + """Test parsing of sex information.""" + with ZipFile(Path(filepath).absolute(), "r") as zfile: + assert tuple(rqtl2.sex_information( + zfile, rqtl2.control_data(zfile))) == expected -- cgit v1.2.3