aboutsummaryrefslogtreecommitdiff
path: root/gn3/db
diff options
context:
space:
mode:
authorzsloan2023-08-17 19:09:04 +0000
committerzsloan2023-08-17 14:54:42 -0500
commit99a08467a80dfd36ed3d83d5022adfd8cfc4e16d (patch)
treeb8462a4c0b8d229d28499fffa6d4e1c1dcd2ceef /gn3/db
parent346895669845b2778dbbae2638f44d1f8e5dd4c0 (diff)
downloadgenenetwork3-99a08467a80dfd36ed3d83d5022adfd8cfc4e16d.tar.gz
Fix queries for fetching group names
Diffstat (limited to 'gn3/db')
-rw-r--r--gn3/db/datasets.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/gn3/db/datasets.py b/gn3/db/datasets.py
index 0c0fab4..6e3977f 100644
--- a/gn3/db/datasets.py
+++ b/gn3/db/datasets.py
@@ -38,7 +38,7 @@ def retrieve_sample_list(group: str):
samplelist = headers[3:]
return samplelist
-def retrieve_mrna_group_name(connection: Any, probeset_id: int):
+def retrieve_mrna_group_name(connection: Any, probeset_id: int, dataset_name: str):
"""
Given the trait id (ProbeSet.Id in the database), retrieve the name
of the group the dataset belongs to.
@@ -49,9 +49,9 @@ def retrieve_mrna_group_name(connection: Any, probeset_id: int):
"LEFT JOIN ProbeSetFreeze psf ON psx.ProbeSetFreezeId = psf.Id "
"LEFT JOIN ProbeFreeze pf ON psf.ProbeFreezeId = pf.Id "
"LEFT JOIN InbredSet iset ON pf.InbredSetId = iset.Id "
- "WHERE ps.Id = %(probeset_id)s")
+ "WHERE ps.Id = %(probeset_id)s AND psf.Name=%(dataset_name)s")
with connection.cursor() as cursor:
- cursor.execute(query, {"probeset_id": probeset_id})
+ cursor.execute(query, {"probeset_id": probeset_id, "dataset_name": dataset_name})
res = cursor.fetchone()
if res:
return res[0]
@@ -64,9 +64,8 @@ def retrieve_phenotype_group_name(connection: Any, dataset_id: int):
"""
query = (
"SELECT iset.Name "
- "FROM PublishFreeze AS pf INNER JOIN InbredSet AS iset "
- "ON pf.InbredSetId=iset.Id "
- "WHERE pf.Id = %(dataset_id)s")
+ "FROM InbredSet AS iset "
+ "WHERE iset.Id = %(dataset_id)s")
with connection.cursor() as cursor:
cursor.execute(query, {"dataset_id": dataset_id})
res = cursor.fetchone()