diff options
author | zsloan | 2022-05-31 20:59:09 +0000 |
---|---|---|
committer | zsloan | 2022-05-31 20:59:09 +0000 |
commit | fead71fd128f36104b0134968abc28803bc4fd0d (patch) | |
tree | ccd5bf9e89d910b26fd4e844bf240804280958ab /wqflask | |
parent | 89a7868175c7594be91d638974ac1054fc3c8659 (diff) | |
download | genenetwork2-fead71fd128f36104b0134968abc28803bc4fd0d.tar.gz |
Check if entered pubmed_id is already associated with a publication, and
set PublishXRef.PublicationId equal to that Id if it exists
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/wqflask/metadata_edits.py | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/wqflask/wqflask/metadata_edits.py b/wqflask/wqflask/metadata_edits.py index cd5b7893..5a5ee4ac 100644 --- a/wqflask/wqflask/metadata_edits.py +++ b/wqflask/wqflask/metadata_edits.py @@ -339,12 +339,28 @@ def update_phenotype(dataset_id: str, name: str): } updated_publications = "" with database_connection() as conn: - updated_publications = update( - conn, - "Publication", - data=Publication(**publication_), - where=Publication(id_=data_.get("old_id_")), + + existing_publication = fetchone( + conn=conn, + table="Publication", + where=Publication(pubmed_id=data_.get("pubmed-id")) ) + + if existing_publication: + update( + conn, + "PublishXRef", + data=PublishXRef(publication_id=existing_publication.id_), + where=PublishXRef(id_=name, inbred_set_id=dataset_id) + ) + else: + updated_publications = update( + conn, + "Publication", + data=Publication(**publication_), + where=Publication(id_=data_.get("old_id_")), + ) + if updated_publications: diff_data.update( { |