From d93146504048e341262223c09be64c3f0c416c8d Mon Sep 17 00:00:00 2001 From: zsloan Date: Thu, 13 Apr 2023 19:09:57 +0000 Subject: Add function for retrieving group name (given group ID) --- gn3/db/datasets.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'gn3/db') 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): """ -- cgit v1.2.3