diff options
author | Frederick Muriuki Muriithi | 2021-11-24 05:46:43 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2021-11-29 12:05:16 +0300 |
commit | 40f264876f2309fcccfcd3d04a2999bdf3fa5d98 (patch) | |
tree | 763fd18d24845eb77712c22dc5e5fdfb3007cca9 /gn3/db/species.py | |
parent | 6a3ee25e241bd4984c6959e2ccc1e569b53d6486 (diff) | |
download | genenetwork3-40f264876f2309fcccfcd3d04a2999bdf3fa5d98.tar.gz |
Retrieve the species name given the group
Issue:
https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi
* Migrate the `web.webqtl.dbFunction.webqtlDatabaseFunction.retrieveSpecies`
in GeneNetwork1 to `gn3.db.species.species_name` in GeneNetwork3 to enable
the retrieval of the species name, given the group name (formerly RISet).
Diffstat (limited to 'gn3/db/species.py')
-rw-r--r-- | gn3/db/species.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/gn3/db/species.py b/gn3/db/species.py index 702a9a8..20170ba 100644 --- a/gn3/db/species.py +++ b/gn3/db/species.py @@ -57,3 +57,20 @@ def translate_to_mouse_gene_id(species: str, geneid: int, conn: Any) -> int: return translated_gene_id[0] return 0 # default if all else fails + +def species_name(conn: Any, group: str) -> str: + """ + Retrieve the name of the species, given the group (RISet). + + This is a migration of the + `web.webqtl.dbFunction.webqtlDatabaseFunction.retrieveSpecies` function in + GeneNetwork1. + """ + with conn.cursor() as cursor: + cursor.execute( + ("SELECT Species.Name FROM Species, InbredSet " + "WHERE InbredSet.Name = %(group_name)s " + "AND InbredSet.SpeciesId = Species.Id"), + group_name=group_name) + return cursor.fetchone()[0] + return None |