aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-01-03 16:41:33 +0300
committerFrederick Muriuki Muriithi2024-01-03 16:41:33 +0300
commit95d2b868adebbc7ebbc2435f9184c30c014ec513 (patch)
treeed4849c1162d66766e24a9c97c4b03e6a225db22 /tests
parente713b566a873424709300110a78801fd49a74ea1 (diff)
downloadgn-uploader-95d2b868adebbc7ebbc2435f9184c30c014ec513.tar.gz
Parse founder_geno files. Generalise parsing files.
* Add tests for parsing "founder_geno" files * Extract common file parsing structure out to more general function * Use generic function to parse "founder_geno" file in test
Diffstat (limited to 'tests')
-rw-r--r--tests/r_qtl/test_files/test_founder_geno.zipbin0 -> 672 bytes
-rw-r--r--tests/r_qtl/test_files/test_founder_geno_transposed.zipbin0 -> 725 bytes
-rw-r--r--tests/r_qtl/test_r_qtl2_geno.py87
3 files changed, 80 insertions, 7 deletions
diff --git a/tests/r_qtl/test_files/test_founder_geno.zip b/tests/r_qtl/test_files/test_founder_geno.zip
new file mode 100644
index 0000000..f77626b
--- /dev/null
+++ b/tests/r_qtl/test_files/test_founder_geno.zip
Binary files differ
diff --git a/tests/r_qtl/test_files/test_founder_geno_transposed.zip b/tests/r_qtl/test_files/test_founder_geno_transposed.zip
new file mode 100644
index 0000000..6cc8151
--- /dev/null
+++ b/tests/r_qtl/test_files/test_founder_geno_transposed.zip
Binary files differ
diff --git a/tests/r_qtl/test_r_qtl2_geno.py b/tests/r_qtl/test_r_qtl2_geno.py
index d323c4b..787d13a 100644
--- a/tests/r_qtl/test_r_qtl2_geno.py
+++ b/tests/r_qtl/test_r_qtl2_geno.py
@@ -177,11 +177,80 @@ def test_parse_geno_files(relpath, expected):
@pytest.mark.unit_test
@pytest.mark.parametrize(
"relpath,expected",
- (
- ("tests/r_qtl/test_files/test_founder_geno.zip",
- ()),
- ("tests/r_qtl/test_files/test_founder_geno_transposed.zip",
- ())))
+ (("tests/r_qtl/test_files/test_founder_geno.zip",
+ (({
+ "id": "1",
+ "PVV4": 1,
+ "AXR-1": 1,
+ "HH.335C-Col/PhyA": 1,
+ "EC.480C": 1,
+ "EC.66C": 1
+ }, {
+ "id": "2",
+ "PVV4": 1,
+ "AXR-1": 1,
+ "HH.335C-Col/PhyA": 1,
+ "EC.480C": 1,
+ "EC.66C": 1
+ }, {
+ "id": "3",
+ "PVV4": 2,
+ "AXR-1": 2,
+ "HH.335C-Col/PhyA": None,
+ "EC.480C": 1,
+ "EC.66C": 1
+ }, {
+ "id": "4",
+ "PVV4": 1,
+ "AXR-1": 1,
+ "HH.335C-Col/PhyA": 1,
+ "EC.480C": 1,
+ "EC.66C": 1
+ }, {
+ "id": "5",
+ "PVV4": None,
+ "AXR-1": 2,
+ "HH.335C-Col/PhyA": 2,
+ "EC.480C": 2,
+ "EC.66C": 2
+ }))),
+ ("tests/r_qtl/test_files/test_founder_geno_transposed.zip",
+ (({
+ "id": "1",
+ "PVV4": 1,
+ "AXR-1": 1,
+ "HH.335C-Col/PhyA": 1,
+ "EC.480C": 1,
+ "EC.66C": 1
+ }, {
+ "id": "2",
+ "PVV4": 1,
+ "AXR-1": 1,
+ "HH.335C-Col/PhyA": 1,
+ "EC.480C": 1,
+ "EC.66C": 1
+ }, {
+ "id": "3",
+ "PVV4": 2,
+ "AXR-1": 2,
+ "HH.335C-Col/PhyA": None,
+ "EC.480C": 1,
+ "EC.66C": 1
+ }, {
+ "id": "4",
+ "PVV4": 1,
+ "AXR-1": 1,
+ "HH.335C-Col/PhyA": 1,
+ "EC.480C": 1,
+ "EC.66C": 1
+ }, {
+ "id": "5",
+ "PVV4": None,
+ "AXR-1": 2,
+ "HH.335C-Col/PhyA": 2,
+ "EC.480C": 2,
+ "EC.66C": 2
+ })))))
def test_parse_founder_geno_files(relpath, expected):
"""Test parsing of founder_geno files from the R/qtl2 bundle.
@@ -190,5 +259,9 @@ def test_parse_founder_geno_files(relpath, expected):
THEN: ensure that the data we get is as expected
"""
with ZipFile(Path(relpath).absolute(), "r") as zfile:
- assert tuple(rqtl2.founder_genotype_data(
- zfile, rqtl2.control_data(zfile))) == expected
+ cdata = rqtl2.control_data(zfile)
+ assert tuple(rqtl2.file_data(
+ zfile,
+ "founder_geno",
+ cdata,
+ *rqtl2.make_process_data_geno(cdata))) == expected