aboutsummaryrefslogtreecommitdiff
path: root/tests/r_qtl/test_r_qtl2.py
blob: a72b3005f4599ea7fefd5bf1417634e54a339b71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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.
    """