aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2021-11-24 05:46:43 +0300
committerFrederick Muriuki Muriithi2021-11-29 12:05:16 +0300
commit40f264876f2309fcccfcd3d04a2999bdf3fa5d98 (patch)
tree763fd18d24845eb77712c22dc5e5fdfb3007cca9
parent6a3ee25e241bd4984c6959e2ccc1e569b53d6486 (diff)
downloadgenenetwork3-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).
-rw-r--r--gn3/db/species.py17
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