aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-10-17 14:32:22 -0500
committerFrederick Muriuki Muriithi2024-10-17 14:39:43 -0500
commit5b33832cbb6a7eb40cd87128efc3bcf2b5a54726 (patch)
tree7f1a5425fca7ca092b791fde090c111b3cb62433
parentad5610fa54038ddf39db89103636883b53f9afbc (diff)
downloadgn-uploader-5b33832cbb6a7eb40cd87128efc3bcf2b5a54726.tar.gz
Fetch samples from database
Fetch the samples from the database. These will be used to verify that the samples in the phenotype files already exist in the database and are valid.
-rw-r--r--scripts/rqtl2/phenotypes_qc.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/scripts/rqtl2/phenotypes_qc.py b/scripts/rqtl2/phenotypes_qc.py
index e495a97..d565be2 100644
--- a/scripts/rqtl2/phenotypes_qc.py
+++ b/scripts/rqtl2/phenotypes_qc.py
@@ -3,6 +3,7 @@ import sys
import tempfile
from pathlib import Path
from zipfile import ZipFile
+from functools import reduce
import multiprocessing as mproc
from logging import Logger, getLogger, StreamHandler
@@ -13,6 +14,8 @@ from r_qtl import r_qtl2_qc as rqc
from r_qtl import exceptions as rqe
from uploader.files import sha256_digest_over_file
+from uploader.samples.models import samples_by_species_and_population
+
from scripts.rqtl2.entry import build_main
from scripts.rqtl2.cli_parser import add_bundle_argument
from scripts.cli_parser import init_cli_parser, add_global_data_arguments
@@ -144,6 +147,15 @@ def run_qc(# pylint: disable=[too-many-arguments]
((ftype, cdata, extractiondir)
for ftype in ("pheno", "phenocovar", "phenose", "phenonum")))
+ # - Fetch samples/individuals from database.
+ samples = tuple(
+ item for item in set(reduce(
+ lambda acc, item: acc + (
+ item["Name"], item["Name2"], item["Symbol"], item["Alias"]),
+ samples_by_species_and_population(dbconn, speciesid, populationid),
+ tuple()))
+ if bool(item))
+
# - Check that `description` and `units` is present in phenocovar for
# all phenotypes
# - Check all phenotypes in pheno files exist in phenocovar files