From a5094f9de3061e5bbab2c548399fc2477ae4fd61 Mon Sep 17 00:00:00 2001 From: zsloan Date: Wed, 2 Aug 2023 18:49:12 +0000 Subject: Add function for retrieving mRNA Assay group name --- gn3/db/datasets.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'gn3') diff --git a/gn3/db/datasets.py b/gn3/db/datasets.py index 9121ec2..58bbcf5 100644 --- a/gn3/db/datasets.py +++ b/gn3/db/datasets.py @@ -38,6 +38,24 @@ def retrieve_sample_list(group: str): samplelist = headers[3:] return samplelist +def retrieve_mrna_group_name(connection: Any, probeset_id: int): + """ + Given the trait id (ProbeSet.Id in the database), retrieve the name + of the group the dataset belongs to. + """ + query = ( + "SELECT iset.Name " + "FROM ProbeSet AS ps " + "INNER JOIN ProbeSetXRef AS px ON ps.Id = px.ProbeSetId " + "INNER JOIN InbredSet AS id ON px.InbredSetId = is.Id " + "WHERE ps.Id = %(probeset_id)s") + with connection.cursor() as cursor: + cursor.execute(query, {"probeset_id": probeset_id}) + 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 -- cgit v1.2.3