diff options
author | Frederick Muriuki Muriithi | 2024-01-04 17:35:48 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2024-01-04 17:35:48 +0300 |
commit | 5f5cc8503ec10319ee4d9e7d6bd739cc6190561c (patch) | |
tree | 8d92b71cd7e4870693f696e97d5dad82651c8a76 /tests/r_qtl/test_r_qtl2_sex_information.py | |
parent | 6b2002f236188e3c2571af18642527b156ed60e0 (diff) | |
download | gn-uploader-5f5cc8503ec10319ee4d9e7d6bd739cc6190561c.tar.gz |
Parse sex information from R/qtl bundle.
Diffstat (limited to 'tests/r_qtl/test_r_qtl2_sex_information.py')
-rw-r--r-- | tests/r_qtl/test_r_qtl2_sex_information.py | 35 |
1 files changed, 35 insertions, 0 deletions
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 |