diff options
Diffstat (limited to 'scripts/process_rqtl2_bundle.py')
-rw-r--r-- | scripts/process_rqtl2_bundle.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/scripts/process_rqtl2_bundle.py b/scripts/process_rqtl2_bundle.py index 1b26264..6ba746a 100644 --- a/scripts/process_rqtl2_bundle.py +++ b/scripts/process_rqtl2_bundle.py @@ -5,11 +5,14 @@ import json import traceback from typing import Any from pathlib import Path +from zipfile import ZipFile from logging import Logger, getLogger, StreamHandler import MySQLdb as mdb from redis import Redis +import r_qtl.r_qtl2_qc as rqc + from qc_app import jobs from qc_app.db_utils import database_connection from qc_app.check_connections import check_db, check_redis @@ -49,6 +52,14 @@ def percent_completion(geno: float, pheno: float) -> float: """Compute the total completion percent.""" return 0.5 * (geno + pheno) +def qc_r_qtl2_bundle(bundlefilepath, logger): + """Run QC checks on the R/qtl2 bundle.""" + with ZipFile(bundlefilepath, "r") as zfile: + logger.info("Validating the bundle ...") + rqc.validate_bundle(zfile) + logger.info( + "Bundle successfully validated. All listed files are present.") + def process_bundle(dbconn: mdb.Connection, rconn: Redis, rprefix: str, @@ -58,6 +69,7 @@ def process_bundle(dbconn: mdb.Connection, try: thejob = parse_job(rconn, rprefix, jobid) meta = thejob["bundle-metadata"] + qc_r_qtl2_bundle(meta["rqtl2-bundle-file"], logger) rconn.hset(jobs.job_key(rprefix, jobid), "geno-percent", "0") rconn.hset(jobs.job_key(rprefix, jobid), "pheno-percent", "0") |