aboutsummaryrefslogtreecommitdiff
path: root/qc_app/db/datasets.py
diff options
context:
space:
mode:
Diffstat (limited to 'qc_app/db/datasets.py')
-rw-r--r--qc_app/db/datasets.py30
1 files changed, 29 insertions, 1 deletions
diff --git a/qc_app/db/datasets.py b/qc_app/db/datasets.py
index 8122cfa..086c103 100644
--- a/qc_app/db/datasets.py
+++ b/qc_app/db/datasets.py
@@ -2,7 +2,7 @@
import MySQLdb as mdb
from MySQLdb.cursors import DictCursor
-def geno_dataset_by_species_and_population(
+def geno_datasets_by_species_and_population(
conn: mdb.Connection,
speciesid: int,
populationid: int) -> tuple[dict, ...]:
@@ -21,3 +21,31 @@ def geno_dataset_by_id(conn: mdb.Connection, dataset_id: int) -> dict:
cursor.execute("SELECT * FROM GenoFreeze WHERE Id=%s",
(dataset_id,))
return dict(cursor.fetchone())
+
+def probeset_studies_by_species_and_population(
+ conn: mdb.Connection,
+ speciesid: int,
+ populationid: int) -> tuple[dict, ...]:
+ """Retrieve all probesets"""
+ with conn.cursor(cursorclass=DictCursor) as cursor:
+ cursor.execute(
+ "SELECT pf.* FROM InbredSet AS iset INNER JOIN ProbeFreeze AS pf "
+ "ON iset.InbredSetId=pf.InbredSetId "
+ "WHERE iset.SpeciesId=%(sid)s AND iset.InbredSetId=%(pid)s",
+ {"sid": speciesid, "pid": populationid})
+ return tuple(dict(row) for row in cursor.fetchall())
+
+def probeset_datasets_by_study(conn: mdb.Connection,
+ studyid: int) -> tuple[dict, ...]:
+ """Retrieve all probeset databases by study."""
+ with conn.cursor(cursorclass=DictCursor) as cursor:
+ cursor.execute("SELECT * FROM ProbeSetFreeze WHERE ProbeFreezeId=%s",
+ (studyid,))
+ return tuple(dict(row) for row in cursor.fetchall())
+
+def probe_study_by_id(conn: mdb.Connection, studyid: int) -> dict:
+ """Retrieve ProbeSet study by ID"""
+ with conn.cursor(cursorclass=DictCursor) as cursor:
+ cursor.execute("SELECT * FROM ProbeFreeze WHERE Id=%s",
+ (studyid,))
+ return dict(cursor.fetchone())