aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-12-27 08:08:31 +0300
committerFrederick Muriuki Muriithi2023-12-27 08:08:31 +0300
commit46410163ca402660434b09a8fc8ec7b12b89d8a1 (patch)
tree7fc55ed054a4770ca4fd72c44e6dd501deb668b6 /tests
parent8ababbb1cfbdbf3c26d9599253c6d45670c49046 (diff)
downloadgn-uploader-46410163ca402660434b09a8fc8ec7b12b89d8a1.tar.gz
Tests: Add tests for parsing gmap files.
Diffstat (limited to 'tests')
-rw-r--r--tests/r_qtl/test_files/test_gmap.zipbin0 -> 542 bytes
-rw-r--r--tests/r_qtl/test_files/test_gmap_transposed.zipbin0 -> 594 bytes
-rw-r--r--tests/r_qtl/test_r_qtl2.py47
3 files changed, 47 insertions, 0 deletions
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
--- /dev/null
+++ b/tests/r_qtl/test_files/test_gmap.zip
Binary files 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
--- /dev/null
+++ b/tests/r_qtl/test_files/test_gmap_transposed.zip
Binary files 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.
+ """