aboutsummaryrefslogtreecommitdiff
path: root/uploader
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2025-01-25 07:51:29 -0600
committerFrederick Muriuki Muriithi2025-01-25 07:51:29 -0600
commitdd94d8d3c5e32271c02a273386ea3cabdcad0bd1 (patch)
tree76c03db373246868d4c27b2f49121eebde637a44 /uploader
parente913bf1ee8ba2bbe19c064ec7d658e94036117e4 (diff)
downloadgn-uploader-dd94d8d3c5e32271c02a273386ea3cabdcad0bd1.tar.gz
Add function to retrieve a phenotype's publication data.
Diffstat (limited to 'uploader')
-rw-r--r--uploader/phenotypes/models.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/uploader/phenotypes/models.py b/uploader/phenotypes/models.py
index 2765d1e..9b07000 100644
--- a/uploader/phenotypes/models.py
+++ b/uploader/phenotypes/models.py
@@ -54,6 +54,20 @@ def phenotypes_count(conn: mdb.Connection,
return int(cursor.fetchone()["total_phenos"])
+def phenotype_publication_data(conn, phenotype_id) -> Optional[dict]:
+ """Retrieve the publication data for a phenotype if it exists."""
+ with conn.cursor(cursorclass=DictCursor) as cursor:
+ cursor.execute(
+ "SELECT DISTINCT pxr.PhenotypeId, pub.* FROM PublishXRef AS pxr "
+ "INNER JOIN Publication as pub ON pxr.PublicationId=pub.Id "
+ "WHERE pxr.PhenotypeId=%s",
+ (phenotype_id,))
+ res = cursor.fetchone()
+ if res is None:
+ return res
+ return dict(res)
+
+
def dataset_phenotypes(conn: mdb.Connection,
population_id: int,
dataset_id: int,