diff options
author | Frederick Muriuki Muriithi | 2025-03-26 15:59:40 -0500 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2025-03-26 16:00:18 -0500 |
commit | ee9c2e021759e967e9a257843579519e2fd2286e (patch) | |
tree | e73581b929fa2bc4cd582e839a2047c91a8c4685 /scripts | |
parent | 3c71f0ef05b3d3a0abdb6e6b826e318a0994d113 (diff) | |
download | gn-uploader-ee9c2e021759e967e9a257843579519e2fd2286e.tar.gz |
Fetch existing publications from the database.
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/phenotypes_bulk_edit.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/scripts/phenotypes_bulk_edit.py b/scripts/phenotypes_bulk_edit.py index 8da3c77..72a901a 100644 --- a/scripts/phenotypes_bulk_edit.py +++ b/scripts/phenotypes_bulk_edit.py @@ -82,6 +82,20 @@ def descriptions_differences(file_data, db_data) -> dict[str, str]: def compute_differences(conn, file_contents, pheno_ids, pheno_xref_ids) -> tuple[tuple[dict, ...], tuple[dict, ...], tuple[dict, ...]]: +def __fetch_publications__(conn, ids): + """Fetch publication from database by ID.""" + paramstr = ",".join(["(%s, %s)"] * len(ids)) + query = ( + "SELECT " + "pxr.PhenotypeId, pxr.Id AS xref_id, pxr.PublicationId, pub.PubMed_ID " + "FROM PublishXRef AS pxr INNER JOIN Publication AS pub " + "ON pxr.PublicationId=pub.Id " + f"WHERE (pxr.PhenotypeId, pxr.Id) IN ({paramstr})") + with conn.cursor(cursorclass=DictCursor) as cursor: + cursor.execute(query, tuple(item for row in ids for item in row)) + return tuple(dict(row) for row in cursor.fetchall()) + + """Compute differences between data in DB and edited data.""" logger.info("Computing differences.") # 1. Basic Phenotype data differences |