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
48
|
"""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,mapfiletype,expected",
(("tests/r_qtl/test_files/test_gmap.zip",
"genetic-map",
({"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",
"genetic-map",
({"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",
"physical-map",
({"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",
"physical-map",
({"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:
assert rqtl2.map_data(
zfile, mapfiletype, rqtl2.control_data(zfile)) == expected
|