diff options
Diffstat (limited to 'tests/r_qtl/test_r_qtl2.py')
-rw-r--r-- | tests/r_qtl/test_r_qtl2.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/r_qtl/test_r_qtl2.py b/tests/r_qtl/test_r_qtl2.py new file mode 100644 index 0000000..a72b300 --- /dev/null +++ b/tests/r_qtl/test_r_qtl2.py @@ -0,0 +1,47 @@ +"""Test the parsing of the R/qtl2 data files.""" +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( + "relpath,expected", + (("tests/r_qtl/test_files/test_gmap.zip", + ({"marker": "PVV4", "chr": "1", "pos": "0.000000"}, + {"marker": "AXR-1", "chr": "1", "pos": "6.250674"}, + {"marker": "HH.335C-Col/PhyA", "chr": "1", "pos": "9.303868"}, + {"marker": "EC.480C", "chr": "1", "pos": "12.577629"}, + {"marker": "EC.66C", "chr": "1", "pos": "18.392830"})), + ("tests/r_qtl/test_files/test_gmap_transposed.zip", + ({"marker": "PVV4", "chr": "1", "pos": "0.000000"}, + {"marker": "AXR-1", "chr": "1", "pos": "6.250674"}, + {"marker": "HH.335C-Col/PhyA", "chr": "1", "pos": "9.303868"}, + {"marker": "EC.480C", "chr": "1", "pos": "12.577629"}, + {"marker": "EC.66C", "chr": "1", "pos": "18.392830"})))) +def test_parse_gmap_files(relpath, expected): + """ + GIVEN: A path to a zip file, `relpath` + WHEN: we parse a gmap file + THEN: ensure the parsed data is as expected. + """ + with ZipFile(Path(relpath).absolute(), "r") as zfile: + assert rqtl2.map_data( + zfile, "genetic-map", rqtl2.control_data(zfile)) == expected + +@pytest.mark.skip(reason="Test not implemented yet.") +@pytest.mark.unit_test +@pytest.mark.parametrize( + "relpath,expected", + (("tests/r_qtl/test_files/test_pmap.zip", + ()), + ("tests/r_qtl/test_files/test_pmap_transposed.zip", + ()))) +def test_parse_pmap_files(relpath, expected): + """ + GIVEN: A path to a zip file, `relpath` + WHEN: we parse a pmap file + THEN: ensure the parsed data is as expected. + """ |