about summary refs log tree commit diff
path: root/gn3/db/datasets.py
diff options
context:
space:
mode:
authorzsloan2025-05-02 18:28:12 +0000
committerzsloan2025-06-17 10:46:29 -0500
commitc3707f1e8045c72b5d0686c0a9ef239a396997b3 (patch)
treed2472ee9ca8bec31b99b768f70b762d9a0190556 /gn3/db/datasets.py
parent82885f945499415b00b4ef2ee2a5464ea13fb8fb (diff)
downloadgenenetwork3-c3707f1e8045c72b5d0686c0a9ef239a396997b3.tar.gz
Add function for retrieving group_id given group_name
Diffstat (limited to 'gn3/db/datasets.py')
-rw-r--r--gn3/db/datasets.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/gn3/db/datasets.py b/gn3/db/datasets.py
index f3b4f9f..fea207b 100644
--- a/gn3/db/datasets.py
+++ b/gn3/db/datasets.py
@@ -79,6 +79,21 @@ def retrieve_mrna_group_name(connection: Any, probeset_id: int, dataset_name: st
             return res[0]
         return None
 
+def retrieve_group_id(connection: Any, group_name: str):
+    """
+    Given the group name, retrieve the group ID
+    """
+    query = (
+        "SELECT iset.Id "
+        "FROM InbredSet AS iset "
+        "WHERE iset.Name = %(group_name)s")
+    with connection.cursor() as cursor:
+        cursor.execute(query, {"group_name": group_name})
+        res = cursor.fetchone()
+        if res:
+            return res[0]
+        return None
+
 def retrieve_phenotype_group_name(connection: Any, dataset_id: int):
     """
     Given the dataset id (PublishFreeze.Id in the database), retrieve the name