From 0f1dda20ea48f0fa411ff63f86b7e4b9c07e7c99 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Thu, 4 Jan 2024 01:28:58 +0300 Subject: Rename test module. --- tests/r_qtl/test_r_qtl2_gmap.py | 48 ------------------------------------ tests/r_qtl/test_r_qtl2_map_files.py | 48 ++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 48 deletions(-) delete mode 100644 tests/r_qtl/test_r_qtl2_gmap.py create mode 100644 tests/r_qtl/test_r_qtl2_map_files.py (limited to 'tests/r_qtl') diff --git a/tests/r_qtl/test_r_qtl2_gmap.py b/tests/r_qtl/test_r_qtl2_gmap.py deleted file mode 100644 index 5c8ca6a..0000000 --- a/tests/r_qtl/test_r_qtl2_gmap.py +++ /dev/null @@ -1,48 +0,0 @@ -"""Test the parsing of the R/qtl2 gmap 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,mapfiletype,expected", - (("tests/r_qtl/test_files/test_gmap.zip", - "gmap", - ({"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", - "gmap", - ({"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_pmap.zip", - "pmap", - ({"marker": "D1Mit18", "chr": "1", "pos": "52.418656"}, - {"marker": "D1Mit80", "chr": "1", "pos": "86.377953"}, - {"marker": "D1Mit17", "chr": "1", "pos": "189.571337"}, - {"marker": "D2Mit379", "chr": "2", "pos": "37.451062"}, - {"marker": "D2Mit75", "chr": "2", "pos": "80.584782"})), - ("tests/r_qtl/test_files/test_pmap_transposed.zip", - "pmap", - ({"marker": "D1Mit18", "chr": "1", "pos": "52.418656"}, - {"marker": "D1Mit80", "chr": "1", "pos": "86.377953"}, - {"marker": "D1Mit17", "chr": "1", "pos": "189.571337"}, - {"marker": "D2Mit379", "chr": "2", "pos": "37.451062"}, - {"marker": "D2Mit75", "chr": "2", "pos": "80.584782"})))) -def test_parse_map_files(relpath, mapfiletype, expected): - """ - GIVEN: A path to a zip file, `relpath` and the type of the map file, - WHEN: we parse the R/qtl2 map file, - THEN: ensure the parsed data is as expected. - """ - with ZipFile(Path(relpath).absolute(), "r") as zfile: - cdata = rqtl2.control_data(zfile) - assert tuple(rqtl2.file_data(zfile, mapfiletype, cdata)) == expected diff --git a/tests/r_qtl/test_r_qtl2_map_files.py b/tests/r_qtl/test_r_qtl2_map_files.py new file mode 100644 index 0000000..5c8ca6a --- /dev/null +++ b/tests/r_qtl/test_r_qtl2_map_files.py @@ -0,0 +1,48 @@ +"""Test the parsing of the R/qtl2 gmap 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,mapfiletype,expected", + (("tests/r_qtl/test_files/test_gmap.zip", + "gmap", + ({"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", + "gmap", + ({"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_pmap.zip", + "pmap", + ({"marker": "D1Mit18", "chr": "1", "pos": "52.418656"}, + {"marker": "D1Mit80", "chr": "1", "pos": "86.377953"}, + {"marker": "D1Mit17", "chr": "1", "pos": "189.571337"}, + {"marker": "D2Mit379", "chr": "2", "pos": "37.451062"}, + {"marker": "D2Mit75", "chr": "2", "pos": "80.584782"})), + ("tests/r_qtl/test_files/test_pmap_transposed.zip", + "pmap", + ({"marker": "D1Mit18", "chr": "1", "pos": "52.418656"}, + {"marker": "D1Mit80", "chr": "1", "pos": "86.377953"}, + {"marker": "D1Mit17", "chr": "1", "pos": "189.571337"}, + {"marker": "D2Mit379", "chr": "2", "pos": "37.451062"}, + {"marker": "D2Mit75", "chr": "2", "pos": "80.584782"})))) +def test_parse_map_files(relpath, mapfiletype, expected): + """ + GIVEN: A path to a zip file, `relpath` and the type of the map file, + WHEN: we parse the R/qtl2 map file, + THEN: ensure the parsed data is as expected. + """ + with ZipFile(Path(relpath).absolute(), "r") as zfile: + cdata = rqtl2.control_data(zfile) + assert tuple(rqtl2.file_data(zfile, mapfiletype, cdata)) == expected -- cgit v1.2.3