aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2025-04-14 16:11:24 -0500
committerFrederick Muriuki Muriithi2025-04-14 16:11:24 -0500
commit0f0a49dc86381909838fbdf90fdc0b3c7ade21e2 (patch)
tree1bbd749ddb3bc23e2f940d1adf70e2c62d2367fa /scripts
parent14aed51e4aab04c1c53549ee9f1ce5fc20d6b11e (diff)
downloadgn-uploader-0f0a49dc86381909838fbdf90fdc0b3c7ade21e2.tar.gz
Compute data differences in the script.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/phenotypes_bulk_edit.py37
1 files changed, 28 insertions, 9 deletions
diff --git a/scripts/phenotypes_bulk_edit.py b/scripts/phenotypes_bulk_edit.py
index 0b4fec5..6fc198c 100644
--- a/scripts/phenotypes_bulk_edit.py
+++ b/scripts/phenotypes_bulk_edit.py
@@ -11,9 +11,11 @@ from MySQLdb.cursors import DictCursor
from gn_libs import jobs, mysqldb, sqlite3
from uploader.phenotypes.models import phenotypes_data_by_ids
+from uploader.phenotypes.misc import phenotypes_data_differences
+from uploader.phenotypes.views import BULK_EDIT_COMMON_FIELDNAMES
+
import uploader.publications.pubmed as pmed
from uploader.publications.misc import publications_differences
-from uploader.phenotypes.views import BULK_EDIT_COMMON_FIELDNAMES
from uploader.publications.models import (
update_publications, fetch_phenotype_publications)
@@ -213,14 +215,31 @@ def run(conn, job):
for row in _db_publications + _new_publications})
logger.debug("Publications diff: %s", _pub_diff)
# 2. Data differences
- # _db_pheno_data = phenotypes_data_by_ids(conn, tuple({
- # "population_id": job["metadata"]["population-id"],
- # "phenoid": row[0],
- # "xref_id": row[1]
- # } for row in pheno_xref_ids))
- # logger.debug("Phenotype Data in Database: %s", _db_pheno_data)
-
- # data_diff = data_differences(...)
+ _db_pheno_data = phenotypes_data_by_ids(conn, tuple({
+ "population_id": job["metadata"]["population-id"],
+ "phenoid": row[0],
+ "xref_id": row[1]
+ } for row in pheno_xref_ids))
+
+ data_diff = phenotypes_data_differences(
+ ({
+ "phenotype_id": row["phenotype_id"],
+ "xref_id": row["xref_id"],
+ "data": {
+ key:val for key,val in row.items()
+ if key not in BULK_EDIT_COMMON_FIELDNAMES + [
+ "phenotype_id", "xref_id"]
+ }
+ } for row in file_contents),
+ ({
+ **row,
+ "PhenotypeId": row["Id"],
+ "data": {
+ dataitem["StrainName"]: dataitem
+ for dataitem in row["data"].values()
+ }
+ } for row in _db_pheno_data))
+ logger.debug("Data differences: %s", data_diff)
### END: Compute differences
update_descriptions()
link_publications()