about summary refs log tree commit diff
path: root/scripts
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2025-05-19 14:35:31 -0500
committerFrederick Muriuki Muriithi2025-05-19 14:35:31 -0500
commit1f30748f3a87a810cdb242d5c2927689f0b6877f (patch)
treedcedf226c43636f646f243041d220ee9d0801e9f /scripts
parent5bd5f3cf1ae30467df5e4a040fec2acb20be6cee (diff)
downloadgn-uploader-1f30748f3a87a810cdb242d5c2927689f0b6877f.tar.gz
Retrieve publication first.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/load_phenotypes_to_db.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/scripts/load_phenotypes_to_db.py b/scripts/load_phenotypes_to_db.py
index 7e1112e..2be8096 100644
--- a/scripts/load_phenotypes_to_db.py
+++ b/scripts/load_phenotypes_to_db.py
@@ -225,7 +225,10 @@ def load_data(conn, job):
     # Steps
     # 0. Read data from the files: can be multiple files per type
     #
-    # 1. Save all new phenotypes:
+    # 1. Just retrive the publication: Don't create publications for now.
+    _publication = fetch_publication_by_id(
+        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"])
     logger.info("Saving basic phenotype data.")
@@ -234,13 +237,11 @@ def load_data(conn, job):
     dataidmap = {
         row["phenotype_id"]: {
             "phenotype_id": row["phenotype_id"],
-            "data_id": dataid
+            "data_id": dataid,
+            "publication_id": _publication["Id"],
         }
         for dataid, row in enumerate(_phenos, start=__fetch_next_dataid__(conn))
     }
-    # 2. Just retrive the publication: Don't create publications for now.
-    publication = fetch_publication_by_id(
-        conn, int(_job_metadata.get("publicationid", "0"))) or {"Id": 0}
     # 3. a. Fetch the strain names and IDS: create name->ID map
     samples = {
         row["Name"]: row