diff options
author | Frederick Muriuki Muriithi | 2023-07-21 08:36:44 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2023-07-21 08:47:04 +0300 |
commit | 8ab276d489c121c9f53bf9b55e20188acb744ea3 (patch) | |
tree | 8a5e301b5e920d1102744fef69319b381cfe1b9b /gn3 | |
parent | 469a6a878f0a305ac7fbab9d3b4ff9913d3f462c (diff) | |
download | genenetwork3-8ab276d489c121c9f53bf9b55e20188acb744ea3.tar.gz |
Fetch a publication by its PubMed ID
Diffstat (limited to 'gn3')
-rw-r--r-- | gn3/db/phenotypes.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/gn3/db/phenotypes.py b/gn3/db/phenotypes.py index a908c41..009dc1a 100644 --- a/gn3/db/phenotypes.py +++ b/gn3/db/phenotypes.py @@ -141,3 +141,13 @@ def fetch_publication_by_id(conn: DBConnection, publication_id: int) -> dict: "WHERE Id=%(publication_id)s"), {"publication_id": publication_id}) return cursor.fetchone() + +def fetch_publication_by_pubmed_id(conn: DBConnection, pubmed_id: int) -> dict: + """Fetch the publication by its PUBMED ID.""" + with conn.cursor(cursorclass=DictCursor) as cursor: + cols = ', '.join(mapping_to_query_columns(publication_mapping)) + cursor.execute( + (f"SELECT Id as id, {cols} FROM Publication " + "WHERE PubMed_Id=%(pubmed_id)s"), + {"pubmed_id": pubmed_id}) + return cursor.fetchone() |