From f909cd13cadab9bd0bb6e816b6c6f492ab18f28a Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Thu, 19 Sep 2024 13:30:20 -0500 Subject: List genotype datasets --- uploader/genotypes/models.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'uploader/genotypes/models.py') diff --git a/uploader/genotypes/models.py b/uploader/genotypes/models.py index 53c5fb8..642caa6 100644 --- a/uploader/genotypes/models.py +++ b/uploader/genotypes/models.py @@ -39,3 +39,19 @@ def genotype_markers( cursor.execute(_query, (species_id,)) debug_query(cursor) return tuple(dict(row) for row in cursor.fetchall()) + + +def genotype_datasets( + conn: mdb.Connection, + species_id: int, + population_id: int +) -> tuple[dict, ...]: + """Retrieve genotype datasets from the database.""" + with conn.cursor(cursorclass=DictCursor) as cursor: + cursor.execute( + "SELECT gf.* FROM Species AS s INNER JOIN InbredSet AS iset " + "ON s.Id=iset.SpeciesId INNER JOIN GenoFreeze AS gf " + "ON iset.Id=gf.InbredSetId " + "WHERE s.Id=%s AND iset.Id=%s", + (species_id, population_id)) + return tuple(dict(row) for row in cursor.fetchall()) -- cgit v1.2.3