aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2025-05-19 16:56:08 -0500
committerFrederick Muriuki Muriithi2025-05-19 16:56:08 -0500
commit979620f6ccf816170e01c7b92c71a8f4c3ce3e01 (patch)
tree683e316a829b072010c686b825fb98f05625298e
parent2b7e941980387e216d6b8d56952abcdb626b742b (diff)
downloadgn-uploader-main.tar.gz
Extract the bundle first.HEADmain
-rw-r--r--scripts/load_phenotypes_to_db.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/scripts/load_phenotypes_to_db.py b/scripts/load_phenotypes_to_db.py
index b78c648..980aa94 100644
--- a/scripts/load_phenotypes_to_db.py
+++ b/scripts/load_phenotypes_to_db.py
@@ -3,6 +3,7 @@ import json
import logging
import argparse
from pathlib import Path
+from zipfile import ZipFile
from typing import Any, Union
from MySQLdb.cursors import Cursor, DictCursor
@@ -243,7 +244,12 @@ def load_data(conn, job):
conn, int(_job_metadata.get("publicationid", "0"))) or {"Id": 0}
# 2. Save all new phenotypes:
# -> return phenotype IDs
- _control_data = rqtl.control_data(job["job-metadata"]["bundle-file"])
+ bundle = Path(_job_metadata["bundle_file"])
+ _control_data = rqtl2.control_data(bundle)
+ logger.info("Extracting the zipped bundle of files.")
+ _outdir = Path(bundle.parent, f"bundle_{bundle.stem}")
+ with ZipFile(str(bundle), "r") as zfile:
+ _files = rqtl2.extract(zfile, _outdir)
logger.info("Saving basic phenotype data.")
_phenos = save_phenotypes(cursor, _control_data)