From 90e42dd61c91789664c046141fbcbb720ca9901c Mon Sep 17 00:00:00 2001 From: B13nch3n <b13nch3n_01@theb-si.de> Date: Tue, 23 May 2023 09:14:05 +0200 Subject: [PATCH] Make validation work with dictionary version 1.4.5 (info on PDBx dic split up into its single components) --- validation/Dockerfile | 6 ++-- validation/get-mmcif-dict-versions.py | 44 ++++----------------------- 2 files changed, 8 insertions(+), 42 deletions(-) diff --git a/validation/Dockerfile b/validation/Dockerfile index 0ccd36c..7e91748 100644 --- a/validation/Dockerfile +++ b/validation/Dockerfile @@ -80,7 +80,7 @@ COPY --chmod=755 validate-mmcif-file.py /usr/local/bin/validate-mmcif-file ## https://github.com/ihmwg/ModelCIF/blob/master/dist/mmcif_ma.dic. ## Dictionaries do not change that frequently therefore we skip the hassle of ## keeping them in an external volume. -ARG USE_DICT_VERSION="1.4.4" +ARG USE_DICT_VERSION="1.4.5" ENV USE_DICT_VERSION=${USE_DICT_VERSION} LABEL org.modelarchive.dict_release="${USE_DICT_VERSION}" WORKDIR ${SRC_DIR} @@ -118,9 +118,7 @@ RUN set -e pipefail; \ -dictSdbFile ${MMCIF_DICTS_DIR}/mmcif_pdbx_v50.dic.sdb; \ # ## Get versions of ModelCIF & PDBx/mmCIF dictionaries - get-mmcif-dict-versions --parent-location ${_GIT_URL}/base/mmcif_pdbx_v50.dic \ - --child-location ${_MA_DICT_URL} \ - mmcif_ma.dic; \ + get-mmcif-dict-versions --child-location ${_MA_DICT_URL} mmcif_ma.dic; \ mv mmcif_ma_version.json ${MMCIF_DICTS_DIR}/; \ # ## Make SDBs readable and keep possible error logs from building them diff --git a/validation/get-mmcif-dict-versions.py b/validation/get-mmcif-dict-versions.py index da1f1ea..7532e5b 100755 --- a/validation/get-mmcif-dict-versions.py +++ b/validation/get-mmcif-dict-versions.py @@ -25,15 +25,6 @@ def _parse_command_line(): metavar="<DICTIONARY FILE>", help="The mmCIF dictionary file to read the versions from.", ) - parser.add_argument( - "--parent", - "-p", - type=str, - metavar="<NAME OF PARENT DICT>", - help="Name of to the 'parent' dictionary. This is the one the other " - + "dictionary is appended to. This is usually the mmcif_pdbx_v50.dic.", - default="mmcif_pdbx_v50.dic", - ) parser.add_argument( "--output", "-o", @@ -42,14 +33,6 @@ def _parse_command_line(): help="Path to store the JSON file with the version at.", default="mmcif_ma_version.json", ) - parser.add_argument( - "--parent-location", - "-u", - type=str, - metavar="<URL OF PARENT DICT FILE>", - help="Download location of the parent dictionary file.", - default=None, - ) parser.add_argument( "--child-location", "-l", @@ -90,7 +73,7 @@ def _get_data_item(itm, cat, file_name, cat_data): return val[0] -def _get_versions(dic_file, parent_name, io_adapter): +def _get_versions(dic_file, io_adapter): """Fetch the 'category_group_list' object and assemble a version for the dictionary.""" @@ -112,24 +95,11 @@ def _get_versions(dic_file, parent_name, io_adapter): ttl = _get_data_item("title", "dictionary", dic_file, dic) dic_version = {"title": ttl, "version": vrsn} - cmp = _get_data_cat("pdbx_dictionary_component", dic_file, cntnr) - dc_idx = cmp.getAttributeIndex("dictionary_component_id") - vs_idx = cmp.getAttributeIndex("version") - for row in cmp: - if row[dc_idx] == parent_name: - vrsn = row[vs_idx] - prnt_version = {"title": parent_name, "version": vrsn} - break - - return dic_version, prnt_version + return dic_version -def _add_dict_location(parent, child, parent_loc, child_loc): +def _add_dict_location(child, child_loc): """Add URLs to the dictionary versions if available.""" - if parent_loc is None: - parent["location"] = "." - else: - parent["location"] = parent_loc if child_loc is None: child["location"] = "." else: @@ -141,13 +111,11 @@ def _main(): opts = _parse_command_line() io_adapter = IoAdapterPy(False, sys.stdout) - c_vrsn, p_vrsn = _get_versions(opts.dic_file, opts.parent, io_adapter) + c_vrsn = _get_versions(opts.dic_file, io_adapter) - _add_dict_location( - p_vrsn, c_vrsn, opts.parent_location, opts.child_location - ) + _add_dict_location(c_vrsn, opts.child_location) with open(opts.output, "w", encoding="utf8") as jfh: - json.dump({"versions": [p_vrsn, c_vrsn]}, jfh) + json.dump({"versions": [c_vrsn]}, jfh) if __name__ == "__main__": -- GitLab