diff options
author | zsloan | 2023-08-02 18:49:12 +0000 |
---|---|---|
committer | zsloan | 2023-08-17 14:54:42 -0500 |
commit | a5094f9de3061e5bbab2c548399fc2477ae4fd61 (patch) | |
tree | d96114ae0ce2496502c1455e8c476d5562e90e3d /gn3/db | |
parent | 614de6ac83e7d89eebbee056046303e6cb39e9c5 (diff) | |
download | genenetwork3-a5094f9de3061e5bbab2c548399fc2477ae4fd61.tar.gz |
Add function for retrieving mRNA Assay group name
Diffstat (limited to 'gn3/db')
-rw-r--r-- | gn3/db/datasets.py | 18 |
1 files changed, 18 insertions, 0 deletions
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 |