diff options
author | Frederick Muriuki Muriithi | 2024-02-06 06:01:35 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2024-02-06 06:07:46 +0300 |
commit | b59ddf47a8f968e23aae6985986806ad5d704474 (patch) | |
tree | f19a26b238e0b85ceee864fc9fb3dd9d0e6fcbf8 /tests | |
parent | f98d0325e641dd43e0ac460ef4fa931eb94c054f (diff) | |
download | gn-uploader-b59ddf47a8f968e23aae6985986806ad5d704474.tar.gz |
Check that pheno values are numerical and at least 3 decimal places
Diffstat (limited to 'tests')
-rw-r--r-- | tests/r_qtl/test_files/pheno_with_errors.zip | bin | 0 -> 522 bytes | |||
-rw-r--r-- | tests/r_qtl/test_files/pheno_without_errors.zip | bin | 0 -> 539 bytes | |||
-rw-r--r-- | tests/r_qtl/test_r_qtl2_qc.py | 30 |
3 files changed, 24 insertions, 6 deletions
diff --git a/tests/r_qtl/test_files/pheno_with_errors.zip b/tests/r_qtl/test_files/pheno_with_errors.zip Binary files differnew file mode 100644 index 0000000..321e44d --- /dev/null +++ b/tests/r_qtl/test_files/pheno_with_errors.zip diff --git a/tests/r_qtl/test_files/pheno_without_errors.zip b/tests/r_qtl/test_files/pheno_without_errors.zip Binary files differnew file mode 100644 index 0000000..9d9d027 --- /dev/null +++ b/tests/r_qtl/test_files/pheno_without_errors.zip 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 |