aboutsummaryrefslogtreecommitdiff
path: root/gn3/db
diff options
context:
space:
mode:
authorMuriithi Frederick Muriuki2021-08-05 08:40:49 +0300
committerMuriithi Frederick Muriuki2021-08-05 08:40:49 +0300
commit76ba5296c66e131301a9fdb692c3b2623f3331ed (patch)
treec450cf976687dfffce5cb7e07e557a87fa591dc0 /gn3/db
parentf712da630c1a3642cb44b62c4b2b857373cd78d7 (diff)
downloadgenenetwork3-76ba5296c66e131301a9fdb692c3b2623f3331ed.tar.gz
Build up trait_name items from full name
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/clustering.gmi * The full name of the traits from search contains multiple parts to it, and as such, we use it to retrieve the appropriate data and set it up in the final trait_info dictionary that is produced.
Diffstat (limited to 'gn3/db')
-rw-r--r--gn3/db/traits.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/gn3/db/traits.py b/gn3/db/traits.py
index 29c91a6..9f89510 100644
--- a/gn3/db/traits.py
+++ b/gn3/db/traits.py
@@ -341,8 +341,18 @@ def set_riset_fields(trait_info, conn):
**trait_info, "risetid": riid,
"riset": "BXD" if riset == "BXD300" else riset}
+def build_trait_name(trait_fullname):
+ name_parts = trait_fullname.split("::")
+ assert len(name_parts) >= 2, "Name format error"
+ return {
+ "trait_db": name_parts[0],
+ "trait_fullname": trait_fullname,
+ "trait_name": name_parts[1],
+ "cellid": name_parts[2] if len(name_parts) == 3 else ""
+ }
+
def retrieve_trait_info(
- trait_type: str, trait_name: str, trait_dataset_id: int,
+ trait_type: str, trait_full_name: str, trait_dataset_id: int,
trait_dataset_name: str, conn: Any, qtl=None):
"""Retrieves the trait information.
@@ -351,6 +361,7 @@ def retrieve_trait_info(
This function, or the dependent functions, might be incomplete as they are
currently."""
# pylint: disable=[R0913]
+ trait = build_trait_name(trait_full_name)
trait_info_function_table = {
"Publish": retrieve_publish_trait_info,
"ProbeSet": retrieve_probeset_trait_info,
@@ -362,6 +373,7 @@ def retrieve_trait_info(
lambda ti: set_riset_fields(ti, conn),
lambda ti: set_homologene_id_field(ti, conn),
lambda ti: {"type": trait_type, **ti},
+ lambda ti: {**ti, **trait},
set_haveinfo_field)
trait_post_processing_functions_table = {
@@ -377,7 +389,7 @@ def retrieve_trait_info(
return retrieve_info(
{
- "trait_name": trait_name,
+ "trait_name": trait["trait_name"],
"trait_dataset_id": trait_dataset_id,
"trait_dataset_name":trait_dataset_name
},