aboutsummaryrefslogtreecommitdiff
path: root/tests/r_qtl/test_r_qtl2_qc.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/r_qtl/test_r_qtl2_qc.py')
-rw-r--r--tests/r_qtl/test_r_qtl2_qc.py30
1 files changed, 24 insertions, 6 deletions
diff --git a/tests/r_qtl/test_r_qtl2_qc.py b/tests/r_qtl/test_r_qtl2_qc.py
index bcbcbac..1c96a86 100644
--- a/tests/r_qtl/test_r_qtl2_qc.py
+++ b/tests/r_qtl/test_r_qtl2_qc.py
@@ -7,10 +7,6 @@ from zipfile import ZipFile
from r_qtl import r_qtl2 as rqtl2
from r_qtl import r_qtl2_qc as rqc
-###### DO NOT COMMIT THIS ######
-from quality_control.debug import __pk__
-###### END: DO NOT COMMIT THIS ######
-
@pytest.mark.unit_test
@pytest.mark.parametrize(
"filepath,expected",
@@ -93,8 +89,8 @@ def test_missing_files(filepath, expected):
("tests/r_qtl/test_files/test_geno.zip",
tuple()),
("tests/r_qtl/test_files/geno_with_missing_genotypes.zip",
- ((1, "AXR-1", f"Invalid value 'X'. Expected one of ('L', 'C')"),
- (2, "EC.480C", f"Invalid value 'Y'. Expected one of ('L', 'C')"),
+ ((1, "AXR-1", "Invalid value 'X'. Expected one of ('L', 'C')"),
+ (2, "EC.480C", "Invalid value 'Y'. Expected one of ('L', 'C')"),
(6, "HH.335C-Col/PhyA", f"Invalid value 'H'. Expected one of ('L', 'C')")))))
def test_geno_errors(filepath, expected):
"""
@@ -105,3 +101,25 @@ def test_geno_errors(filepath, expected):
"""
with ZipFile(Path(filepath).absolute(), "r") as zfile:
assert tuple(rqc.geno_errors(zfile)) == expected
+
+@pytest.mark.unit_test
+@pytest.mark.parametrize(
+ "filepath,expected",
+ (("tests/r_qtl/test_files/empty_control_file_yaml.zip",
+ ((None, None, "Missing 'pheno' file."),)),
+ ("tests/r_qtl/test_files/pheno_without_errors.zip",
+ tuple()),
+ ("tests/r_qtl/test_files/pheno_with_errors.zip",
+ ((1, "liver", ("Invalid value '61.92'. Expected numerical value "
+ "with at least 3 decimal places.")),
+ (2, "spleen", ("Invalid value 'brrr'. Expected numerical value "
+ "with at least 3 decimal places."))))))
+def test_pheno_errors(filepath, expected):
+ """
+ GIVEN: A R/qtl2 bundle
+ WHEN: we check for pheno errors
+ THEN: We should get a sequence of all errors present in the pheno file, or
+ an empty sequence if no errors exist.
+ """
+ with ZipFile(Path(filepath).absolute(), "r") as zfile:
+ assert tuple(rqc.pheno_errors(zfile)) == expected