about summary refs log tree commit diff
diff options
context:
space:
mode:
-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