about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2025-08-25 09:58:11 -0500
committerFrederick Muriuki Muriithi2025-08-25 09:58:11 -0500
commit148c71a817fc3507594bb07bae770c4498cb7d78 (patch)
treee179258a35c0d38252f16e5feccc794c80fe521f
parentf98d99b625b85d27e729918a069bcf42630bc562 (diff)
downloadgn-uploader-148c71a817fc3507594bb07bae770c4498cb7d78.tar.gz
Preprocess phenotype data and return normalised form.
-rw-r--r--uploader/phenotypes/models.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/uploader/phenotypes/models.py b/uploader/phenotypes/models.py
index 4b8b223..deaf991 100644
--- a/uploader/phenotypes/models.py
+++ b/uploader/phenotypes/models.py
@@ -304,6 +304,23 @@ def phenotypes_data_by_ids(
             reduce(__organise_by_phenotype__, cursor.fetchall(), {}).values())
 
 
+def __pre_process_phenotype_data__(row):
+    _desc = row.get("description", "")
+    _pre_pub_desc = row.get("pre_publication_description", _desc)
+    _orig_desc = row.get("original_description", _desc)
+    _post_pub_desc = row.get("post_publication_description", _orig_desc)
+    _pre_pub_abbr = row.get("pre_publication_abbreviation", row["id"])
+    _post_pub_abbr = row.get("post_publication_abbreviation", _pre_pub_abbr)
+    return {
+        "pre_publication_description": _pre_pub_desc,
+        "post_publication_description": _post_pub_desc,
+        "original_description": _orig_desc,
+        "units": row["units"],
+        "pre_publication_abbreviation": _pre_pub_abbr,
+        "post_publication_abbreviation": _post_pub_abbr
+    }
+
+
 def create_new_phenotypes(conn: mdb.Connection,
                           phenotypes: Iterable[dict]) -> tuple[dict, ...]:
     """Add entirely new phenotypes to the database."""