aboutsummaryrefslogtreecommitdiff
path: root/uploader/phenotypes/models.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-09-26 17:03:31 -0500
committerFrederick Muriuki Muriithi2024-09-26 17:03:31 -0500
commit1b6b9a90a4dbe38aefc00293309fb48d9f478b13 (patch)
tree0a78c1e0e8f7a69a1282c817e23cd5ed267a31f4 /uploader/phenotypes/models.py
parentd3122c73497650d7165afb8fc6c75f2650ef956c (diff)
downloadgn-uploader-1b6b9a90a4dbe38aefc00293309fb48d9f478b13.tar.gz
Start building up the view dataset endpoint
Diffstat (limited to 'uploader/phenotypes/models.py')
-rw-r--r--uploader/phenotypes/models.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/uploader/phenotypes/models.py b/uploader/phenotypes/models.py
index 1f72dbd..4ef674f 100644
--- a/uploader/phenotypes/models.py
+++ b/uploader/phenotypes/models.py
@@ -20,3 +20,34 @@ def datasets_by_population(
"WHERE s.Id=%s AND iset.Id=%s;",
(species_id, population_id))
return tuple(dict(row) for row in cursor.fetchall())
+
+
+def phenotypes_data(conn: mdb.Connection,
+ population_id: int,
+ dataset_id: int,
+ offset: int = 0,
+ limit: Optional[int] = None) -> tuple[dict, ...]:
+ """Fetch the data for the phenotypes."""
+ #TODO: This query isn't exactly right, it misses some data.
+ # — Phenotype -> PublishXRef -> PublishData -> Strain -> PublishFreeze
+ _query = ("SELECT pxr.*, pd.*, str.* FROM PublishFreeze AS pf "
+ "INNER JOIN PublishXRef AS pxr ON pf.InbredSetId=pxr.InbredSetId "
+ "INNER JOIN PublishData AS pd ON pxr.DataId=pd.Id "
+ "INNER JOIN Strain AS str ON pd.StrainId=str.Id "
+ "WHERE pf.InbredSetId=%s AND pf.Id=%s "
+ "ORDER BY pxr.DataId ASC, str.Id ASC") + (
+ f" LIMIT {limit} OFFSET {offset}" if bool(limit) else "")
+ with conn.cursor(cursorclass=DictCursor) as cursor:
+ cursor.execute(_query, (population_id, dataset_id))
+ debug_query(cursor)
+ return tuple(dict(row) for row in cursor.fetchall())
+
+
+def phenotypes_se(conn: mdb.Connection, dataset_id: int) -> tuple[dict, ...]:
+ """Fetch the standard errors for the phenotypes."""
+ return tuple()
+
+
+def phenotypes_sample_counts(conn: mdb.Connection, dataset_id: int) -> tuple[dict, ...]:
+ """Fetch the standard errors for the phenotypes."""
+ return tuple()