From 46410163ca402660434b09a8fc8ec7b12b89d8a1 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Wed, 27 Dec 2023 08:08:31 +0300 Subject: Tests: Add tests for parsing gmap files. --- tests/r_qtl/test_files/test_gmap.zip | Bin 0 -> 542 bytes tests/r_qtl/test_files/test_gmap_transposed.zip | Bin 0 -> 594 bytes tests/r_qtl/test_r_qtl2.py | 47 ++++++++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 tests/r_qtl/test_files/test_gmap.zip create mode 100644 tests/r_qtl/test_files/test_gmap_transposed.zip create mode 100644 tests/r_qtl/test_r_qtl2.py (limited to 'tests') diff --git a/tests/r_qtl/test_files/test_gmap.zip b/tests/r_qtl/test_files/test_gmap.zip new file mode 100644 index 0000000..c8d452a Binary files /dev/null and b/tests/r_qtl/test_files/test_gmap.zip differ diff --git a/tests/r_qtl/test_files/test_gmap_transposed.zip b/tests/r_qtl/test_files/test_gmap_transposed.zip new file mode 100644 index 0000000..74a956e Binary files /dev/null and b/tests/r_qtl/test_files/test_gmap_transposed.zip differ 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. + """ -- cgit v1.2.3