about summary refs log tree commit diff
diff options
context:
space:
mode:
authorzsloan2023-04-13 19:09:57 +0000
committerzsloan2023-05-22 17:23:08 +0000
commitd93146504048e341262223c09be64c3f0c416c8d (patch)
tree1bf218c17bc837f4180d2bb009131226044332ab
parent3404fda373f52213a44c6b04a7348308b2619139 (diff)
downloadgenenetwork3-d93146504048e341262223c09be64c3f0c416c8d.tar.gz
Add function for retrieving group name (given group ID)
-rw-r--r--gn3/db/datasets.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/gn3/db/datasets.py b/gn3/db/datasets.py
index 65ab1f8..9186875 100644
--- a/gn3/db/datasets.py
+++ b/gn3/db/datasets.py
@@ -33,6 +33,27 @@ def retrieve_sample_list(
             samplelist = headers[3:]
         return samplelist
 
+def retrieve_group_name(
+        group_id: int, connection: any):
+    """
+    Given the group id (InbredSet.Id in the database), retrieve its name
+    """
+    query = (
+        "SELECT Name "
+        "FROM InbredSet "
+        "WHERE "
+        "InbredSet.Id = %(group_id)s")
+    with connection.cursor() as cursor:
+        cursor.execute(
+            query,
+            {
+                "group_id": group_id
+            })
+        res = cursor.fetchone()
+        if res:
+            return res[0]
+        return None
+
 def retrieve_probeset_trait_dataset_name(
         threshold: int, name: str, connection: Any):
     """