From 9810ad334b33f606f969afea55d6f3524de8ec50 Mon Sep 17 00:00:00 2001 From: Dennis Piehl Date: Thu, 9 May 2024 01:00:05 -0400 Subject: [PATCH] V1.23 Tweak to BIRD citation method; update setuptools config --- HISTORY.txt | 3 ++- .../dictionary/DictMethodChemRefHelper.py | 26 ++++++++++++++----- rcsb/utils/dictionary/__init__.py | 2 +- setup.cfg | 2 +- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/HISTORY.txt b/HISTORY.txt index 8e9c238..3496e67 100644 --- a/HISTORY.txt +++ b/HISTORY.txt @@ -129,4 +129,5 @@ 26-Mar-2024 - V1.20 Add GlyGen annotation 'type' to polymer entity instances, but temporarily turn off loading Fix incremental update method for NeighborInteractionWorkflow 1-Apr-2024 - V1.21 Turn on GlyGen annotations loading - 3-May-2024 - V1.22 Adjust BIRD citation method in DictMethodChemRefHelper \ No newline at end of file + 3-May-2024 - V1.22 Adjust BIRD citation method in DictMethodChemRefHelper + 9-May-2024 - V1.23 Tweak to above update (V1.22); update setuptools config \ No newline at end of file diff --git a/rcsb/utils/dictionary/DictMethodChemRefHelper.py b/rcsb/utils/dictionary/DictMethodChemRefHelper.py index c29be8a..230f25e 100644 --- a/rcsb/utils/dictionary/DictMethodChemRefHelper.py +++ b/rcsb/utils/dictionary/DictMethodChemRefHelper.py @@ -797,6 +797,7 @@ def addChemCompDescriptor(self, dataContainer, catName, **kwargs): def renameCitationCategory(self, dataContainer, catName, **kwargs): """Rename citation and citation author categories. + Note that this method is run twice: once for catName 'rcsb_bird_citation', and once for 'rcsb_bird_citation_author' Args: dataContainer (object): mmif.api.DataContainer object instance @@ -807,22 +808,35 @@ def renameCitationCategory(self, dataContainer, catName, **kwargs): """ try: _ = kwargs + ok = False logger.debug("Starting with %r %r", dataContainer.getName(), catName) + # + catDestSrcMap = { + "rcsb_bird_citation": "citation", + "rcsb_bird_citation_author": "citation_author", + } + # if not (dataContainer.exists("chem_comp") and dataContainer.exists("pdbx_chem_comp_identifier")): return False containerName = dataContainer.getName() if not containerName.upper().startswith("PRD_"): return False # + if catName not in catDestSrcMap: + logger.error("Unsupported catName %r", catName) + return False + # # Copy target categories to new name - if dataContainer.exists("citation"): - dataContainer.copy("citation", "rcsb_bird_citation") - if dataContainer.exists("citation_author"): - dataContainer.copy("citation_author", "rcsb_bird_citation_author") - return True + ccId = dataContainer.getObj("chem_comp").getValue("id", 0) + srcCat = catDestSrcMap[catName] + logger.debug("Working on containerName %r ccId %r srcCatName %r catName %r", containerName, ccId, srcCat, catName) + if dataContainer.exists(srcCat) and not dataContainer.exists(catName): + ok = dataContainer.copy(srcCat, catName) + if not ok: + logger.error("Failed for containerName %r ccId %r srcCatName %r catName %r", containerName, ccId, srcCat, catName) + return ok except Exception as e: logger.exception("For %s failing with %s", catName, str(e)) - return False def addChemCompSynonyms(self, dataContainer, catName, **kwargs): diff --git a/rcsb/utils/dictionary/__init__.py b/rcsb/utils/dictionary/__init__.py index d07d929..757aff7 100644 --- a/rcsb/utils/dictionary/__init__.py +++ b/rcsb/utils/dictionary/__init__.py @@ -2,4 +2,4 @@ __author__ = "John Westbrook" __email__ = "john.westbrook@rcsb.org" __license__ = "Apache 2.0" -__version__ = "1.22" +__version__ = "1.23" diff --git a/setup.cfg b/setup.cfg index 53bb53d..360a483 100755 --- a/setup.cfg +++ b/setup.cfg @@ -3,5 +3,5 @@ universal=1 [metadata] -description-file = README.md +description_file = README.md