aboutsummaryrefslogtreecommitdiff
path: root/tests/r_qtl/test_r_qtl2_control_file.py
blob: 316307dcb75519c095de2f74feb6b1b604508e56 (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
"""Test the parsing of control file"""
from pathlib import Path

import pytest
from zipfile import ZipFile

from r_qtl import r_qtl2 as rqtl2

__DEFAULTS__ = {
    "description": "Empty control file to test defaults",
    "sep": ",",
    "na.strings": ["NA"],
    "comment.char": "#",
    "geno_transposed": False,
    "founder_geno_transposed": False,
    "pheno_transposed": False,
    "covar_transposed": False,
    "phenocovar_transposed": False,
    "gmap_transposed": False,
    "pmap_transposed": False,
    "phenose_transposed": False
}

@pytest.mark.unit_test
@pytest.mark.parametrize(
    "filepath,expected",
    (("tests/r_qtl/test_files/empty_control_file_yaml.zip",
      __DEFAULTS__),
     ("tests/r_qtl/test_files/empty_control_file_json.zip",
      __DEFAULTS__)))
def test_defaults_are_set(filepath, expected):
    """
    GIVEN: path to a R/qtl2 bundle with an empty control file
    WHEN: the control data is parsed
    THEN: ensure all the defaults are set up correctly
    """
    with ZipFile(Path(filepath).absolute(), "r") as zfile:
        assert rqtl2.control_data(zfile) == expected