aboutsummaryrefslogtreecommitdiff
path: root/gn3/db/datasets.py
diff options
context:
space:
mode:
Diffstat (limited to 'gn3/db/datasets.py')
-rw-r--r--gn3/db/datasets.py20
1 files changed, 8 insertions, 12 deletions
diff --git a/gn3/db/datasets.py b/gn3/db/datasets.py
index 28fe0fe..9121ec2 100644
--- a/gn3/db/datasets.py
+++ b/gn3/db/datasets.py
@@ -38,22 +38,18 @@ def retrieve_sample_list(group: str):
samplelist = headers[3:]
return samplelist
-def retrieve_group_name(
- group_id: int, connection: Any):
+def retrieve_phenotype_group_name(connection: Any, dataset_id: int):
"""
- Given the group id (InbredSet.Id in the database), retrieve its name
+ Given the dataset id (PublishFreeze.Id in the database), retrieve the name
+ of the group the dataset belongs to.
"""
query = (
- "SELECT Name "
- "FROM InbredSet "
- "WHERE "
- "InbredSet.Id = %(group_id)s")
+ "SELECT iset.Name "
+ "FROM PublishFreeze AS pf INNER JOIN InbredSet AS iset "
+ "ON pf.InbredSetId=iset.Id "
+ "WHERE pf.Id = %(dataset_id)s")
with connection.cursor() as cursor:
- cursor.execute(
- query,
- {
- "group_id": group_id
- })
+ cursor.execute(query, {"dataset_id": dataset_id})
res = cursor.fetchone()
if res:
return res[0]