aboutsummaryrefslogtreecommitdiff
path: root/qc_app/db
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-01-17 11:41:43 +0300
committerFrederick Muriuki Muriithi2024-01-17 11:41:43 +0300
commit33e106334a212853842c30f8c595da1099c3d84e (patch)
treea9a073bc24e2cec54f346f67d0ad1f652a5894bf /qc_app/db
parentcde57e8faeb41df27587361dcf42e235545cacb3 (diff)
downloadgn-uploader-33e106334a212853842c30f8c595da1099c3d84e.tar.gz
UI: Select ProbeSet study.
Diffstat (limited to 'qc_app/db')
-rw-r--r--qc_app/db/__init__.py2
-rw-r--r--qc_app/db/datasets.py30
2 files changed, 30 insertions, 2 deletions
diff --git a/qc_app/db/__init__.py b/qc_app/db/__init__.py
index 270f1a0..36e93e8 100644
--- a/qc_app/db/__init__.py
+++ b/qc_app/db/__init__.py
@@ -5,4 +5,4 @@ from .populations import (
population_by_id,
populations_by_species,
population_by_species_and_id)
-from .datasets import geno_dataset_by_species_and_population
+from .datasets import geno_datasets_by_species_and_population
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())