diff options
| author | Frederick Muriuki Muriithi | 2026-04-13 13:47:57 -0500 |
|---|---|---|
| committer | Frederick Muriuki Muriithi | 2026-04-13 13:55:11 -0500 |
| commit | 2b83212a830cbaef8575be3b0996a7d838c16c01 (patch) | |
| tree | 0b2248259522276d7a0a7e45ea1f69ff8a6332ac /uploader/genotypes/models.py | |
| parent | 2981951d059afc4e21b59bc6ec9f3983b5213547 (diff) | |
| download | gn-uploader-2b83212a830cbaef8575be3b0996a7d838c16c01.tar.gz | |
Retrieve ALL markers for a species regardless of data.
Retrieve all the genetic markers that exist for a particular species regardless of whether or not a particular marker has corresponding samples allele data.
Diffstat (limited to 'uploader/genotypes/models.py')
| -rw-r--r-- | uploader/genotypes/models.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/uploader/genotypes/models.py b/uploader/genotypes/models.py index 4f09b02..34d2cfe 100644 --- a/uploader/genotypes/models.py +++ b/uploader/genotypes/models.py @@ -29,29 +29,28 @@ def genotype_markers_count(conn: mdb.Connection, species_id: int) -> int: def genotype_markers( conn: mdb.Connection, species_id: int, - dataset_id: int, offset: int = 0, limit: Optional[int] = None ) -> tuple[tuple[dict, ...], int]: """Retrieve markers from the database.""" _query_template = ( - "SELECT %%COLS%% FROM GenoXRef AS gxr INNER JOIN Geno AS gno " - "ON gxr.GenoId=gno.Id WHERE gxr.GenoFreezeId=%s AND gno.SpeciesId=%s " + "SELECT %%COLS%% FROM Geno AS gno " + "WHERE gno.SpeciesId=%s " "%%LIMIT%%") with conn.cursor(cursorclass=DictCursor) as cursor: cursor.execute( _query_template.replace("%%LIMIT%%", "").replace( - "%%COLS%%", "COUNT(gxr.GenoId) AS total_records"), - (species_id, dataset_id)) + "%%COLS%%", "COUNT(gno.Id) AS total_records"), + (species_id,)) _total_records = cursor.fetchone()["total_records"] cursor.execute( - _query_template.replace("%%COLS%%", "gxr.GenoFreezeId, gno.*").replace( + _query_template.replace("%%COLS%%", "gno.*").replace( "%%LIMIT%%", (f"LIMIT {int(limit)} OFFSET {int(offset)}" if bool(limit) and limit > 0 else "")), - (species_id, dataset_id)) + (species_id,)) debug_query(cursor, app.logger) return tuple(dict(row) for row in cursor.fetchall()), _total_records |
