diff --git a/.gitmodules b/.gitmodules index b2c5b7a..e69de29 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "wwpdb/mock-data"] - path = wwpdb/mock-data - url = ../py-onedep_mock_data.git diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 27b623d..b1843b5 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -31,6 +31,8 @@ jobs: parameters: {tox: 'lint_pylint', python: '3.10', os: 'linux'} - template: azure-template-tox-job.yml parameters: {tox: 'test_coverage', python: '3.10', os: 'linux'} + - template: azure-template-tox-job.yml + parameters: {tox: 'mypy', python: '3.10', os: 'linux'} # - template: azure-template-tox-job.yml parameters: {tox: 'py310', python: '3.10', os: 'linux'} diff --git a/azure-template-publish-job.yml b/azure-template-publish-job.yml index 2c89f36..4920cef 100644 --- a/azure-template-publish-job.yml +++ b/azure-template-publish-job.yml @@ -41,8 +41,6 @@ jobs: - download: current artifact: ${{ format('sw_{0}_{1}', parameters.tox, parameters.os) }} - - download: current - artifact: ${{ format('sw_u_{0}_{1}', parameters.tox, parameters.os) }} # - script: ls -lR $(Pipeline.Workspace)/${{ format('sw_{0}_{1}', parameters.tox, parameters.os) }} displayName: "Listing of downloaded artifacts" @@ -57,11 +55,6 @@ jobs: secureFile: 'PYPIRC-AZURE' - ${{ if startsWith(parameters.os, 'linux') }}: - - script: twine upload --verbose --skip-existing -r pypi --config-file $(pypicred.secureFilePath) $(Pipeline.Workspace)/${{ format('sw_u_{0}_{1}', parameters.tox, parameters.os) }}/* - displayName: "Linux upload sdist and source wheel to PyPi ..." - continueOnError: true - # - - ${{ if startsWith(parameters.os, 'macos') }}: - script: twine upload --verbose --skip-existing -r pypi --config-file $(pypicred.secureFilePath) $(Pipeline.Workspace)/${{ format('sw_{0}_{1}', parameters.tox, parameters.os) }}/* - displayName: "Mac upload sdist and binary wheel to PyPi ..." + displayName: "Linux upload sdist and source wheel to PyPi ..." continueOnError: true diff --git a/azure-template-tox-job.yml b/azure-template-tox-job.yml index 73d62c8..3bffd6f 100644 --- a/azure-template-tox-job.yml +++ b/azure-template-tox-job.yml @@ -182,23 +182,15 @@ jobs: # Build artifacts if this is a test target (i.e. labeled as py##) # - ${{ if startsWith(parameters.tox, 'py') }}: - - script: pip install --upgrade pip twine setuptools wheel + - script: pip install --upgrade pip twine build wheel displayName: "Acquire build tools" - - script: python setup.py sdist --dist-dir "$(System.DefaultWorkingDirectory)/dist" - displayName: "Build source dist" - - script: python setup.py bdist_wheel --dist-dir "$(System.DefaultWorkingDirectory)/dist" - displayName: "Build wheel" - # - - script: python setup.py sdist --dist-dir "$(System.DefaultWorkingDirectory)/udist" - displayName: "Build source dist" + - script: python -m build --outdir "$(System.DefaultWorkingDirectory)/dist" + displayName: "Build source distributions" # # Check the install artifacts - - script: ls -lR "$(System.DefaultWorkingDirectory)/dist" "$(System.DefaultWorkingDirectory)/udist" + - script: ls -lR "$(System.DefaultWorkingDirectory)/dist" displayName: "Listing of installed software" # - publish: $(System.DefaultWorkingDirectory)/dist artifact: ${{ format('sw_{0}_{1}', parameters.tox, parameters.os) }} # - - publish: $(System.DefaultWorkingDirectory)/udist - artifact: ${{ format('sw_u_{0}_{1}', parameters.tox, parameters.os) }} - # diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..9c50a3c --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,174 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "wwpdb.utils.oe-util" +dynamic = ["version"] +description = "wwPDB workflow engine utils" +readme = "README.md" +license = "Apache-2.0" +authors = [ + { name = "Ezra Peisach", email = "ezra.peisach@rcsb.org" }, +] +classifiers = [ + "Development Status :: 3 - Alpha", + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Natural Language :: English", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", +] +dependencies = [ + "mmcif.utils", + "OpenEye-toolkits ; python_version >= '3'", + "OpenEye-toolkits-python2.7-ucs2-linux-x64 == 2016.6.1; python_version == '2.7' and sys_platform=='linux2'", + "wwpdb.utils.cc_dict_util >= 0.2", +] + +requires-python = ">=3.6" + +# https://hatch.pypa.io/latest/how-to/environment/dependency-resolution/ +[project.optional-dependencies] +dev = [ + "check-manifest", +] +test = [ + "coverage", +] + +[project.scripts] + +[project.urls] +Homepage = "https://github.com/rcsb/py-wwpdb_apps_wf_engine_utils" + +[tool.hatch.version] +path = "wwpdb/utils/oe_util/__init__.py" + +[tool.hatch.build.targets.sdist] +include = [ + "/wwpdb", +] + +exclude = ["/wwpdb/mock-data", "/wwpdb/utils/oe_util/Archive"] + +[tool.hatch.build.targets.wheel] +packages = ["wwpdb"] + +exclude = ["/wwpdb/mock-data", "/wwpdb/utils/oe_util/Archive"] + +#=================================== Ruff basics =============================# +[tool.ruff] + +line-length = 120 # 120 is hatch's default via 'hatch init' +include = [ + "*.py", # Source + "pyproject.toml", # This file (RUF rules only) + "*.ipynb", # Jupyter notebooks +] + +exclude = ["Archive"] + +# +#=================================== Ruff lint ==============================# + +[tool.ruff.lint] + +# +# ------------------------- Ruff misc. options ---------------------- +preview = true +explicit-preview-rules = true + +ignore = [ + "C402", # Unnecessary generator (rewrite as a `dict` comprehension) + "EXE001", # Shebang is present but file is not executabl + "FBT002", # Boolean default positional argument in function definition + "FBT001", # Boolean-typed positional argument in function definition + "FURB113", # Use `stPL.extend(...)` instead of repeatedly calling `stPL.append()` + "INP001", # File `xx` is part of an implicit namespace package. Add an `__init__.py + "N801", # Class name `markdownTests` should use CapWords convention + "N802", # Function name should be lowercase + "N803", # Argument name should be lowercase + "N806", # in function should be lowercase + "N815", # Caiable... in class shope should not be mixedCase + "N816", # Variable in global scope should not be mixedCase + "N999", # Invalid module name, + "PERF401", # Use a list comprehension to create a transformed list + "PERF403", # Use a dictionary comprehension instead of a for-loop + "PLR1714", # Consider merging multiple comparisons + "PLR2004", # Magic value used in comparison, consider replacing + "PLR6201", # Use a `set` literal when testing for membership + "PLR6301", # Method `` could be a function, class method, or static method + "PLW1514", # `open` in text mode without explicit `encoding` argument + "PT009", # Use a regular `assert` instead of unittest-style `assertGreater` + "RET504", # Unnecessary assignment to `X` before `return` statement + "RUF100", # RUF REMOVES FLAKE8 noqa! + "S110", # `try`-`except`-`pass` detected, consider logging the exception + "SIM102", # Use a single `if` statement instead of nested `if` statements + "SIM103", # Return the condition directly + "SIM108", # Use ternary operator + "SIM115", # Use context handler for opening files + "TRY300", # Consider moving this statement to an `else` block + "TRY400", # Use `logging.exception` instead of `logging.error` + "TRY401", # Redundant exception object included in `logging.exception` call + "UP008", # Use `super()` instead of `super(__class__, self)` + "UP031" # Use format specifiers instead of percent format +] + +# -------------------- default environment scripts ------------------ +[tool.hatch.envs.default] +skip-install = true +dependencies = ["mypy", "ruff >=0.6.9", "wwpdb.utils.testing", "OpenEye-toolkits~=2022.1.1"] + +[tool.hatch.envs.default.env-vars] +PIP_EXTRA_INDEX_URL = "https://pypi.anaconda.org/OpenEye/simple" + + +[tool.hatch.envs.default.scripts] + +# 'format' formats and fixes issues but does not complain +format = [ + "ruff format", + "ruff check --fix-only", +] + +# 'format-python' just excludes Prettier +format-python = ["ruff format", "ruff check --fix-only"] + +# 'check' only checks but never fixes +check = ["ruff check --no-fix .", "mypy --non-interactive --install-types -p wwpdb -p tests"] + +# only checks with ruff (mypy has a lot of false positives) +check-ruff = "ruff check --no-fix . {args}" + +# to complement 'check-ruff' +check-mypy = "mypy --non-interactive --install-types wwpdb tests {args}" + +# only check security via Bandit; we require these rules to pass +check-security = "ruff check --select S --no-fix ." + +# ----------------------- testing environment ---------------- +[tool.hatch.envs.hatch-test] +dependencies = ["tox"] + +[tool.hatch.envs.hatch-test.scripts] +run = ["tox"] + + +# ------------------------- Mypy disable --------- +[[tool.mypy.overrides]] +module = ["wwpdb.*", "openeye.*", "mmcif_utils.*", "mmcif.*"] +ignore_missing_imports = true + +[tool.mypy] +exclude = [ + "test-output", +] + +# ------------------------ ruff disable until typing added +[tool.ruff.lint.per-file-ignores] +"awwpdb/utils/config/ConfigInfoData.py" = ["RUF012"] # typing.ClassVar +"wwpdb/utils/config/ConfigInfoData.py" = ["SLF001", "RUF012", "F401"] # Private member access, should use typing.ClassVar, do not remove unused imports + diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 360a483..0000000 --- a/setup.cfg +++ /dev/null @@ -1,7 +0,0 @@ -[bdist_wheel] -# use py2.py3 tag for pure-python dist: -universal=1 - -[metadata] -description_file = README.md - diff --git a/setup.py b/setup.py deleted file mode 100755 index dbb8250..0000000 --- a/setup.py +++ /dev/null @@ -1,75 +0,0 @@ -# File: setup.py -# Date: 6-Oct-2018 -# -# Update: -# -import re - -from setuptools import find_packages -from setuptools import setup -import sys - -if sys.version_info[0] < 3: - from io import open as open - -packages = [] -thisPackage = "wwpdb.utils.oe_util" - -with open("wwpdb/utils/oe_util/__init__.py", "r", encoding="utf-8") as fd: - version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) - -if not version: - raise RuntimeError("Cannot find version information") - - -setup( - name=thisPackage, - version=version, - description="wwPDB workflow engine utils", - long_description="See: README.md", - author="Ezra Peisach", - author_email="ezra.peisach@rcsb.org", - url="https://github.com/rcsb/py-wwpdb_apps_wf_engine_utils", - # - license="Apache 2.0", - classifiers=[ - "Development Status :: 3 - Alpha", - # 'Development Status :: 5 - Production/Stable', - "Intended Audience :: Developers", - "Natural Language :: English", - "License :: OSI Approved :: Apache Software License", - "Programming Language :: Python", - "Programming Language :: Python :: 2.7", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - ], - entry_points={"console_scripts": []}, - # - # Also depends on 'openeye.oechem' but cannot install by pypi - install_requires=[ - "mmcif.utils", - "wwpdb.utils.cc_dict_util ~= 0.2", - "OpenEye-toolkits-python2.7-ucs2-linux-x64 == 2016.6.1; python_version == '2.7' and sys_platform=='linux2'", - "OpenEye-toolkits ; python_version >= '3'", - ], - packages=find_packages(exclude=["wwpdb.utils.tests_oe_util"]), - package_data={ - # If any package contains *.md or *.rst ... files, include them: - "": ["*.md", "*.rst", "*.txt", "*.cfg"] - }, - # - # These basic tests require no database services - - test_suite="wwpdb.utils.tests_oe_util", - tests_require=["tox"], - # - # Not configured ... - extras_require={ - "dev": ["check-manifest"], - "test": ["coverage"], - }, - # Added for - command_options={"build_sphinx": {"project": ("setup.py", thisPackage), "version": ("setup.py", version), "release": ("setup.py", version)}}, - # This setting for namespace package support - - zip_safe=False, -) diff --git a/wwpdb/utils/tests_oe_util/Archive/OeShapeSearchTests.py b/tests/Archive/OeShapeSearchTests.py similarity index 100% rename from wwpdb/utils/tests_oe_util/Archive/OeShapeSearchTests.py rename to tests/Archive/OeShapeSearchTests.py diff --git a/wwpdb/utils/tests_oe_util/OeAlignDepictTests.py b/tests/OeAlignDepictTests.py similarity index 92% rename from wwpdb/utils/tests_oe_util/OeAlignDepictTests.py rename to tests/OeAlignDepictTests.py index c65b116..942dd4b 100644 --- a/wwpdb/utils/tests_oe_util/OeAlignDepictTests.py +++ b/tests/OeAlignDepictTests.py @@ -14,6 +14,7 @@ MCSS comparison and depiction. """ + __docformat__ = "restructuredtext en" __author__ = "John Westbrook" __email__ = "jwest@rcsb.rutgers.edu" @@ -21,15 +22,13 @@ __version__ = "V0.01" -import unittest -import traceback -import sys -import platform +import builtins import os import os.path - -if sys.version_info[0] < 3: - from io import open as open +import platform +import sys +import traceback +import unittest try: from openeye.oechem import OEFloatArray # noqa: F401 pylint: disable=unused-import @@ -47,7 +46,6 @@ class OeAlignDepictTests(unittest.TestCase): def setUp(self): self.__lfh = sys.stderr self.__verbose = False - # self.__here = os.path.abspath(os.path.dirname(__file__)) self.__examples = os.path.join(self.__here, "examples") @@ -59,9 +57,7 @@ def setUp(self): # Chemical component repository path - self.__topCachePath = os.path.join(self.__here, "ligand-dict-v3") self.__rnaPairFile = os.path.join(self.__examples, "rna-linking-components.txt") - # self.__refId = "C" - # self.__idList = ["cg1", "atp", "gtp", "A", "C", "G", "DG"] self.__pairIdList = [("c", "cg1"), ("c", "atp"), ("c", "gtp"), ("c", "A"), ("c", "C"), ("c", "G"), ("c", "DG")] @@ -70,7 +66,7 @@ def tearDown(self): def __readPairList(self, fn="./examples/rna-linking-components.txt"): pairList = [] - ifh = open(fn, "r", encoding="utf-8") + ifh = builtins.open(fn, encoding="utf-8") for line in ifh: fields = line.split() pairList.append((fields[1], fields[0])) @@ -88,7 +84,7 @@ def testMCSAlignPairDepict(self): fName = os.path.join(self.__testoutput, "ref-" + self.__refId + "-trg-" + fitId + ".png") aML = oed.alignPair(imagePath=fName) if len(aML) > 0: - for (rCC, rAt, tCC, tAt) in aML: + for rCC, rAt, tCC, tAt in aML: self.__lfh.write("%5s %-5s %5s %-5s\n" % (rCC, rAt, tCC, tAt)) except: # noqa: E722 pylint: disable=bare-except traceback.print_exc(file=self.__lfh) @@ -104,7 +100,7 @@ def testMCSAlignListDepict(self): imageFile = os.path.join(self.__testoutput, "list-example-mcs-alignment.pdf") aML = oed.alignPairList(imagePath=imageFile) if len(aML) > 0: - for (rCC, rAt, tCC, tAt) in aML: + for rCC, rAt, tCC, tAt in aML: self.__lfh.write("%5s %-5s %5s %-5s\n" % (rCC, rAt, tCC, tAt)) except: # noqa: E722 pylint: disable=bare-except @@ -120,7 +116,7 @@ def testMCSAlignPairListDepict(self): imageFile = os.path.join(self.__testoutput, "pair-list-example-mcs-alignment.pdf") aML = oed.alignPairList(imagePath=imageFile) if len(aML) > 0: - for (rCC, rAt, tCC, tAt) in aML: + for rCC, rAt, tCC, tAt in aML: self.__lfh.write("%5s %-5s %5s %-5s\n" % (rCC, rAt, tCC, tAt)) except: # noqa: E722 pylint: disable=bare-except @@ -137,7 +133,7 @@ def testMCSAlignRnaPairListDepict(self): imageFile = os.path.join(self.__testoutput, "rna-modified-pair-alignment.pdf") aML = oed.alignPairList(imagePath=imageFile) if len(aML) > 0: - for (rCC, rAt, tCC, tAt) in aML: + for rCC, rAt, tCC, tAt in aML: self.__lfh.write("%5s %-5s %5s %-5s\n" % (rCC, rAt, tCC, tAt)) except: # noqa: E722 pylint: disable=bare-except @@ -173,7 +169,6 @@ def testSdfMCSAlignAtomMap(self): oed = OeDepictMCSAlign(verbose=self.__verbose, log=self.__lfh) # oed.setSearchType(sType='exact') oed.setSearchType(sType="exact") - # oed.setRefPath(refPath, type="SDF") # oed.setFitId(fitId,cachePath=self.__topCachePath) oed.setFitPath(fitPath, title="ATP") @@ -194,14 +189,18 @@ def testMCSRelaxAlignPairDepict(self): try: oed = OeDepictMCSAlign(verbose=self.__verbose, log=self.__lfh) oed.setSearchType(sType="relaxed") - oed.setRefPath(ccPath=os.path.join(self.__examples, "PRDCC_000225.cif"), title="PRD_000225", suppressHydrogens=False) - oed.setFitPath(ccPath=os.path.join(self.__examples, "L_LDI_990_.comp.cif"), title="L_LDI_990", suppressHydrogens=False) + oed.setRefPath( + ccPath=os.path.join(self.__examples, "PRDCC_000225.cif"), title="PRD_000225", suppressHydrogens=False + ) + oed.setFitPath( + ccPath=os.path.join(self.__examples, "L_LDI_990_.comp.cif"), title="L_LDI_990", suppressHydrogens=False + ) fName = os.path.join(self.__testoutput, "relaxed-fit.png") aML = oed.alignPair(imagePath=fName) if len(aML) > 0: - for (rCC, rAt, tCC, tAt) in aML: + for rCC, rAt, tCC, tAt in aML: self.__lfh.write("%5s %-5s %5s %-5s\n" % (rCC, rAt, tCC, tAt)) - except Exception as e: # noqa: F841 pylint: disable=unused-variable + except Exception as e: # noqa: F841,BLE001 pylint: disable=unused-variable traceback.print_exc(file=self.__lfh) self.fail() @@ -237,10 +236,8 @@ def suite(): # mySuite1 = suiteAlignPair() unittest.TextTestRunner(verbosity=2).run(mySuite1) - # mySuite1 = suiteAlignPairRelax() unittest.TextTestRunner(verbosity=2).run(mySuite1) - # mySuite1 = suiteAlignExtPairRelax() unittest.TextTestRunner(verbosity=2).run(mySuite1) diff --git a/wwpdb/utils/tests_oe_util/OeAlignDepictUtilsTests.py b/tests/OeAlignDepictUtilsTests.py similarity index 90% rename from wwpdb/utils/tests_oe_util/OeAlignDepictUtilsTests.py rename to tests/OeAlignDepictUtilsTests.py index 66f232e..571ab04 100644 --- a/wwpdb/utils/tests_oe_util/OeAlignDepictUtilsTests.py +++ b/tests/OeAlignDepictUtilsTests.py @@ -15,6 +15,7 @@ MCSS comparison and depiction. """ + __docformat__ = "restructuredtext en" __author__ = "John Westbrook" __email__ = "jwest@rcsb.rutgers.edu" @@ -22,15 +23,13 @@ __version__ = "V0.01" -import sys -import unittest -import traceback -import platform +import builtins import os import os.path - -if sys.version_info[0] < 3: - from io import open as open +import platform +import sys +import traceback +import unittest try: from openeye.oechem import OEFloatArray # noqa: F401 pylint: disable=unused-import @@ -40,7 +39,12 @@ skiptests = True if not skiptests: - from wwpdb.utils.oe_util.oedepict.OeAlignDepictUtils import OeDepictMCSAlign, OeDepictMCSAlignMulti, OeDepictMCSAlignSingle, OeTestMCSAlign + from wwpdb.utils.oe_util.oedepict.OeAlignDepictUtils import ( + OeDepictMCSAlign, + OeDepictMCSAlignMulti, + OeDepictMCSAlignSingle, + OeTestMCSAlign, + ) @unittest.skipIf(skiptests, "Could not import openeye") @@ -48,7 +52,6 @@ class OeAlignDepictUtilsTests(unittest.TestCase): def setUp(self): self.__lfh = sys.stderr self.__verbose = True - # self.__here = os.path.abspath(os.path.dirname(__file__)) self.__examples = os.path.join(self.__here, "examples") self.__testoutput = os.path.join(self.__here, "test-output", platform.python_version()) @@ -58,12 +61,9 @@ def setUp(self): # Chemical component repository path - self.__topCachePath = os.path.join(self.__here, "ligand-dict-v3") self.__rnaPairFile = os.path.join(self.__examples, "rna-linking-components.txt") - # self.__refId = "C" - # self.__idList = ["cg1", "atp", "gtp", "A", "C", "G", "DG"] self.__pairIdList = [("c", "cg1"), ("c", "atp"), ("c", "gtp"), ("c", "A"), ("c", "C"), ("c", "G"), ("c", "DG")] - # self.__refPathTup = ("A", os.path.join(self.__datadir, "A.cif"), os.path.join(self.__testoutput, "A-ref.svg")) self.__fitPathTupList = [ ("A", os.path.join(self.__datadir, "A.cif"), os.path.join(self.__testoutput, "A-fit.svg")), @@ -71,14 +71,13 @@ def setUp(self): ("ATP", os.path.join(self.__datadir, "ATP.cif"), os.path.join(self.__testoutput, "ATP-fit.svg")), ("GTP", os.path.join(self.__datadir, "GTP.cif"), os.path.join(self.__testoutput, "GTP-fit.svg")), ] - # def tearDown(self): pass def __readPairList(self, fn="./examples/rna-linking-components.txt"): pairList = [] - ifh = open(fn, "r", encoding="utf-8") + ifh = builtins.open(fn, encoding="utf-8") for line in ifh: fields = line.split() pairList.append((fields[1], fields[0])) @@ -91,7 +90,12 @@ def testMCSAlignPairDepict(self): try: oed = OeDepictMCSAlign(verbose=self.__verbose, log=self.__lfh) oed.setDisplayOptions( - labelAtomName=True, labelAtomCIPStereo=True, labelAtomIndex=False, labelBondIndex=False, highlightStyleFit="ballAndStickInverse", bondDisplayWidth=0.5 + labelAtomName=True, + labelAtomCIPStereo=True, + labelAtomIndex=False, + labelBondIndex=False, + highlightStyleFit="ballAndStickInverse", + bondDisplayWidth=0.5, ) oed.setRefId(self.__refId, cachePath=self.__topCachePath) @@ -100,7 +104,7 @@ def testMCSAlignPairDepict(self): fName = os.path.join(self.__testoutput, "ref-" + self.__refId + "-trg-" + fitId + ".svg") aML = oed.alignPair(imagePath=fName) if len(aML) > 0: - for (rCC, rAt, tCC, tAt) in aML: + for rCC, rAt, tCC, tAt in aML: self.__lfh.write("%5s %-5s %5s %-5s\n" % (rCC, rAt, tCC, tAt)) except: # noqa: E722 pylint: disable=bare-except traceback.print_exc(file=self.__lfh) @@ -126,7 +130,7 @@ def testMCSAlignFitListDepictMulti(self): imageFile = os.path.join(self.__testoutput, "list-example-mcs-alignment.pdf") aML = oed.alignOneWithListMulti(imagePath=imageFile) if len(aML) > 0: - for (rCC, rAt, tCC, tAt) in aML: + for rCC, rAt, tCC, tAt in aML: self.__lfh.write("%5s %-5s %5s %-5s\n" % (rCC, rAt, tCC, tAt)) except: # noqa: E722 pylint: disable=bare-except @@ -153,7 +157,7 @@ def testMCSAlignPairListDepictPortrait(self): imageFile = os.path.join(self.__testoutput, "pair-list-example-mcs-alignment-portrait.pdf") aML = oed.alignPairListMulti(imagePath=imageFile) if len(aML) > 0: - for (rCC, rAt, tCC, tAt) in aML: + for rCC, rAt, tCC, tAt in aML: self.__lfh.write("%5s %-5s %5s %-5s\n" % (rCC, rAt, tCC, tAt)) except: # noqa: E722 pylint: disable=bare-except traceback.print_exc(file=self.__lfh) @@ -167,19 +171,23 @@ def testMCSAlignRnaPairListDepict(self): oed = OeDepictMCSAlignMulti(verbose=self.__verbose, log=self.__lfh) oed.setPairIdList(pairIdList, cachePath=self.__topCachePath) oed.setDisplayOptions( - labelAtomName=True, labelAtomCIPStereo=True, labelAtomIndex=False, labelBondIndex=False, highlightStyleFit="ballAndStickInverse", bondDisplayWidth=0.5 + labelAtomName=True, + labelAtomCIPStereo=True, + labelAtomIndex=False, + labelBondIndex=False, + highlightStyleFit="ballAndStickInverse", + bondDisplayWidth=0.5, ) imageFile = os.path.join(self.__testoutput, "rna-modified-pair-alignment.pdf") aML = oed.alignPairListMulti(imagePath=imageFile) if len(aML) > 0: - for (rCC, rAt, tCC, tAt) in aML: + for rCC, rAt, tCC, tAt in aML: self.__lfh.write("%5s %-5s %5s %-5s\n" % (rCC, rAt, tCC, tAt)) except: # noqa: E722 pylint: disable=bare-except traceback.print_exc(file=self.__lfh) self.fail() - # def testMCSAlignAtomMap(self): """Test case - match test with return of atom maps""" self.__lfh.write("\nStarting OeAlignDepictUtilsTests testMCSAlignAtomMap\n") @@ -204,8 +212,18 @@ def testMCSRelaxAlignPairDepict(self): try: oed = OeDepictMCSAlign(verbose=self.__verbose, log=self.__lfh) oed.setSearchType(sType="relaxed") - oed.setRefPath(refId="PRD_000225", ccPath=os.path.join(self.__examples, "PRDCC_000225.cif"), title="PRD_000225", suppressHydrogens=False) - oed.setFitPath(fitId="LD_LDI_990", ccPath=os.path.join(self.__examples, "L_LDI_990_.comp.cif"), title="L_LDI_990", suppressHydrogens=False) + oed.setRefPath( + refId="PRD_000225", + ccPath=os.path.join(self.__examples, "PRDCC_000225.cif"), + title="PRD_000225", + suppressHydrogens=False, + ) + oed.setFitPath( + fitId="LD_LDI_990", + ccPath=os.path.join(self.__examples, "L_LDI_990_.comp.cif"), + title="L_LDI_990", + suppressHydrogens=False, + ) fName = os.path.join(self.__testoutput, "relaxed-fit.svg") oed.setDisplayOptions( imageSizeX=2000, @@ -219,7 +237,7 @@ def testMCSRelaxAlignPairDepict(self): ) aML = oed.alignPair(imagePath=fName) if len(aML) > 0: - for (rCC, rAt, tCC, tAt) in aML: + for rCC, rAt, tCC, tAt in aML: self.__lfh.write("%5s %-5s %5s %-5s\n" % (rCC, rAt, tCC, tAt)) except: # noqa: E722 pylint: disable=bare-except traceback.print_exc(file=self.__lfh) @@ -244,7 +262,7 @@ def testMCSAlignListMultiDepict(self): imageFile = os.path.join(self.__testoutput, "mcs-align-with-list-multi.pdf") aML = oed.alignOneWithListMulti(imagePath=imageFile) if len(aML) > 0: - for (rCC, rAt, tCC, tAt) in aML: + for rCC, rAt, tCC, tAt in aML: self.__lfh.write("%5s %-5s %5s %-5s\n" % (rCC, rAt, tCC, tAt)) except: # noqa: E722 pylint: disable=bare-except @@ -272,7 +290,7 @@ def testMCSAlignListDepict(self): imageFile = os.path.join(self.__testoutput, "mcs-align-with-list-single.svg") aML = oed.alignOneWithList(imagePath=imageFile) if len(aML) > 0: - for (rCC, rAt, tCC, tAt) in aML: + for rCC, rAt, tCC, tAt in aML: self.__lfh.write("%5s %-5s %5s %-5s\n" % (rCC, rAt, tCC, tAt)) except: # noqa: E722 pylint: disable=bare-except @@ -300,7 +318,7 @@ def testMCSAlignListDepictSingle(self): oed.setPairIdList(self.__pairIdList, cachePath=self.__topCachePath) aML = oed.alignOneWithList() if len(aML) > 0: - for (rCC, rAt, tCC, tAt) in aML: + for rCC, rAt, tCC, tAt in aML: self.__lfh.write("%5s %-5s %5s %-5s\n" % (rCC, rAt, tCC, tAt)) except: # noqa: E722 pylint: disable=bare-except @@ -318,7 +336,6 @@ def testMCSAlignPathListDepictSingle(self): try: # Use inverse highlighting of matching/non-matching atoms/bonds - hOpt = "inverse" - # oed = OeDepictMCSAlignSingle(verbose=self.__verbose, log=self.__lfh) if hOpt == "inverse": oed.setDisplayOptions( @@ -355,7 +372,9 @@ def testMCSAlignPathListDepictSingle(self): bondDisplayWidth=1.0, ) - oed.setRefPath(self.__refPathTup[0], self.__refPathTup[1], title=self.__refPathTup[0], imagePath=self.__refPathTup[2]) + oed.setRefPath( + self.__refPathTup[0], self.__refPathTup[1], title=self.__refPathTup[0], imagePath=self.__refPathTup[2] + ) for fitPathTup in self.__fitPathTupList: oed.addFitPath(fitPathTup[0], fitPathTup[1], title=fitPathTup[0], imagePath=fitPathTup[2]) @@ -364,7 +383,7 @@ def testMCSAlignPathListDepictSingle(self): # Write out no atom correspondences -- # if len(aML) > 0: - for (rCC, rAt, tCC, tAt) in aML: + for rCC, rAt, tCC, tAt in aML: self.__lfh.write("%5s %-5s %5s %-5s\n" % (rCC, rAt, tCC, tAt)) except: # noqa: E722 pylint: disable=bare-except @@ -403,16 +422,13 @@ def suiteAlignWithListSingle(): if __name__ == "__main__": - # mySuite1 = suiteAlignPair() unittest.TextTestRunner(verbosity=2).run(mySuite1) - # mySuite1 = suiteAlignWithList() unittest.TextTestRunner(verbosity=2).run(mySuite1) mySuite1 = suiteAlignTypeTests() unittest.TextTestRunner(verbosity=2).run(mySuite1) - # mySuite1 = suiteAlignWithListSingle() unittest.TextTestRunner(verbosity=2).run(mySuite1) diff --git a/wwpdb/utils/tests_oe_util/OeBirdAltDepictTests.py b/tests/OeBirdAltDepictTests.py similarity index 88% rename from wwpdb/utils/tests_oe_util/OeBirdAltDepictTests.py rename to tests/OeBirdAltDepictTests.py index d0574df..df91608 100644 --- a/wwpdb/utils/tests_oe_util/OeBirdAltDepictTests.py +++ b/tests/OeBirdAltDepictTests.py @@ -11,6 +11,7 @@ A collection of tests for the OEDepictAlignUtils class with FAMILY PRD data - """ + __docformat__ = "restructuredtext en" __author__ = "John Westbrook" __email__ = "jwest@rcsb.rutgers.edu" @@ -18,16 +19,14 @@ __version__ = "V0.01" -import sys -import unittest -import traceback -import platform -import time +import builtins import os import os.path - -if sys.version_info[0] < 3: - from io import open as open +import platform +import sys +import time +import traceback +import unittest try: from openeye.oechem import OEFloatArray # noqa: F401 pylint: disable=unused-import @@ -38,6 +37,7 @@ if not skiptests: from mmcif_utils.bird.PdbxBirdIndex import PdbxBirdIndex + from wwpdb.utils.oe_util.build.OeChemCompIoUtils import OeChemCompIoUtils from wwpdb.utils.oe_util.oedepict.OeAlignDepictUtils import OeDepictMCSAlignMulti from wwpdb.utils.oe_util.oedepict.OeDepict import OeDepictMultiPage @@ -66,7 +66,9 @@ def __testBuildBirdIndex(self): afD = {} pD = {} try: - bI = PdbxBirdIndex(indexPath=os.path.join(self.__testoutput, "bird-index.pic"), verbose=self.__verbose, log=self.__lfh) + bI = PdbxBirdIndex( + indexPath=os.path.join(self.__testoutput, "bird-index.pic"), verbose=self.__verbose, log=self.__lfh + ) familyIdL = bI.getFamilyList() for familyId in familyIdL: prdIdList = bI.getPrdIdList(familyId) @@ -81,7 +83,7 @@ def __testBuildBirdIndex(self): fD[familyId].append((familyId, prdId, ccId, ccPath)) pD[prdId] = (ccId, ccPath) - ifh = open(self.__altFamilyIndexPath, "r", encoding="utf-8") + ifh = builtins.open(self.__altFamilyIndexPath, encoding="utf-8") for line in ifh: fields = line.split() fId = fields[0].strip() @@ -131,14 +133,22 @@ def testFamilyDepiction(self): aML = oed.alignOneWithListMulti(imagePath=imageFileName) if len(aML) > 0: - for (rCC, rAt, tCC, tAt) in aML: + for rCC, rAt, tCC, tAt in aML: self.__lfh.write("%5s %-5s %5s %-5s\n" % (rCC, rAt, tCC, tAt)) else: oeU = OeChemCompIoUtils(verbose=self.__verbose, log=self.__lfh) oemList = oeU.getFromPathList([refCcPath], use3D=False) oed = OeDepictMultiPage(verbose=self.__verbose, log=self.__lfh) oed.setMolTitleList([(refPrdId, oemList[0], refPrdId)]) - oed.setDisplayOptions(labelAtomName=False, labelAtomCIPStereo=True, labelAtomIndex=False, labelBondIndex=False, gridRows=3, gridCols=3, bondDisplayWidth=0.5) + oed.setDisplayOptions( + labelAtomName=False, + labelAtomCIPStereo=True, + labelAtomIndex=False, + labelBondIndex=False, + gridRows=3, + gridCols=3, + bondDisplayWidth=0.5, + ) oed.prepare() oed.write(imageFileName) except: # noqa: E722 pylint: disable=bare-except @@ -149,7 +159,7 @@ def testFamilyDepictionHTMLIndex(self): """Test case - aligned family members --""" self.__lfh.write("\nStarting OeBirdDepictTests testFamilyDepictionHTMLIndex\n") tS = time.strftime("%Y %m %d %H:%M:%S", time.localtime()) - ofh = open("index.html", "w", encoding="utf-8") + ofh = builtins.open("index.html", "w", encoding="utf-8") ofh.write("\n") ofh.write("\n") ofh.write("

Index of family chemical diagrams produced on: %s

\n" % tS) @@ -164,7 +174,9 @@ def testFamilyDepictionHTMLIndex(self): (familyId, _refPrdId, _refCcId, _refCcPath) = fmList[0] imageFileName = familyId + "-members.pdf" if os.access(imageFileName, os.R_OK): - ofh.write('
  • %s with %2d members.
  • \n' % (imageFileName, familyId, len(fmList))) + ofh.write( + '
  • %s with %2d members.
  • \n' % (imageFileName, familyId, len(fmList)) + ) ofh.write("\n") ofh.write("\n") ofh.write("\n") diff --git a/wwpdb/utils/tests_oe_util/OeBirdDepictTests.py b/tests/OeBirdDepictTests.py similarity index 88% rename from wwpdb/utils/tests_oe_util/OeBirdDepictTests.py rename to tests/OeBirdDepictTests.py index cfe92bd..3d12a0d 100644 --- a/wwpdb/utils/tests_oe_util/OeBirdDepictTests.py +++ b/tests/OeBirdDepictTests.py @@ -13,6 +13,7 @@ A collection of tests for the OEDepictAlignUtils class with FAMILY PRD data - """ + __docformat__ = "restructuredtext en" __author__ = "John Westbrook" __email__ = "jwest@rcsb.rutgers.edu" @@ -20,16 +21,14 @@ __version__ = "V0.01" -import sys -import unittest -import traceback -import platform -import time +import builtins import os import os.path - -if sys.version_info[0] < 3: - from io import open as open +import platform +import sys +import time +import traceback +import unittest try: from openeye.oechem import OEFloatArray # noqa: F401 pylint: disable=unused-import @@ -40,6 +39,7 @@ if not skiptests: from mmcif_utils.bird.PdbxBirdIndex import PdbxBirdIndex + from wwpdb.utils.oe_util.build.OeChemCompIoUtils import OeChemCompIoUtils from wwpdb.utils.oe_util.oedepict.OeAlignDepictUtils import OeDepictMCSAlignMulti from wwpdb.utils.oe_util.oedepict.OeDepict import OeDepictMultiPage @@ -64,7 +64,9 @@ def __testBuildBirdIndex(self): self.__lfh.write("\nStarting OeBirdDepictTests __testBuildBirdIndex\n") fD = {} try: - bI = PdbxBirdIndex(indexPath=os.path.join(self.__testoutput, "bird-index.pic"), verbose=self.__verbose, log=self.__lfh) + bI = PdbxBirdIndex( + indexPath=os.path.join(self.__testoutput, "bird-index.pic"), verbose=self.__verbose, log=self.__lfh + ) familyIdL = bI.getFamilyList() for familyId in familyIdL: prdIdList = bI.getPrdIdList(familyId) @@ -118,14 +120,22 @@ def testFamilyDepiction(self): aML = oed.alignOneWithListMulti(imagePath=imageFileName) if len(aML) > 0: - for (rCC, rAt, tCC, tAt) in aML: + for rCC, rAt, tCC, tAt in aML: self.__lfh.write("%5s %-5s %5s %-5s\n" % (rCC, rAt, tCC, tAt)) else: oeU = OeChemCompIoUtils(verbose=self.__verbose, log=self.__lfh) oemList = oeU.getFromPathList([refCcPath], use3D=False) oed = OeDepictMultiPage(verbose=self.__verbose, log=self.__lfh) oed.setMolTitleList([(refPrdId, oemList[0], refPrdId)]) - oed.setDisplayOptions(labelAtomName=False, labelAtomCIPStereo=True, labelAtomIndex=False, labelBondIndex=False, gridRows=3, gridCols=3, bondDisplayWidth=0.5) + oed.setDisplayOptions( + labelAtomName=False, + labelAtomCIPStereo=True, + labelAtomIndex=False, + labelBondIndex=False, + gridRows=3, + gridCols=3, + bondDisplayWidth=0.5, + ) oed.prepare() oed.write(imageFileName) except: # noqa: E722 pylint: disable=bare-except @@ -136,7 +146,7 @@ def testFamilyDepictionHTMLIndex(self): """Test case - aligned family members --""" self.__lfh.write("\nStarting OeBirdDepictTests testFamilyDepictionHTMLIndex\n") tS = time.strftime("%Y %m %d %H:%M:%S", time.localtime()) - ofh = open(os.path.join(self.__testoutput, "index.html"), "w", encoding="utf-8") + ofh = builtins.open(os.path.join(self.__testoutput, "index.html"), "w", encoding="utf-8") ofh.write("\n") ofh.write("\n") ofh.write("

    Index of family chemical diagrams produced on: %s

    \n" % tS) @@ -151,7 +161,9 @@ def testFamilyDepictionHTMLIndex(self): (familyId, _refPrdId, _refCcId, _refCcPath) = fmList[0] imageFileName = familyId + "-members.pdf" if os.access(imageFileName, os.R_OK): - ofh.write('
  • %s with %2d members.
  • \n' % (imageFileName, familyId, len(fmList))) + ofh.write( + '
  • %s with %2d members.
  • \n' % (imageFileName, familyId, len(fmList)) + ) ofh.write("\n") ofh.write("\n") ofh.write("\n") diff --git a/wwpdb/utils/tests_oe_util/OeBuildModelMolTests.py b/tests/OeBuildModelMolTests.py similarity index 93% rename from wwpdb/utils/tests_oe_util/OeBuildModelMolTests.py rename to tests/OeBuildModelMolTests.py index c8571a2..6844210 100644 --- a/wwpdb/utils/tests_oe_util/OeBuildModelMolTests.py +++ b/tests/OeBuildModelMolTests.py @@ -12,6 +12,7 @@ A collection of tests for the OEBuildModelMol and related classes. """ + __docformat__ = "restructuredtext en" __author__ = "John Westbrook" __email__ = "jwest@rcsb.rutgers.edu" @@ -20,8 +21,8 @@ import os import sys -import unittest import traceback +import unittest try: from openeye.oechem import OEFloatArray # noqa: F401 pylint: disable=unused-import @@ -33,8 +34,8 @@ if not skiptests: from wwpdb.utils.oe_util.build.OeBuildModelMol import OeBuildModelMol -from mmcif_utils.chemcomp.PdbxChemCompModelIo import PdbxChemCompModelIo from mmcif_utils.chemcomp.PdbxChemCompModel import PdbxChemCompModelDescriptor +from mmcif_utils.chemcomp.PdbxChemCompModelIo import PdbxChemCompModelIo @unittest.skipIf(skiptests, "Requires oe library") @@ -43,9 +44,8 @@ def setUp(self): self.__lfh = sys.stderr self.__verbose = True HERE = os.path.abspath(os.path.dirname(__file__)) - TOPDIR = os.path.dirname(os.path.dirname(os.path.dirname(HERE))) - mockTopPath = os.path.join(TOPDIR, "wwpdb", "mock-data") - self.__modelFilePath = os.path.join(mockTopPath, "CCD", "MTGL00001.cif") + datadir = os.path.join(HERE, "data") + self.__modelFilePath = os.path.join(datadir, "MTGL00001.cif") self.__modelFilePathList = [self.__modelFilePath] def tearDown(self): @@ -63,13 +63,12 @@ def testBuildFromModel(self): self.__lfh.write("Title = %s\n" % oem.getTitle()) self.__lfh.write("SMILES (canonical) = %s\n" % oem.getCanSMILES()) self.__lfh.write("SMILES (isomeric) = %s\n" % oem.getIsoSMILES()) - # pccm = PdbxChemCompModelIo(verbose=self.__verbose, log=self.__lfh) pccm.setFilePath(self.__modelFilePath) dL = pccm.getDescriptorList() for d in dL: pd = PdbxChemCompModelDescriptor(d, verbose=self.__verbose, log=self.__lfh) - print(pd.getType()) + print(pd.getType()) # noqa: T201 if pd.getType() == "SMILES_CANNONICAL": sm = pd.getDescriptor() if sm == oem.getIsoSMILES(): @@ -98,9 +97,7 @@ def testSerialize3D(self): self.__lfh.write("SMILES (canonical) = %s\n" % oem.getCanSMILES()) self.__lfh.write("SMILES (isomeric) = %s\n" % oem.getIsoSMILES()) oeS = oem.serialize() - # self.__lfh.write("Serialized string length = %d\n" % len(oeS)) - # oemD = OeBuildModelMol(verbose=self.__verbose, log=self.__lfh) ok = oemD.deserialize(oeS) self.__lfh.write("Deserialized status = %s\n" % ok) diff --git a/wwpdb/utils/tests_oe_util/OeBuildMolTests.py b/tests/OeBuildMolTests.py similarity index 88% rename from wwpdb/utils/tests_oe_util/OeBuildMolTests.py rename to tests/OeBuildMolTests.py index a729584..7aae5fb 100644 --- a/wwpdb/utils/tests_oe_util/OeBuildMolTests.py +++ b/tests/OeBuildMolTests.py @@ -16,17 +16,18 @@ A collection of tests for the OEBuildMol and related classes. """ + __docformat__ = "restructuredtext en" __author__ = "John Westbrook" __email__ = "jwest@rcsb.rutgers.edu" __license__ = "Creative Commons Attribution 3.0 Unported" __version__ = "V0.01" +import os +import platform import sys -import unittest import traceback -import platform -import os +import unittest try: from openeye.oechem import OEFloatArray # noqa: F401 pylint: disable=unused-import @@ -36,9 +37,10 @@ skiptests = True if not skiptests: - from wwpdb.utils.oe_util.build.OeBuildMol import OeBuildMol from mmcif_utils.persist.PdbxPyIoAdapter import PdbxPyIoAdapter as PdbxIoAdapter + from wwpdb.utils.oe_util.build.OeBuildMol import OeBuildMol + @unittest.skipIf(skiptests, "Cannot import openeye.oechem for tests") class OeBuildMolTests(unittest.TestCase): @@ -51,7 +53,11 @@ def setUp(self): os.makedirs(self.__testoutput) self.__datadir = os.path.join(self.__here, "data") self.__sdfFilePath = os.path.join(self.__datadir, "ATP.sdf") - self.__pathList = [os.path.join(self.__datadir, "ATP.cif"), os.path.join(self.__datadir, "GTP.cif"), os.path.join(self.__datadir, "ARG.cif")] + self.__pathList = [ + os.path.join(self.__datadir, "ATP.cif"), + os.path.join(self.__datadir, "GTP.cif"), + os.path.join(self.__datadir, "ARG.cif"), + ] def tearDown(self): pass @@ -82,7 +88,11 @@ def testBuildFromFiles(self): self.assertTrue(ok) # myReader.write(pdbxFilePath="TMP.cif") for container in myReader.getContainerList(): - oem.set(container.getName(), dcChemCompAtom=container.getObj("chem_comp_atom"), dcChemCompBond=container.getObj("chem_comp_bond")) + oem.set( + container.getName(), + dcChemCompAtom=container.getObj("chem_comp_atom"), + dcChemCompBond=container.getObj("chem_comp_bond"), + ) oem.build3D(coordType="model") self.__lfh.write("Title = %s\n" % oem.getTitle()) self.__lfh.write("SMILES (canonical) = %s\n" % oem.getCanSMILES()) @@ -105,15 +115,17 @@ def testSerialize2D(self): ok = myReader.read(pdbxFilePath=pth) myReader.write(pdbxFilePath=os.path.join(self.__testoutput, "TMP.cif")) for container in myReader.getContainerList(): - oem.set(container.getName(), dcChemCompAtom=container.getObj("chem_comp_atom"), dcChemCompBond=container.getObj("chem_comp_bond")) + oem.set( + container.getName(), + dcChemCompAtom=container.getObj("chem_comp_atom"), + dcChemCompBond=container.getObj("chem_comp_bond"), + ) oem.build2D() self.__lfh.write("Title = %s\n" % oem.getTitle()) self.__lfh.write("SMILES (canonical) = %s\n" % oem.getCanSMILES()) self.__lfh.write("SMILES (isomeric) = %s\n" % oem.getIsoSMILES()) oeS = oem.serialize() - # self.__lfh.write("Serialized string length = %d\n" % len(oeS)) - # oemD = OeBuildMol(verbose=self.__verbose, log=self.__lfh) ok = oemD.deserialize(oeS) self.__lfh.write("Deserialized status = %s\n" % ok) @@ -137,15 +149,17 @@ def testSerialize3D(self): ok = myReader.read(pdbxFilePath=pth) myReader.write(pdbxFilePath=os.path.join(self.__testoutput, "TMP.cif")) for container in myReader.getContainerList(): - oem.set(container.getName(), dcChemCompAtom=container.getObj("chem_comp_atom"), dcChemCompBond=container.getObj("chem_comp_bond")) + oem.set( + container.getName(), + dcChemCompAtom=container.getObj("chem_comp_atom"), + dcChemCompBond=container.getObj("chem_comp_bond"), + ) oem.build3D(coordType="model") self.__lfh.write("Title = %s\n" % oem.getTitle()) self.__lfh.write("SMILES (canonical) = %s\n" % oem.getCanSMILES()) self.__lfh.write("SMILES (isomeric) = %s\n" % oem.getIsoSMILES()) oeS = oem.serialize() - # self.__lfh.write("Serialized string length = %d\n" % len(oeS)) - # oemD = OeBuildMol(verbose=self.__verbose, log=self.__lfh) ok = oemD.deserialize(oeS) self.__lfh.write("Deserialized status = %s\n" % ok) diff --git a/wwpdb/utils/tests_oe_util/OeChemCompIoUtilsTests.py b/tests/OeChemCompIoUtilsTests.py similarity index 94% rename from wwpdb/utils/tests_oe_util/OeChemCompIoUtilsTests.py rename to tests/OeChemCompIoUtilsTests.py index 8856e2b..0d82e53 100644 --- a/wwpdb/utils/tests_oe_util/OeChemCompIoUtilsTests.py +++ b/tests/OeChemCompIoUtilsTests.py @@ -13,17 +13,18 @@ Test cases for persistent storage of serialized OE molecule objects. """ + __docformat__ = "restructuredtext en" __author__ = "John Westbrook" __email__ = "jwest@rcsb.rutgers.edu" __license__ = "Creative Commons Attribution 3.0 Unported" __version__ = "V0.01" +import os +import platform import sys -import unittest import traceback -import platform -import os +import unittest try: from openeye.oechem import OEFloatArray # noqa: F401 pylint: disable=unused-import @@ -48,7 +49,11 @@ def setUp(self): self.__datadir = os.path.join(self.__here, "data") self.__topCachePath = os.path.join(self.__here, "ligand-dict-v3") - self.__pathList = [os.path.join(self.__datadir, "ATP.cif"), os.path.join(self.__datadir, "GTP.cif"), os.path.join(self.__datadir, "ARG.cif")] + self.__pathList = [ + os.path.join(self.__datadir, "ATP.cif"), + os.path.join(self.__datadir, "GTP.cif"), + os.path.join(self.__datadir, "ARG.cif"), + ] self.__idList = ["MSE", "GTP", "TRP", "XXATP"] def tearDown(self): @@ -94,6 +99,5 @@ def suite1(): if __name__ == "__main__": - # mySuite = suite1() unittest.TextTestRunner(verbosity=2).run(mySuite) diff --git a/wwpdb/utils/tests_oe_util/OeDepictTests.py b/tests/OeDepictTests.py similarity index 84% rename from wwpdb/utils/tests_oe_util/OeDepictTests.py rename to tests/OeDepictTests.py index 15e738f..6f2dbee 100644 --- a/wwpdb/utils/tests_oe_util/OeDepictTests.py +++ b/tests/OeDepictTests.py @@ -14,6 +14,7 @@ A collection of tests for the OEDepict and related classes. """ + __docformat__ = "restructuredtext en" __author__ = "John Westbrook" __email__ = "jwest@rcsb.rutgers.edu" @@ -21,13 +22,13 @@ __version__ = "V0.01" -import sys -import unittest -import platform -import traceback +import fnmatch import os import os.path -import fnmatch +import platform +import sys +import traceback +import unittest try: from openeye.oechem import OEFloatArray # noqa: F401 pylint: disable=unused-import @@ -37,9 +38,9 @@ skiptests = True if not skiptests: - from wwpdb.utils.oe_util.oedepict.OeDepict import OeDepict, OeDepictMultiPage - from wwpdb.utils.oe_util.build.OeChemCompIoUtils import OeChemCompIoUtils from wwpdb.utils.oe_util.build.OeBuildMol import OeBuildMol + from wwpdb.utils.oe_util.build.OeChemCompIoUtils import OeChemCompIoUtils + from wwpdb.utils.oe_util.oedepict.OeDepict import OeDepict, OeDepictMultiPage @unittest.skipIf(skiptests, "Cannot import openeye.oechem for tests") @@ -129,10 +130,9 @@ def __getPathList(self, topPath, pattern="*", excludeDirs=None, recurse=True): if excludeDirs is None: excludeDirs = [] pathList = [] - # try: names = os.listdir(topPath) - except os.error: + except OSError: return pathList # expand pattern @@ -150,7 +150,9 @@ def __getPathList(self, topPath, pattern="*", excludeDirs=None, recurse=True): if recurse: # recursively scan directories if os.path.isdir(fullname) and not os.path.islink(fullname) and (name not in excludeDirs): - pathList.extend(self.__getPathList(topPath=fullname, pattern=pattern, excludeDirs=excludeDirs, recurse=recurse)) + pathList.extend( + self.__getPathList(topPath=fullname, pattern=pattern, excludeDirs=excludeDirs, recurse=recurse) + ) return pathList @@ -164,14 +166,20 @@ def testDepictCCIdList(self): oeMolTitleList = list(oeMolTitleZip) if self.__verbose: self.__lfh.write("molTitleList length is %d\n" % len(oeMolTitleList)) - # for ccId, mol, title in oeMolTitleList: # dirPath, fName = os.path.split(title) imagePath = os.path.join(self.__testoutput, ccId + ".svg") oed = OeDepict(verbose=self.__verbose, log=self.__lfh) - title = "" + title = "" # noqa: PLC0414,PLW2901 oed.setMolTitleList([(ccId, mol, title)]) - oed.setDisplayOptions(labelAtomName=False, labelAtomCIPStereo=True, labelAtomIndex=False, labelBondIndex=False, cellBorders=False, bondDisplayWidth=0.5) + oed.setDisplayOptions( + labelAtomName=False, + labelAtomCIPStereo=True, + labelAtomIndex=False, + labelBondIndex=False, + cellBorders=False, + bondDisplayWidth=0.5, + ) oed.setGridOptions(rows=1, cols=1) oed.prepare() oed.write(imagePath) @@ -183,18 +191,25 @@ def testDepictPrdCCPathList(self): """Test case - get, read, build OE molecule, and depict the molecule.""" self.__lfh.write("\nStarting OeDepictTests testDepictPrdCCPathList\n") try: - ccPathList = self.__getPathList(topPath=self.__pathPrdChemCompCVS, pattern="*.cif", excludeDirs=["CVS", "REMOVED", "FULL"]) + ccPathList = self.__getPathList( + topPath=self.__pathPrdChemCompCVS, pattern="*.cif", excludeDirs=["CVS", "REMOVED", "FULL"] + ) oeMolTitleZip = self.__testMakeFromFiles(pathList=ccPathList) oeMolTitleList = list(oeMolTitleZip) if self.__verbose: self.__lfh.write("molTitleList length is %d\n" % len(oeMolTitleList)) - # for ccId, mol, title in oeMolTitleList: _dirPath, fName = os.path.split(title) imagePath = os.path.join(self.__testoutput, fName[:-4] + ".svg") oed = OeDepict(verbose=self.__verbose, log=self.__lfh) oed.setMolTitleList([(ccId, mol, title)]) - oed.setDisplayOptions(labelAtomName=False, labelAtomCIPStereo=True, labelAtomIndex=False, labelBondIndex=False, bondDisplayWidth=0.5) + oed.setDisplayOptions( + labelAtomName=False, + labelAtomCIPStereo=True, + labelAtomIndex=False, + labelBondIndex=False, + bondDisplayWidth=0.5, + ) oed.setGridOptions(rows=1, cols=1) oed.prepare() oed.write(imagePath) @@ -209,7 +224,15 @@ def testDepictIdList(self): oeMolTitleList = self.__testMakeFromIds(self.__idList) oed = OeDepict(verbose=self.__verbose, log=self.__lfh) oed.setMolTitleList(oeMolTitleList) - oed.setDisplayOptions(imageX=1000, imageY=1000, labelAtomName=True, labelAtomCIPStereo=True, labelAtomIndex=False, labelBondIndex=False, bondDisplayWidth=0.5) + oed.setDisplayOptions( + imageX=1000, + imageY=1000, + labelAtomName=True, + labelAtomCIPStereo=True, + labelAtomIndex=False, + labelBondIndex=False, + bondDisplayWidth=0.5, + ) oed.setGridOptions(rows=2, cols=2) oed.prepare() oed.write(os.path.join(self.__testoutput, "myIdListtest.png")) @@ -224,7 +247,15 @@ def testDepictPathList(self): oeMolTitleList = self.__testMakeFromFiles(self.__pathList) oed = OeDepict(verbose=self.__verbose, log=self.__lfh) oed.setMolTitleList(oeMolTitleList) - oed.setDisplayOptions(imageX=1500, imageY=1500, labelAtomName=True, labelAtomCIPStereo=True, labelAtomIndex=False, labelBondIndex=False, bondDisplayWidth=0.5) + oed.setDisplayOptions( + imageX=1500, + imageY=1500, + labelAtomName=True, + labelAtomCIPStereo=True, + labelAtomIndex=False, + labelBondIndex=False, + bondDisplayWidth=0.5, + ) oed.setGridOptions(rows=3, cols=3) oed.prepare() oed.write(os.path.join(self.__testoutput, "pathListtest.png")) @@ -252,7 +283,14 @@ def testDepictPathListMulti(self): oeMolTitleList = self.__testMakeFromFiles(self.__pathList) oed = OeDepictMultiPage(verbose=self.__verbose, log=self.__lfh) oed.setMolTitleList(oeMolTitleList) - oed.setDisplayOptions(pageOrientation="Portrait", labelAtomName=True, labelAtomCIPStereo=True, labelAtomIndex=False, labelBondIndex=False, bondDisplayWidth=0.5) + oed.setDisplayOptions( + pageOrientation="Portrait", + labelAtomName=True, + labelAtomCIPStereo=True, + labelAtomIndex=False, + labelBondIndex=False, + bondDisplayWidth=0.5, + ) oed.setGridOptions(rows=2, cols=1) oed.prepare() oed.write(os.path.join(self.__testoutput, "multiPathListtest.pdf")) @@ -267,7 +305,13 @@ def testDepictWithErrorsMulti(self): oeMolTitleList = self.__testMakeFromFiles(self.__pathList2) oed = OeDepictMultiPage(verbose=self.__verbose, log=self.__lfh) oed.setMolTitleList(oeMolTitleList) - oed.setDisplayOptions(labelAtomName=True, labelAtomCIPStereo=True, labelAtomIndex=False, labelBondIndex=False, bondDisplayWidth=0.5) + oed.setDisplayOptions( + labelAtomName=True, + labelAtomCIPStereo=True, + labelAtomIndex=False, + labelBondIndex=False, + bondDisplayWidth=0.5, + ) oed.prepare() oed.write(os.path.join(self.__testoutput, "myErrortest.pdf")) except: # noqa: E722 pylint: disable=bare-except @@ -281,11 +325,16 @@ def testDepictOneSDF(self): oem = OeBuildMol(verbose=self.__verbose, log=self.__lfh) if oem.importFile(self.__sdfFilePath, type="3D"): self.__lfh.write("Title = %s\n" % oem.getTitle()) - # imagePath = os.path.join(self.__testoutput, "ATP.svg") oed = OeDepict(verbose=self.__verbose, log=self.__lfh) oed.setMolTitleList([("ATP", oem, "Title for ATP")]) - oed.setDisplayOptions(labelAtomName=True, labelAtomCIPStereo=True, labelAtomIndex=False, labelBondIndex=False, bondDisplayWidth=0.5) + oed.setDisplayOptions( + labelAtomName=True, + labelAtomCIPStereo=True, + labelAtomIndex=False, + labelBondIndex=False, + bondDisplayWidth=0.5, + ) oed.setGridOptions(rows=1, cols=1) oed.prepare() oed.write(imagePath) @@ -304,7 +353,13 @@ def testDepictSMILES(self): oed = OeDepict(verbose=self.__verbose, log=self.__lfh) oed.setMolTitleList([("benzene", oem, "Title for benzene")]) - oed.setDisplayOptions(labelAtomName=False, labelAtomCIPStereo=True, labelAtomIndex=False, labelBondIndex=False, bondDisplayWidth=1.0) + oed.setDisplayOptions( + labelAtomName=False, + labelAtomCIPStereo=True, + labelAtomIndex=False, + labelBondIndex=False, + bondDisplayWidth=1.0, + ) oed.setGridOptions(rows=1, cols=1) oed.prepare() oed.write(imagePath) @@ -356,10 +411,8 @@ def suiteDepictSDF(): # unittest.main() mySuite1 = suiteDepictMulti() unittest.TextTestRunner(verbosity=2).run(mySuite1) - # mySuite2 = suiteDepict() unittest.TextTestRunner(verbosity=2).run(mySuite2) - # mySuite3 = suiteDepictPrd() unittest.TextTestRunner(verbosity=2).run(mySuite3) diff --git a/wwpdb/utils/tests_oe_util/OeDescriptorUtilsTests.py b/tests/OeDescriptorUtilsTests.py similarity index 93% rename from wwpdb/utils/tests_oe_util/OeDescriptorUtilsTests.py rename to tests/OeDescriptorUtilsTests.py index 7100bdd..28fc395 100644 --- a/wwpdb/utils/tests_oe_util/OeDescriptorUtilsTests.py +++ b/tests/OeDescriptorUtilsTests.py @@ -8,7 +8,7 @@ # ## """ - Tests for standardizing descriptors - +Tests for standardizing descriptors - """ @@ -40,7 +40,6 @@ @unittest.skipIf(skiptests, "Requires openeye library") class OeDescriptorUtilsTests(unittest.TestCase): def setUp(self): - # self.__gtpSmilesList = [ "O=P(O)(O)OP(=O)(O)OP(=O)(O)OCC3OC(n2cnc1c2N=C(N)NC1=O)C(O)C3O", "NC1=Nc2n(cnc2C(=O)N1)[C@@H]3O[C@H](CO[P@@](O)(=O)O[P@@](O)(=O)O[P](O)(O)=O)[C@@H](O)[C@H]3O", @@ -70,9 +69,10 @@ def testSmilesConvert(self): except Exception as e: logger.exception("Error '%s' occured. Arguments %s.", str(e), e.args) self.fail() - # endTime = time.time() - logger.info("Completed at %s (%.2f seconds)", time.strftime("%Y %m %d %H:%M:%S", time.localtime()), endTime - startTime) + logger.info( + "Completed at %s (%.2f seconds)", time.strftime("%Y %m %d %H:%M:%S", time.localtime()), endTime - startTime + ) def testSmilesConversionSuite(): diff --git a/wwpdb/utils/tests_oe_util/OeMCSSTests.py b/tests/OeMCSSTests.py similarity index 93% rename from wwpdb/utils/tests_oe_util/OeMCSSTests.py rename to tests/OeMCSSTests.py index b70a155..a5d4b3d 100644 --- a/wwpdb/utils/tests_oe_util/OeMCSSTests.py +++ b/tests/OeMCSSTests.py @@ -15,6 +15,7 @@ MCSS comparison and depiction. """ + __docformat__ = "restructuredtext en" __author__ = "John Westbrook" __email__ = "jwest@rcsb.rutgers.edu" @@ -22,14 +23,15 @@ __version__ = "V0.01" +import builtins +import os +import platform import sys -import unittest import traceback -import platform -import os +import unittest -if sys.version_info[0] < 3: - from io import open as open +# if sys.version_info[0] < 3: +# from io import open as open try: from openeye.oechem import OEFloatArray # noqa: F401 pylint: disable=unused-import @@ -47,7 +49,6 @@ class OeAlignDepictTests(unittest.TestCase): def setUp(self): self.__lfh = sys.stderr self.__verbose = True - # self.__here = os.path.abspath(os.path.dirname(__file__)) self.__examples = os.path.join(self.__here, "examples") self.__testoutput = os.path.join(self.__here, "test-output", platform.python_version()) @@ -57,9 +58,7 @@ def setUp(self): # Chemical component repository path - self.__topCachePath = os.path.join(self.__here, "ligand-dict-v3") self.__rnaPairFile = os.path.join(self.__examples, "rna-linking-components.txt") - # self.__refId = "C" - # self.__idList = ["cg1", "atp", "gtp", "A", "C", "G", "DG"] self.__pairIdList = [("c", "cg1"), ("c", "atp"), ("c", "gtp"), ("c", "A"), ("c", "C"), ("c", "G"), ("c", "DG")] @@ -68,7 +67,7 @@ def tearDown(self): def __readPairList(self, fn="./examples/rna-linking-components.txt"): pairList = [] - ifh = open(fn, "r", encoding="utf-8") + ifh = builtins.open(fn, encoding="utf-8") for line in ifh: fields = line.split() pairList.append((fields[1], fields[0])) @@ -87,7 +86,7 @@ def testMCSAlignPairDepict(self): fName = os.path.join(self.__testoutput, "ref-" + self.__refId + "-trg-" + fitId + ".png") aML = oed.alignPair(imagePath=fName) if len(aML) > 0: - for (rCC, rAt, tCC, tAt) in aML: + for rCC, rAt, tCC, tAt in aML: self.__lfh.write("%5s %-5s %5s %-5s\n" % (rCC, rAt, tCC, tAt)) except: # noqa: E722 pylint: disable=bare-except traceback.print_exc(file=self.__lfh) @@ -103,7 +102,7 @@ def testMCSAlignListDepict(self): imageFile = os.path.join(self.__testoutput, "list-example-mcs-alignment.pdf") aML = oed.alignPairList(imagePath=imageFile) if len(aML) > 0: - for (rCC, rAt, tCC, tAt) in aML: + for rCC, rAt, tCC, tAt in aML: self.__lfh.write("%5s %-5s %5s %-5s\n" % (rCC, rAt, tCC, tAt)) except: # noqa: E722 pylint: disable=bare-except @@ -119,7 +118,7 @@ def testMCSAlignPairListDepict(self): imageFile = os.path.join(self.__testoutput, "pair-list-example-mcs-alignment.pdf") aML = oed.alignPairList(imagePath=imageFile) if len(aML) > 0: - for (rCC, rAt, tCC, tAt) in aML: + for rCC, rAt, tCC, tAt in aML: self.__lfh.write("%5s %-5s %5s %-5s\n" % (rCC, rAt, tCC, tAt)) except: # noqa: E722 pylint: disable=bare-except @@ -136,7 +135,7 @@ def testMCSAlignRnaPairListDepict(self): imageFile = os.path.join(self.__testoutput, "rna-modified-pair-alignment.pdf") aML = oed.alignPairList(imagePath=imageFile) if len(aML) > 0: - for (rCC, rAt, tCC, tAt) in aML: + for rCC, rAt, tCC, tAt in aML: self.__lfh.write("%5s %-5s %5s %-5s\n" % (rCC, rAt, tCC, tAt)) except: # noqa: E722 pylint: disable=bare-except @@ -173,7 +172,6 @@ def testSdfMCSAlignAtomMap(self): oed = OeDepictMCSAlign(verbose=self.__verbose, log=self.__lfh) # oed.setSearchType(sType='exact') oed.setSearchType(sType="exact") - # oed.setRefPath(refPath, type="SDF") # oed.setFitId(fitId,cachePath=self.__topCachePath) oed.setFitPath(fitPath, title="ATP") @@ -194,12 +192,16 @@ def testMCSRelaxAlignPairDepict(self): try: oed = OeDepictMCSAlign(verbose=self.__verbose, log=self.__lfh) oed.setSearchType(sType="relaxed") - oed.setRefPath(ccPath=os.path.join(self.__examples, "PRDCC_000225.cif"), title="PRD_000225", suppressHydrogens=False) - oed.setFitPath(ccPath=os.path.join(self.__examples, "L_LDI_990_.comp.cif"), title="L_LDI_990", suppressHydrogens=False) + oed.setRefPath( + ccPath=os.path.join(self.__examples, "PRDCC_000225.cif"), title="PRD_000225", suppressHydrogens=False + ) + oed.setFitPath( + ccPath=os.path.join(self.__examples, "L_LDI_990_.comp.cif"), title="L_LDI_990", suppressHydrogens=False + ) fName = os.path.join(self.__testoutput, "relaxed-fit.png") aML = oed.alignPair(imagePath=fName) if len(aML) > 0: - for (rCC, rAt, tCC, tAt) in aML: + for rCC, rAt, tCC, tAt in aML: self.__lfh.write("%5s %-5s %5s %-5s\n" % (rCC, rAt, tCC, tAt)) except: # noqa: E722 pylint: disable=bare-except traceback.print_exc(file=self.__lfh) @@ -237,9 +239,7 @@ def suite(): # mySuite1 = suiteAlignPair() unittest.TextTestRunner(verbosity=2).run(mySuite1) - # mySuite1 = suiteAlignPairRelax() unittest.TextTestRunner(verbosity=2).run(mySuite1) - # mySuite1 = suiteAlignExtPairRelax() unittest.TextTestRunner(verbosity=2).run(mySuite1) diff --git a/wwpdb/utils/tests_oe_util/OePersistFullDictTests.py b/tests/OePersistFullDictTests.py similarity index 83% rename from wwpdb/utils/tests_oe_util/OePersistFullDictTests.py rename to tests/OePersistFullDictTests.py index d16876c..bec70fc 100644 --- a/wwpdb/utils/tests_oe_util/OePersistFullDictTests.py +++ b/tests/OePersistFullDictTests.py @@ -16,20 +16,21 @@ for the the full chemical component dictionary + PRD chemical components """ + __docformat__ = "restructuredtext en" __author__ = "John Westbrook" __email__ = "jwest@rcsb.rutgers.edu" __license__ = "Creative Commons Attribution 3.0 Unported" __version__ = "V0.01" -import sys -import unittest -import platform -import traceback import fnmatch -import time import os import os.path +import platform +import sys +import time +import traceback +import unittest try: from openeye.oechem import OEFloatArray # noqa: F401 pylint: disable=unused-import @@ -39,13 +40,12 @@ skiptests = True if not skiptests: - from wwpdb.utils.cc_dict_util.persist.PdbxChemCompDictUtil import PdbxChemCompDictUtil - from wwpdb.utils.cc_dict_util.persist.PdbxChemCompDictIndex import PdbxChemCompDictIndex + from mmcif_utils.persist.PdbxPersist import PdbxPersist - from wwpdb.utils.oe_util.build.OePersist import OePersist + from wwpdb.utils.cc_dict_util.persist.PdbxChemCompDictIndex import PdbxChemCompDictIndex + from wwpdb.utils.cc_dict_util.persist.PdbxChemCompDictUtil import PdbxChemCompDictUtil from wwpdb.utils.oe_util.build.OeBuildMol import OeBuildMol - - from mmcif_utils.persist.PdbxPersist import PdbxPersist + from wwpdb.utils.oe_util.build.OePersist import OePersist import logging @@ -130,10 +130,9 @@ def getPathList(self, topPath, pattern="*", excludeDirs=None, recurse=True): pathList = [] if excludeDirs is None: excludeDirs = [] - # try: names = os.listdir(topPath) - except os.error: + except OSError: return pathList # expand pattern @@ -151,7 +150,9 @@ def getPathList(self, topPath, pattern="*", excludeDirs=None, recurse=True): if recurse: # recursively scan directories if os.path.isdir(fullname) and not os.path.islink(fullname) and (name not in excludeDirs): - pathList.extend(self.getPathList(topPath=fullname, pattern=pattern, excludeDirs=excludeDirs, recurse=recurse)) + pathList.extend( + self.getPathList(topPath=fullname, pattern=pattern, excludeDirs=excludeDirs, recurse=recurse) + ) return pathList @@ -161,9 +162,14 @@ def testCreateChemCompStore(self): Extract the path list by searching the file system of the CVS repository """ startTime = time.time() - self.__lfh.write("\nStarting OePersistFullDictTests testCreateChemCompStore at %s\n" % (time.strftime("%Y %m %d %H:%M:%S", time.localtime()))) + self.__lfh.write( + "\nStarting OePersistFullDictTests testCreateChemCompStore at %s\n" + % (time.strftime("%Y %m %d %H:%M:%S", time.localtime())) + ) try: - ccPathList = self.getPathList(topPath=self.__pathChemCompCVS, pattern="*.cif", excludeDirs=["CVS", "REMOVED", "FULL"]) + ccPathList = self.getPathList( + topPath=self.__pathChemCompCVS, pattern="*.cif", excludeDirs=["CVS", "REMOVED", "FULL"] + ) if self.__verbose: self.__lfh.write("Pathlist length is %d\n" % len(ccPathList)) dUtil = PdbxChemCompDictUtil(verbose=self.__verbose, log=self.__lfh) @@ -175,7 +181,8 @@ def testCreateChemCompStore(self): endTime = time.time() self.__lfh.write( - "\nCompleted OePersistFullDictTests testCreateChemCompStore at %s (%d seconds)\n" % (time.strftime("%Y %m %d %H:%M:%S", time.localtime()), endTime - startTime) + "\nCompleted OePersistFullDictTests testCreateChemCompStore at %s (%d seconds)\n" + % (time.strftime("%Y %m %d %H:%M:%S", time.localtime()), endTime - startTime) ) def testUpdateChemCompStoreWithPrd(self): @@ -184,28 +191,35 @@ def testUpdateChemCompStoreWithPrd(self): Extract the path list from the file system of the PRD CVS repository. """ startTime = time.time() - self.__lfh.write("\nStarting OePersistFullDictTests testUpdateChemCompStoreWithPrd at %s\n" % (time.strftime("%Y %m %d %H:%M:%S", time.localtime()))) + self.__lfh.write( + "\nStarting OePersistFullDictTests testUpdateChemCompStoreWithPrd at %s\n" + % (time.strftime("%Y %m %d %H:%M:%S", time.localtime())) + ) try: - ccPathList = self.getPathList(topPath=self.__pathPrdChemCompCVS, pattern="*.cif", excludeDirs=["CVS", "REMOVED", "FULL"]) + ccPathList = self.getPathList( + topPath=self.__pathPrdChemCompCVS, pattern="*.cif", excludeDirs=["CVS", "REMOVED", "FULL"] + ) if self.__verbose: self.__lfh.write("PRDCC pathlist length is %d\n" % len(ccPathList)) - # dUtil = PdbxChemCompDictUtil(verbose=self.__verbose, log=self.__lfh) dUtil.updateStoreByFile(pathList=ccPathList, storePath=self.__persistStorePathCC) - # except: # noqa: E722 pylint: disable=bare-except traceback.print_exc(file=self.__lfh) self.fail() endTime = time.time() self.__lfh.write( - "\nCompleted OePersistFullDictTests testUpdateChemCompStoreWithPrd at %s (%d seconds)\n" % (time.strftime("%Y %m %d %H:%M:%S", time.localtime()), endTime - startTime) + "\nCompleted OePersistFullDictTests testUpdateChemCompStoreWithPrd at %s (%d seconds)\n" + % (time.strftime("%Y %m %d %H:%M:%S", time.localtime()), endTime - startTime) ) def testCreateChemCompIndex(self): """Test case - create search index from chemical component persistent store""" startTime = time.time() - self.__lfh.write("\nStarting OePersistFullDictTests testCreateChemCompIndex at %s\n" % (time.strftime("%Y %m %d %H:%M:%S", time.localtime()))) + self.__lfh.write( + "\nStarting OePersistFullDictTests testCreateChemCompIndex at %s\n" + % (time.strftime("%Y %m %d %H:%M:%S", time.localtime())) + ) try: if not os.path.exists(self.__persistStorePathCC): self.testCreateChemCompStore() @@ -218,7 +232,8 @@ def testCreateChemCompIndex(self): endTime = time.time() self.__lfh.write( - "\nCompleted OePersistFullDictTests testCreateChemCompIndex at %s (%d seconds)\n" % (time.strftime("%Y %m %d %H:%M:%S", time.localtime()), endTime - startTime) + "\nCompleted OePersistFullDictTests testCreateChemCompIndex at %s (%d seconds)\n" + % (time.strftime("%Y %m %d %H:%M:%S", time.localtime()), endTime - startTime) ) def testCreateStoreOE(self): @@ -226,7 +241,10 @@ def testCreateStoreOE(self): of chemical component defintions. """ startTime = time.time() - self.__lfh.write("\nStarting OePersistFullDictTests testCreateStoreOE at %s\n" % (time.strftime("%Y %m %d %H:%M:%S", time.localtime()))) + self.__lfh.write( + "\nStarting OePersistFullDictTests testCreateStoreOE at %s\n" + % (time.strftime("%Y %m %d %H:%M:%S", time.localtime())) + ) try: myPersist = PdbxPersist(self.__verbose, self.__lfh) indexD = myPersist.getIndex(dbFileName=self.__persistStorePathCC) # noqa: F841 pylint: disable=unused-variable @@ -240,7 +258,6 @@ def testCreateStoreOE(self): ccBnd = myPersist.fetchObject(containerName=ccId, objectName="chem_comp_bond") if ccAt is None or ccBnd is None: continue - # oem.set(ccId, dcChemCompAtom=ccAt, dcChemCompBond=ccBnd) oem.build3D() if self.__debug: @@ -253,12 +270,10 @@ def testCreateStoreOE(self): molList.append(molD) myPersist.close() - # oeP = OePersist(self.__verbose, self.__lfh) oeP.setMoleculeList(moleculeList=molList) oeP.store(dbFileName=self.__storePath) mL = oeP.getIndex(dbFileName=self.__storePath) - # if self.__debug: self.__lfh.write("OePersistTests(testCreateStore) molecule list %r\n" % mL) @@ -267,17 +282,22 @@ def testCreateStoreOE(self): self.fail() endTime = time.time() - self.__lfh.write("\nCompleted OePersistFullDictTests testCreateStoreOE at %s (%d seconds)\n" % (time.strftime("%Y %m %d %H:%M:%S", time.localtime()), endTime - startTime)) + self.__lfh.write( + "\nCompleted OePersistFullDictTests testCreateStoreOE at %s (%d seconds)\n" + % (time.strftime("%Y %m %d %H:%M:%S", time.localtime()), endTime - startTime) + ) def testFetchAll(self): """Test case - fetch all of the molecules in an 'open' persistent store""" startTime = time.time() - self.__lfh.write("\nStarting OePersistFullDictTests testFetchAll at %s\n" % (time.strftime("%Y %m %d %H:%M:%S", time.localtime()))) + self.__lfh.write( + "\nStarting OePersistFullDictTests testFetchAll at %s\n" + % (time.strftime("%Y %m %d %H:%M:%S", time.localtime())) + ) try: myPersist = OePersist(self.__verbose, self.__lfh) myPersist.open(dbFileName=self.__storePath) moleculeNameList = myPersist.getStoreMoleculeIndex() - # oem = OeBuildMol(verbose=self.__verbose, log=self.__lfh) for ccId in moleculeNameList: molD = myPersist.fetchMolecule(moleculeName=ccId) @@ -297,18 +317,23 @@ def testFetchAll(self): self.fail() endTime = time.time() - self.__lfh.write("\nCompleted OePersistFullDictTests testFetchAll at %s (%d seconds)\n" % (time.strftime("%Y %m %d %H:%M:%S", time.localtime()), endTime - startTime)) + self.__lfh.write( + "\nCompleted OePersistFullDictTests testFetchAll at %s (%d seconds)\n" + % (time.strftime("%Y %m %d %H:%M:%S", time.localtime()), endTime - startTime) + ) def testFetchOne(self): """Test case - fetch all of the molecules in the persistent store one by one. Each fetch reopens the store. """ startTime = time.time() - self.__lfh.write("\nStarting OePersistFullDictTests testFetchOne at %s\n" % (time.strftime("%Y %m %d %H:%M:%S", time.localtime()))) + self.__lfh.write( + "\nStarting OePersistFullDictTests testFetchOne at %s\n" + % (time.strftime("%Y %m %d %H:%M:%S", time.localtime())) + ) try: myPersist = OePersist(self.__verbose, self.__lfh) moleculeNameList = myPersist.getIndex(dbFileName=self.__storePath) - # oem = OeBuildMol(verbose=self.__verbose, log=self.__lfh) for ccId in moleculeNameList: molD = myPersist.fetchOneMolecule(dbFileName=self.__storePath, moleculeName=ccId) @@ -327,13 +352,16 @@ def testFetchOne(self): self.fail() endTime = time.time() - self.__lfh.write("\nCompleted OePersistFullDictTests testFetchOne at %s (%d seconds)\n" % (time.strftime("%Y %m %d %H:%M:%S", time.localtime()), endTime - startTime)) + self.__lfh.write( + "\nCompleted OePersistFullDictTests testFetchOne at %s (%d seconds)\n" + % (time.strftime("%Y %m %d %H:%M:%S", time.localtime()), endTime - startTime) + ) def suiteCreateStoreCC(): suiteSelect = unittest.TestSuite() suiteSelect.addTest(OePersistFullDictTests("testCreateChemCompStore")) -# suiteSelect.addTest(OePersistFullDictTests("testUpdateChemCompStoreWithPrd")) + # suiteSelect.addTest(OePersistFullDictTests("testUpdateChemCompStoreWithPrd")) return suiteSelect @@ -362,7 +390,6 @@ def suiteSearchStoreOE(): if __name__ == "__main__": here = os.path.abspath(os.path.dirname(__file__)) testoutput = os.path.join(here, "test-output", platform.python_version()) - # if not os.access(os.path.join(testoutput, "chemcomp-store.db"), os.F_OK): mySuite = suiteCreateStoreCC() unittest.TextTestRunner(verbosity=2).run(mySuite) diff --git a/wwpdb/utils/tests_oe_util/OePersistTests.py b/tests/OePersistTests.py similarity index 83% rename from wwpdb/utils/tests_oe_util/OePersistTests.py rename to tests/OePersistTests.py index 7944576..6a98187 100644 --- a/wwpdb/utils/tests_oe_util/OePersistTests.py +++ b/tests/OePersistTests.py @@ -14,18 +14,19 @@ Test cases for persistent storage of serialized OE molecule objects. """ + __docformat__ = "restructuredtext en" __author__ = "John Westbrook" __email__ = "jwest@rcsb.rutgers.edu" __license__ = "Creative Commons Attribution 3.0 Unported" __version__ = "V0.01" -import sys -import unittest -import platform import os -import traceback +import platform +import sys import time +import traceback +import unittest try: from openeye.oechem import OEFloatArray # noqa: F401 pylint: disable=unused-import @@ -35,10 +36,11 @@ skiptests = True if not skiptests: - from wwpdb.utils.oe_util.build.OePersist import OePersist - from wwpdb.utils.oe_util.build.OeBuildMol import OeBuildMol from mmcif_utils.persist.PdbxPyIoAdapter import PdbxPyIoAdapter as PdbxIoAdapter + from wwpdb.utils.oe_util.build.OeBuildMol import OeBuildMol + from wwpdb.utils.oe_util.build.OePersist import OePersist + @unittest.skipIf(skiptests, "Cannot import openeye.oechem for tests") class OePersistTests(unittest.TestCase): @@ -50,7 +52,11 @@ def setUp(self): self.__testoutput = os.path.join(self.__here, "test-output", platform.python_version()) if not os.path.exists(self.__testoutput): os.makedirs(self.__testoutput) - self.__pathList = [os.path.join(self.__datadir, "ATP.cif"), os.path.join(self.__datadir, "GTP.cif"), os.path.join(self.__datadir, "ARG.cif")] + self.__pathList = [ + os.path.join(self.__datadir, "ATP.cif"), + os.path.join(self.__datadir, "GTP.cif"), + os.path.join(self.__datadir, "ARG.cif"), + ] self.__storePath = os.path.join(self.__testoutput, "oe-store.db") def tearDown(self): @@ -69,7 +75,11 @@ def testCreateStore(self): self.assertTrue(ok) for container in myReader.getContainerList(): name = container.getName() - oem.set(name, dcChemCompAtom=container.getObj("chem_comp_atom"), dcChemCompBond=container.getObj("chem_comp_bond")) + oem.set( + name, + dcChemCompAtom=container.getObj("chem_comp_atom"), + dcChemCompBond=container.getObj("chem_comp_bond"), + ) oem.build2D() self.__lfh.write("Title = %s\n" % oem.getTitle()) self.__lfh.write("SMILES (canonical) = %s\n" % oem.getCanSMILES()) @@ -91,12 +101,13 @@ def testCreateStore(self): def testFetchAll(self): """Test case - fetch all of the molecules in the persistent store""" startTime = time.time() - self.__lfh.write("\nStarting OePersistTests testFetchAll at %s\n" % time.strftime("%Y %m %d %H:%M:%S", time.localtime())) + self.__lfh.write( + "\nStarting OePersistTests testFetchAll at %s\n" % time.strftime("%Y %m %d %H:%M:%S", time.localtime()) + ) try: myPersist = OePersist(self.__verbose, self.__lfh) myPersist.open(dbFileName=self.__storePath) moleculeNameList = myPersist.getStoreMoleculeIndex() - # oem = OeBuildMol(verbose=self.__verbose, log=self.__lfh) for ccId in moleculeNameList: molD = myPersist.fetchMolecule(moleculeName=ccId) @@ -113,16 +124,20 @@ def testFetchAll(self): self.fail() endTime = time.time() - self.__lfh.write("\nCompleted OePersistTests testFetchAll at %s (%d seconds)\n" % (time.strftime("%Y %m %d %H:%M:%S", time.localtime()), endTime - startTime)) + self.__lfh.write( + "\nCompleted OePersistTests testFetchAll at %s (%d seconds)\n" + % (time.strftime("%Y %m %d %H:%M:%S", time.localtime()), endTime - startTime) + ) def testFetchOne(self): """Test case - fetch all of the molecules in the persistent store one by one""" startTime = time.time() - self.__lfh.write("\nStarting OePersistTests testFetchOne at %s\n" % time.strftime("%Y %m %d %H:%M:%S", time.localtime())) + self.__lfh.write( + "\nStarting OePersistTests testFetchOne at %s\n" % time.strftime("%Y %m %d %H:%M:%S", time.localtime()) + ) try: myPersist = OePersist(self.__verbose, self.__lfh) moleculeNameList = myPersist.getIndex(dbFileName=self.__storePath) - # oem = OeBuildMol(verbose=self.__verbose, log=self.__lfh) for ccId in moleculeNameList: molD = myPersist.fetchOneMolecule(dbFileName=self.__storePath, moleculeName=ccId) @@ -139,7 +154,10 @@ def testFetchOne(self): self.fail() endTime = time.time() - self.__lfh.write("\nCompleted OePersistTests testFetchOne at %s (%d seconds)\n" % (time.strftime("%Y %m %d %H:%M:%S", time.localtime()), endTime - startTime)) + self.__lfh.write( + "\nCompleted OePersistTests testFetchOne at %s (%d seconds)\n" + % (time.strftime("%Y %m %d %H:%M:%S", time.localtime()), endTime - startTime) + ) def testUpdateStore(self): """Test case - update store from a selection of serialized OE molecules.""" @@ -153,7 +171,11 @@ def testUpdateStore(self): self.assertTrue(ok) for container in myReader.getContainerList(): name = container.getName() - oem.set(name, dcChemCompAtom=container.getObj("chem_comp_atom"), dcChemCompBond=container.getObj("chem_comp_bond")) + oem.set( + name, + dcChemCompAtom=container.getObj("chem_comp_atom"), + dcChemCompBond=container.getObj("chem_comp_bond"), + ) oem.build2D() self.__lfh.write("Title = %s\n" % oem.getTitle()) self.__lfh.write("SMILES (canonical) = %s\n" % oem.getCanSMILES()) @@ -182,6 +204,5 @@ def suite1(): if __name__ == "__main__": - # mySuite = suite1() unittest.TextTestRunner(verbosity=2).run(mySuite) diff --git a/wwpdb/utils/tests_oe_util/PdbxBuildChemCompTests.py b/tests/PdbxBuildChemCompTests.py similarity index 99% rename from wwpdb/utils/tests_oe_util/PdbxBuildChemCompTests.py rename to tests/PdbxBuildChemCompTests.py index 811bab5..13bec44 100644 --- a/wwpdb/utils/tests_oe_util/PdbxBuildChemCompTests.py +++ b/tests/PdbxBuildChemCompTests.py @@ -13,16 +13,17 @@ Test cases for OE -> CC building tools - """ + __docformat__ = "restructuredtext en" __author__ = "John Westbrook" __email__ = "jwest@rcsb.rutgers.edu" __license__ = "Creative Commons Attribution 3.0 Unported" __version__ = "V0.01" +import os import sys -import unittest import traceback -import os +import unittest try: from openeye.oechem import OEFloatArray # noqa: F401 pylint: disable=unused-import @@ -32,8 +33,8 @@ skiptests = True if not skiptests: - from wwpdb.utils.oe_util.build.PdbxBuildChemComp import PdbxBuildChemComp from wwpdb.utils.oe_util.build.OeChemCompIoUtils import OeChemCompIoUtils + from wwpdb.utils.oe_util.build.PdbxBuildChemComp import PdbxBuildChemComp @unittest.skipIf(skiptests, "Requires openeye library") @@ -64,7 +65,6 @@ def __molListPrint(self, oeMolList): if inKy not in inKyD: inKyD[inKy] = [] inKyD[inKy].append(inKy) - # self.__lfh.write("Unique InChiKeys = %d\n" % (len(inKyD))) def testBuildFromFiles(self): diff --git a/wwpdb/utils/tests_oe_util/__init__.py b/tests/__init__.py similarity index 100% rename from wwpdb/utils/tests_oe_util/__init__.py rename to tests/__init__.py diff --git a/wwpdb/utils/tests_oe_util/data/A.cif b/tests/data/A.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/data/A.cif rename to tests/data/A.cif diff --git a/wwpdb/utils/tests_oe_util/data/ARG.cif b/tests/data/ARG.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/data/ARG.cif rename to tests/data/ARG.cif diff --git a/wwpdb/utils/tests_oe_util/data/ATP.cif b/tests/data/ATP.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/data/ATP.cif rename to tests/data/ATP.cif diff --git a/wwpdb/utils/tests_oe_util/data/ATP.sdf b/tests/data/ATP.sdf similarity index 100% rename from wwpdb/utils/tests_oe_util/data/ATP.sdf rename to tests/data/ATP.sdf diff --git a/wwpdb/utils/tests_oe_util/data/GTP.cif b/tests/data/GTP.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/data/GTP.cif rename to tests/data/GTP.cif diff --git a/wwpdb/utils/tests_oe_util/data/MTGL00001.cif b/tests/data/MTGL00001.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/data/MTGL00001.cif rename to tests/data/MTGL00001.cif diff --git a/wwpdb/utils/tests_oe_util/data/T.cif b/tests/data/T.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/data/T.cif rename to tests/data/T.cif diff --git a/wwpdb/utils/tests_oe_util/data/XXATP.cif b/tests/data/XXATP.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/data/XXATP.cif rename to tests/data/XXATP.cif diff --git a/wwpdb/utils/tests_oe_util/data/ccid_exercise_list.txt b/tests/data/ccid_exercise_list.txt similarity index 100% rename from wwpdb/utils/tests_oe_util/data/ccid_exercise_list.txt rename to tests/data/ccid_exercise_list.txt diff --git a/wwpdb/utils/tests_oe_util/data/ccid_target_list.txt b/tests/data/ccid_target_list.txt similarity index 100% rename from wwpdb/utils/tests_oe_util/data/ccid_target_list.txt rename to tests/data/ccid_target_list.txt diff --git a/wwpdb/utils/tests_oe_util/examples/L_LDI_990_.comp.cif b/tests/examples/L_LDI_990_.comp.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/examples/L_LDI_990_.comp.cif rename to tests/examples/L_LDI_990_.comp.cif diff --git a/wwpdb/utils/tests_oe_util/examples/PRDCC_000225.cif b/tests/examples/PRDCC_000225.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/examples/PRDCC_000225.cif rename to tests/examples/PRDCC_000225.cif diff --git a/wwpdb/utils/tests_oe_util/examples/rna-linking-components.txt b/tests/examples/rna-linking-components.txt similarity index 100% rename from wwpdb/utils/tests_oe_util/examples/rna-linking-components.txt rename to tests/examples/rna-linking-components.txt diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/1/10C/10C.cif b/tests/ligand-dict-v3/1/10C/10C.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/1/10C/10C.cif rename to tests/ligand-dict-v3/1/10C/10C.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/1/125/125.cif b/tests/ligand-dict-v3/1/125/125.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/1/125/125.cif rename to tests/ligand-dict-v3/1/125/125.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/1/126/126.cif b/tests/ligand-dict-v3/1/126/126.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/1/126/126.cif rename to tests/ligand-dict-v3/1/126/126.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/1/127/127.cif b/tests/ligand-dict-v3/1/127/127.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/1/127/127.cif rename to tests/ligand-dict-v3/1/127/127.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/1/12A/12A.cif b/tests/ligand-dict-v3/1/12A/12A.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/1/12A/12A.cif rename to tests/ligand-dict-v3/1/12A/12A.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/1/1MA/1MA.cif b/tests/ligand-dict-v3/1/1MA/1MA.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/1/1MA/1MA.cif rename to tests/ligand-dict-v3/1/1MA/1MA.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/1/1MG/1MG.cif b/tests/ligand-dict-v3/1/1MG/1MG.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/1/1MG/1MG.cif rename to tests/ligand-dict-v3/1/1MG/1MG.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/1/1SC/1SC.cif b/tests/ligand-dict-v3/1/1SC/1SC.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/1/1SC/1SC.cif rename to tests/ligand-dict-v3/1/1SC/1SC.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/2/23G/23G.cif b/tests/ligand-dict-v3/2/23G/23G.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/2/23G/23G.cif rename to tests/ligand-dict-v3/2/23G/23G.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/2/2AU/2AU.cif b/tests/ligand-dict-v3/2/2AU/2AU.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/2/2AU/2AU.cif rename to tests/ligand-dict-v3/2/2AU/2AU.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/2/2MA/2MA.cif b/tests/ligand-dict-v3/2/2MA/2MA.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/2/2MA/2MA.cif rename to tests/ligand-dict-v3/2/2MA/2MA.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/2/2MG/2MG.cif b/tests/ligand-dict-v3/2/2MG/2MG.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/2/2MG/2MG.cif rename to tests/ligand-dict-v3/2/2MG/2MG.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/2/2MU/2MU.cif b/tests/ligand-dict-v3/2/2MU/2MU.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/2/2MU/2MU.cif rename to tests/ligand-dict-v3/2/2MU/2MU.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/2/2OM/2OM.cif b/tests/ligand-dict-v3/2/2OM/2OM.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/2/2OM/2OM.cif rename to tests/ligand-dict-v3/2/2OM/2OM.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/3/3AU/3AU.cif b/tests/ligand-dict-v3/3/3AU/3AU.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/3/3AU/3AU.cif rename to tests/ligand-dict-v3/3/3AU/3AU.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/3/3MU/3MU.cif b/tests/ligand-dict-v3/3/3MU/3MU.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/3/3MU/3MU.cif rename to tests/ligand-dict-v3/3/3MU/3MU.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/3/3TD/3TD.cif b/tests/ligand-dict-v3/3/3TD/3TD.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/3/3TD/3TD.cif rename to tests/ligand-dict-v3/3/3TD/3TD.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/4/4OC/4OC.cif b/tests/ligand-dict-v3/4/4OC/4OC.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/4/4OC/4OC.cif rename to tests/ligand-dict-v3/4/4OC/4OC.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/4/4SU/4SU.cif b/tests/ligand-dict-v3/4/4SU/4SU.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/4/4SU/4SU.cif rename to tests/ligand-dict-v3/4/4SU/4SU.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/5/5BU/5BU.cif b/tests/ligand-dict-v3/5/5BU/5BU.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/5/5BU/5BU.cif rename to tests/ligand-dict-v3/5/5BU/5BU.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/5/5FA/5FA.cif b/tests/ligand-dict-v3/5/5FA/5FA.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/5/5FA/5FA.cif rename to tests/ligand-dict-v3/5/5FA/5FA.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/5/5FU/5FU.cif b/tests/ligand-dict-v3/5/5FU/5FU.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/5/5FU/5FU.cif rename to tests/ligand-dict-v3/5/5FU/5FU.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/5/5IC/5IC.cif b/tests/ligand-dict-v3/5/5IC/5IC.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/5/5IC/5IC.cif rename to tests/ligand-dict-v3/5/5IC/5IC.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/5/5MC/5MC.cif b/tests/ligand-dict-v3/5/5MC/5MC.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/5/5MC/5MC.cif rename to tests/ligand-dict-v3/5/5MC/5MC.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/5/5MU/5MU.cif b/tests/ligand-dict-v3/5/5MU/5MU.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/5/5MU/5MU.cif rename to tests/ligand-dict-v3/5/5MU/5MU.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/6/6IA/6IA.cif b/tests/ligand-dict-v3/6/6IA/6IA.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/6/6IA/6IA.cif rename to tests/ligand-dict-v3/6/6IA/6IA.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/7/70U/70U.cif b/tests/ligand-dict-v3/7/70U/70U.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/7/70U/70U.cif rename to tests/ligand-dict-v3/7/70U/70U.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/7/7MG/7MG.cif b/tests/ligand-dict-v3/7/7MG/7MG.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/7/7MG/7MG.cif rename to tests/ligand-dict-v3/7/7MG/7MG.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/8/8AN/8AN.cif b/tests/ligand-dict-v3/8/8AN/8AN.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/8/8AN/8AN.cif rename to tests/ligand-dict-v3/8/8AN/8AN.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/A/A/A.cif b/tests/ligand-dict-v3/A/A/A.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/A/A/A.cif rename to tests/ligand-dict-v3/A/A/A.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/A/A23/A23.cif b/tests/ligand-dict-v3/A/A23/A23.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/A/A23/A23.cif rename to tests/ligand-dict-v3/A/A23/A23.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/A/A2L/A2L.cif b/tests/ligand-dict-v3/A/A2L/A2L.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/A/A2L/A2L.cif rename to tests/ligand-dict-v3/A/A2L/A2L.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/A/A2M/A2M.cif b/tests/ligand-dict-v3/A/A2M/A2M.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/A/A2M/A2M.cif rename to tests/ligand-dict-v3/A/A2M/A2M.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/A/A3P/A3P.cif b/tests/ligand-dict-v3/A/A3P/A3P.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/A/A3P/A3P.cif rename to tests/ligand-dict-v3/A/A3P/A3P.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/A/A44/A44.cif b/tests/ligand-dict-v3/A/A44/A44.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/A/A44/A44.cif rename to tests/ligand-dict-v3/A/A44/A44.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/A/A5M/A5M.cif b/tests/ligand-dict-v3/A/A5M/A5M.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/A/A5M/A5M.cif rename to tests/ligand-dict-v3/A/A5M/A5M.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/A/A5O/A5O.cif b/tests/ligand-dict-v3/A/A5O/A5O.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/A/A5O/A5O.cif rename to tests/ligand-dict-v3/A/A5O/A5O.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/A/AET/AET.cif b/tests/ligand-dict-v3/A/AET/AET.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/A/AET/AET.cif rename to tests/ligand-dict-v3/A/AET/AET.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/A/AP7/AP7.cif b/tests/ligand-dict-v3/A/AP7/AP7.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/A/AP7/AP7.cif rename to tests/ligand-dict-v3/A/AP7/AP7.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/A/ATP/ATP.cif b/tests/ligand-dict-v3/A/ATP/ATP.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/A/ATP/ATP.cif rename to tests/ligand-dict-v3/A/ATP/ATP.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/A/AVC/AVC.cif b/tests/ligand-dict-v3/A/AVC/AVC.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/A/AVC/AVC.cif rename to tests/ligand-dict-v3/A/AVC/AVC.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/C/C/C.cif b/tests/ligand-dict-v3/C/C/C.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/C/C/C.cif rename to tests/ligand-dict-v3/C/C/C.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/C/C2L/C2L.cif b/tests/ligand-dict-v3/C/C2L/C2L.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/C/C2L/C2L.cif rename to tests/ligand-dict-v3/C/C2L/C2L.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/C/C31/C31.cif b/tests/ligand-dict-v3/C/C31/C31.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/C/C31/C31.cif rename to tests/ligand-dict-v3/C/C31/C31.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/C/C43/C43.cif b/tests/ligand-dict-v3/C/C43/C43.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/C/C43/C43.cif rename to tests/ligand-dict-v3/C/C43/C43.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/C/CBV/CBV.cif b/tests/ligand-dict-v3/C/CBV/CBV.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/C/CBV/CBV.cif rename to tests/ligand-dict-v3/C/CBV/CBV.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/C/CCC/CCC.cif b/tests/ligand-dict-v3/C/CCC/CCC.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/C/CCC/CCC.cif rename to tests/ligand-dict-v3/C/CCC/CCC.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/C/CG1/CG1.cif b/tests/ligand-dict-v3/C/CG1/CG1.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/C/CG1/CG1.cif rename to tests/ligand-dict-v3/C/CG1/CG1.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/C/CH/CH.cif b/tests/ligand-dict-v3/C/CH/CH.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/C/CH/CH.cif rename to tests/ligand-dict-v3/C/CH/CH.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/C/CNU/CNU.cif b/tests/ligand-dict-v3/C/CNU/CNU.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/C/CNU/CNU.cif rename to tests/ligand-dict-v3/C/CNU/CNU.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/C/CSF/CSF.cif b/tests/ligand-dict-v3/C/CSF/CSF.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/C/CSF/CSF.cif rename to tests/ligand-dict-v3/C/CSF/CSF.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/D/DG/DG.cif b/tests/ligand-dict-v3/D/DG/DG.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/D/DG/DG.cif rename to tests/ligand-dict-v3/D/DG/DG.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/F/FHU/FHU.cif b/tests/ligand-dict-v3/F/FHU/FHU.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/F/FHU/FHU.cif rename to tests/ligand-dict-v3/F/FHU/FHU.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/G/G/G.cif b/tests/ligand-dict-v3/G/G/G.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/G/G/G.cif rename to tests/ligand-dict-v3/G/G/G.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/G/G25/G25.cif b/tests/ligand-dict-v3/G/G25/G25.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/G/G25/G25.cif rename to tests/ligand-dict-v3/G/G25/G25.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/G/G2L/G2L.cif b/tests/ligand-dict-v3/G/G2L/G2L.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/G/G2L/G2L.cif rename to tests/ligand-dict-v3/G/G2L/G2L.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/G/G46/G46.cif b/tests/ligand-dict-v3/G/G46/G46.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/G/G46/G46.cif rename to tests/ligand-dict-v3/G/G46/G46.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/G/G48/G48.cif b/tests/ligand-dict-v3/G/G48/G48.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/G/G48/G48.cif rename to tests/ligand-dict-v3/G/G48/G48.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/G/G7M/G7M.cif b/tests/ligand-dict-v3/G/G7M/G7M.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/G/G7M/G7M.cif rename to tests/ligand-dict-v3/G/G7M/G7M.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/G/GAO/GAO.cif b/tests/ligand-dict-v3/G/GAO/GAO.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/G/GAO/GAO.cif rename to tests/ligand-dict-v3/G/GAO/GAO.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/G/GDP/GDP.cif b/tests/ligand-dict-v3/G/GDP/GDP.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/G/GDP/GDP.cif rename to tests/ligand-dict-v3/G/GDP/GDP.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/G/GH3/GH3.cif b/tests/ligand-dict-v3/G/GH3/GH3.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/G/GH3/GH3.cif rename to tests/ligand-dict-v3/G/GH3/GH3.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/G/GOM/GOM.cif b/tests/ligand-dict-v3/G/GOM/GOM.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/G/GOM/GOM.cif rename to tests/ligand-dict-v3/G/GOM/GOM.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/G/GRB/GRB.cif b/tests/ligand-dict-v3/G/GRB/GRB.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/G/GRB/GRB.cif rename to tests/ligand-dict-v3/G/GRB/GRB.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/G/GTP/GTP.cif b/tests/ligand-dict-v3/G/GTP/GTP.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/G/GTP/GTP.cif rename to tests/ligand-dict-v3/G/GTP/GTP.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/H/H2U/H2U.cif b/tests/ligand-dict-v3/H/H2U/H2U.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/H/H2U/H2U.cif rename to tests/ligand-dict-v3/H/H2U/H2U.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/I/IC/IC.cif b/tests/ligand-dict-v3/I/IC/IC.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/I/IC/IC.cif rename to tests/ligand-dict-v3/I/IC/IC.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/I/IG/IG.cif b/tests/ligand-dict-v3/I/IG/IG.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/I/IG/IG.cif rename to tests/ligand-dict-v3/I/IG/IG.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/I/IU/IU.cif b/tests/ligand-dict-v3/I/IU/IU.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/I/IU/IU.cif rename to tests/ligand-dict-v3/I/IU/IU.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/K/KAG/KAG.cif b/tests/ligand-dict-v3/K/KAG/KAG.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/K/KAG/KAG.cif rename to tests/ligand-dict-v3/K/KAG/KAG.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/L/LCA/LCA.cif b/tests/ligand-dict-v3/L/LCA/LCA.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/L/LCA/LCA.cif rename to tests/ligand-dict-v3/L/LCA/LCA.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/M/M2G/M2G.cif b/tests/ligand-dict-v3/M/M2G/M2G.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/M/M2G/M2G.cif rename to tests/ligand-dict-v3/M/M2G/M2G.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/M/M4C/M4C.cif b/tests/ligand-dict-v3/M/M4C/M4C.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/M/M4C/M4C.cif rename to tests/ligand-dict-v3/M/M4C/M4C.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/M/M5M/M5M.cif b/tests/ligand-dict-v3/M/M5M/M5M.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/M/M5M/M5M.cif rename to tests/ligand-dict-v3/M/M5M/M5M.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/M/MA6/MA6.cif b/tests/ligand-dict-v3/M/MA6/MA6.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/M/MA6/MA6.cif rename to tests/ligand-dict-v3/M/MA6/MA6.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/M/MAD/MAD.cif b/tests/ligand-dict-v3/M/MAD/MAD.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/M/MAD/MAD.cif rename to tests/ligand-dict-v3/M/MAD/MAD.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/M/MGQ/MGQ.cif b/tests/ligand-dict-v3/M/MGQ/MGQ.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/M/MGQ/MGQ.cif rename to tests/ligand-dict-v3/M/MGQ/MGQ.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/M/MGV/MGV.cif b/tests/ligand-dict-v3/M/MGV/MGV.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/M/MGV/MGV.cif rename to tests/ligand-dict-v3/M/MGV/MGV.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/M/MIA/MIA.cif b/tests/ligand-dict-v3/M/MIA/MIA.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/M/MIA/MIA.cif rename to tests/ligand-dict-v3/M/MIA/MIA.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/M/MNU/MNU.cif b/tests/ligand-dict-v3/M/MNU/MNU.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/M/MNU/MNU.cif rename to tests/ligand-dict-v3/M/MNU/MNU.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/M/MSE/MSE.cif b/tests/ligand-dict-v3/M/MSE/MSE.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/M/MSE/MSE.cif rename to tests/ligand-dict-v3/M/MSE/MSE.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/M/MTU/MTU.cif b/tests/ligand-dict-v3/M/MTU/MTU.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/M/MTU/MTU.cif rename to tests/ligand-dict-v3/M/MTU/MTU.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/N/N5M/N5M.cif b/tests/ligand-dict-v3/N/N5M/N5M.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/N/N5M/N5M.cif rename to tests/ligand-dict-v3/N/N5M/N5M.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/N/N6G/N6G.cif b/tests/ligand-dict-v3/N/N6G/N6G.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/N/N6G/N6G.cif rename to tests/ligand-dict-v3/N/N6G/N6G.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/O/O2G/O2G.cif b/tests/ligand-dict-v3/O/O2G/O2G.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/O/O2G/O2G.cif rename to tests/ligand-dict-v3/O/O2G/O2G.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/O/OMC/OMC.cif b/tests/ligand-dict-v3/O/OMC/OMC.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/O/OMC/OMC.cif rename to tests/ligand-dict-v3/O/OMC/OMC.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/O/OMG/OMG.cif b/tests/ligand-dict-v3/O/OMG/OMG.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/O/OMG/OMG.cif rename to tests/ligand-dict-v3/O/OMG/OMG.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/O/OMU/OMU.cif b/tests/ligand-dict-v3/O/OMU/OMU.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/O/OMU/OMU.cif rename to tests/ligand-dict-v3/O/OMU/OMU.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/O/ONE/ONE.cif b/tests/ligand-dict-v3/O/ONE/ONE.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/O/ONE/ONE.cif rename to tests/ligand-dict-v3/O/ONE/ONE.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/P/P5P/P5P.cif b/tests/ligand-dict-v3/P/P5P/P5P.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/P/P5P/P5P.cif rename to tests/ligand-dict-v3/P/P5P/P5P.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/P/PGP/PGP.cif b/tests/ligand-dict-v3/P/PGP/PGP.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/P/PGP/PGP.cif rename to tests/ligand-dict-v3/P/PGP/PGP.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/P/PMT/PMT.cif b/tests/ligand-dict-v3/P/PMT/PMT.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/P/PMT/PMT.cif rename to tests/ligand-dict-v3/P/PMT/PMT.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/P/PPU/PPU.cif b/tests/ligand-dict-v3/P/PPU/PPU.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/P/PPU/PPU.cif rename to tests/ligand-dict-v3/P/PPU/PPU.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/P/PSU/PSU.cif b/tests/ligand-dict-v3/P/PSU/PSU.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/P/PSU/PSU.cif rename to tests/ligand-dict-v3/P/PSU/PSU.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/P/PU/PU.cif b/tests/ligand-dict-v3/P/PU/PU.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/P/PU/PU.cif rename to tests/ligand-dict-v3/P/PU/PU.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/P/PYO/PYO.cif b/tests/ligand-dict-v3/P/PYO/PYO.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/P/PYO/PYO.cif rename to tests/ligand-dict-v3/P/PYO/PYO.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/Q/QUO/QUO.cif b/tests/ligand-dict-v3/Q/QUO/QUO.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/Q/QUO/QUO.cif rename to tests/ligand-dict-v3/Q/QUO/QUO.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/R/RIA/RIA.cif b/tests/ligand-dict-v3/R/RIA/RIA.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/R/RIA/RIA.cif rename to tests/ligand-dict-v3/R/RIA/RIA.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/R/RSQ/RSQ.cif b/tests/ligand-dict-v3/R/RSQ/RSQ.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/R/RSQ/RSQ.cif rename to tests/ligand-dict-v3/R/RSQ/RSQ.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/R/RUS/RUS.cif b/tests/ligand-dict-v3/R/RUS/RUS.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/R/RUS/RUS.cif rename to tests/ligand-dict-v3/R/RUS/RUS.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/S/S4C/S4C.cif b/tests/ligand-dict-v3/S/S4C/S4C.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/S/S4C/S4C.cif rename to tests/ligand-dict-v3/S/S4C/S4C.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/S/SMT/SMT.cif b/tests/ligand-dict-v3/S/SMT/SMT.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/S/SMT/SMT.cif rename to tests/ligand-dict-v3/S/SMT/SMT.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/S/SRA/SRA.cif b/tests/ligand-dict-v3/S/SRA/SRA.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/S/SRA/SRA.cif rename to tests/ligand-dict-v3/S/SRA/SRA.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/S/SSU/SSU.cif b/tests/ligand-dict-v3/S/SSU/SSU.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/S/SSU/SSU.cif rename to tests/ligand-dict-v3/S/SSU/SSU.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/S/SUR/SUR.cif b/tests/ligand-dict-v3/S/SUR/SUR.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/S/SUR/SUR.cif rename to tests/ligand-dict-v3/S/SUR/SUR.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/T/T/T.cif b/tests/ligand-dict-v3/T/T/T.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/T/T/T.cif rename to tests/ligand-dict-v3/T/T/T.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/T/T23/T23.cif b/tests/ligand-dict-v3/T/T23/T23.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/T/T23/T23.cif rename to tests/ligand-dict-v3/T/T23/T23.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/T/T2S/T2S.cif b/tests/ligand-dict-v3/T/T2S/T2S.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/T/T2S/T2S.cif rename to tests/ligand-dict-v3/T/T2S/T2S.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/T/T38/T38.cif b/tests/ligand-dict-v3/T/T38/T38.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/T/T38/T38.cif rename to tests/ligand-dict-v3/T/T38/T38.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/T/T39/T39.cif b/tests/ligand-dict-v3/T/T39/T39.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/T/T39/T39.cif rename to tests/ligand-dict-v3/T/T39/T39.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/T/T41/T41.cif b/tests/ligand-dict-v3/T/T41/T41.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/T/T41/T41.cif rename to tests/ligand-dict-v3/T/T41/T41.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/T/T6A/T6A.cif b/tests/ligand-dict-v3/T/T6A/T6A.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/T/T6A/T6A.cif rename to tests/ligand-dict-v3/T/T6A/T6A.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/T/TPG/TPG.cif b/tests/ligand-dict-v3/T/TPG/TPG.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/T/TPG/TPG.cif rename to tests/ligand-dict-v3/T/TPG/TPG.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/T/TRP/TRP.cif b/tests/ligand-dict-v3/T/TRP/TRP.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/T/TRP/TRP.cif rename to tests/ligand-dict-v3/T/TRP/TRP.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/TP/XXATP/XXATP.cif b/tests/ligand-dict-v3/TP/XXATP/XXATP.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/TP/XXATP/XXATP.cif rename to tests/ligand-dict-v3/TP/XXATP/XXATP.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/U/U/U.cif b/tests/ligand-dict-v3/U/U/U.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/U/U/U.cif rename to tests/ligand-dict-v3/U/U/U.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/U/U2L/U2L.cif b/tests/ligand-dict-v3/U/U2L/U2L.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/U/U2L/U2L.cif rename to tests/ligand-dict-v3/U/U2L/U2L.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/U/U2P/U2P.cif b/tests/ligand-dict-v3/U/U2P/U2P.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/U/U2P/U2P.cif rename to tests/ligand-dict-v3/U/U2P/U2P.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/U/U31/U31.cif b/tests/ligand-dict-v3/U/U31/U31.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/U/U31/U31.cif rename to tests/ligand-dict-v3/U/U31/U31.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/U/U34/U34.cif b/tests/ligand-dict-v3/U/U34/U34.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/U/U34/U34.cif rename to tests/ligand-dict-v3/U/U34/U34.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/U/U36/U36.cif b/tests/ligand-dict-v3/U/U36/U36.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/U/U36/U36.cif rename to tests/ligand-dict-v3/U/U36/U36.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/U/U37/U37.cif b/tests/ligand-dict-v3/U/U37/U37.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/U/U37/U37.cif rename to tests/ligand-dict-v3/U/U37/U37.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/U/U8U/U8U.cif b/tests/ligand-dict-v3/U/U8U/U8U.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/U/U8U/U8U.cif rename to tests/ligand-dict-v3/U/U8U/U8U.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/U/UAR/UAR.cif b/tests/ligand-dict-v3/U/UAR/UAR.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/U/UAR/UAR.cif rename to tests/ligand-dict-v3/U/UAR/UAR.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/U/UD5/UD5.cif b/tests/ligand-dict-v3/U/UD5/UD5.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/U/UD5/UD5.cif rename to tests/ligand-dict-v3/U/UD5/UD5.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/U/UMP/UMP.cif b/tests/ligand-dict-v3/U/UMP/UMP.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/U/UMP/UMP.cif rename to tests/ligand-dict-v3/U/UMP/UMP.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/U/UR3/UR3.cif b/tests/ligand-dict-v3/U/UR3/UR3.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/U/UR3/UR3.cif rename to tests/ligand-dict-v3/U/UR3/UR3.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/U/URD/URD.cif b/tests/ligand-dict-v3/U/URD/URD.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/U/URD/URD.cif rename to tests/ligand-dict-v3/U/URD/URD.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/U/US5/US5.cif b/tests/ligand-dict-v3/U/US5/US5.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/U/US5/US5.cif rename to tests/ligand-dict-v3/U/US5/US5.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/X/XTS/XTS.cif b/tests/ligand-dict-v3/X/XTS/XTS.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/X/XTS/XTS.cif rename to tests/ligand-dict-v3/X/XTS/XTS.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/Y/YG/YG.cif b/tests/ligand-dict-v3/Y/YG/YG.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/Y/YG/YG.cif rename to tests/ligand-dict-v3/Y/YG/YG.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/Y/YYG/YYG.cif b/tests/ligand-dict-v3/Y/YYG/YYG.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/Y/YYG/YYG.cif rename to tests/ligand-dict-v3/Y/YYG/YYG.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/Z/ZAD/ZAD.cif b/tests/ligand-dict-v3/Z/ZAD/ZAD.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/Z/ZAD/ZAD.cif rename to tests/ligand-dict-v3/Z/ZAD/ZAD.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/Z/ZBC/ZBC.cif b/tests/ligand-dict-v3/Z/ZBC/ZBC.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/Z/ZBC/ZBC.cif rename to tests/ligand-dict-v3/Z/ZBC/ZBC.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/Z/ZBU/ZBU.cif b/tests/ligand-dict-v3/Z/ZBU/ZBU.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/Z/ZBU/ZBU.cif rename to tests/ligand-dict-v3/Z/ZBU/ZBU.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/Z/ZCY/ZCY.cif b/tests/ligand-dict-v3/Z/ZCY/ZCY.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/Z/ZCY/ZCY.cif rename to tests/ligand-dict-v3/Z/ZCY/ZCY.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/Z/ZGU/ZGU.cif b/tests/ligand-dict-v3/Z/ZGU/ZGU.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/Z/ZGU/ZGU.cif rename to tests/ligand-dict-v3/Z/ZGU/ZGU.cif diff --git a/wwpdb/utils/tests_oe_util/ligand-dict-v3/Z/ZTH/ZTH.cif b/tests/ligand-dict-v3/Z/ZTH/ZTH.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/ligand-dict-v3/Z/ZTH/ZTH.cif rename to tests/ligand-dict-v3/Z/ZTH/ZTH.cif diff --git a/wwpdb/utils/tests_oe_util/prdcc-v3/0/PRDCC_000010.cif b/tests/prdcc-v3/0/PRDCC_000010.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/prdcc-v3/0/PRDCC_000010.cif rename to tests/prdcc-v3/0/PRDCC_000010.cif diff --git a/wwpdb/utils/tests_oe_util/prdcc-v3/0/PRDCC_000110.cif b/tests/prdcc-v3/0/PRDCC_000110.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/prdcc-v3/0/PRDCC_000110.cif rename to tests/prdcc-v3/0/PRDCC_000110.cif diff --git a/wwpdb/utils/tests_oe_util/prdcc-v3/0/PRDCC_000150.cif b/tests/prdcc-v3/0/PRDCC_000150.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/prdcc-v3/0/PRDCC_000150.cif rename to tests/prdcc-v3/0/PRDCC_000150.cif diff --git a/wwpdb/utils/tests_oe_util/prdcc-v3/0/PRDCC_000160.cif b/tests/prdcc-v3/0/PRDCC_000160.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/prdcc-v3/0/PRDCC_000160.cif rename to tests/prdcc-v3/0/PRDCC_000160.cif diff --git a/wwpdb/utils/tests_oe_util/prdcc-v3/0/PRDCC_000180.cif b/tests/prdcc-v3/0/PRDCC_000180.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/prdcc-v3/0/PRDCC_000180.cif rename to tests/prdcc-v3/0/PRDCC_000180.cif diff --git a/wwpdb/utils/tests_oe_util/prdcc-v3/1/PRDCC_000001.cif b/tests/prdcc-v3/1/PRDCC_000001.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/prdcc-v3/1/PRDCC_000001.cif rename to tests/prdcc-v3/1/PRDCC_000001.cif diff --git a/wwpdb/utils/tests_oe_util/prdcc-v3/1/PRDCC_000011.cif b/tests/prdcc-v3/1/PRDCC_000011.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/prdcc-v3/1/PRDCC_000011.cif rename to tests/prdcc-v3/1/PRDCC_000011.cif diff --git a/wwpdb/utils/tests_oe_util/prdcc-v3/1/PRDCC_000151.cif b/tests/prdcc-v3/1/PRDCC_000151.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/prdcc-v3/1/PRDCC_000151.cif rename to tests/prdcc-v3/1/PRDCC_000151.cif diff --git a/wwpdb/utils/tests_oe_util/prdcc-v3/1/PRDCC_000161.cif b/tests/prdcc-v3/1/PRDCC_000161.cif similarity index 100% rename from wwpdb/utils/tests_oe_util/prdcc-v3/1/PRDCC_000161.cif rename to tests/prdcc-v3/1/PRDCC_000161.cif diff --git a/tox.ini b/tox.ini index e94dff7..6a68c7b 100644 --- a/tox.ini +++ b/tox.ini @@ -7,25 +7,25 @@ test_pattern = "*Tests.py" # # Source paths (unquoted and space separated list of files/directories) for linting and format checks -source_paths = wwpdb/utils/oe_util wwpdb/utils/tests_oe_util setup.py +source_paths = wwpdb/utils/oe_util tests # # Start directory path for test discovery # Each path must reference valid directory that is searchable by python3.9 (i.e. contains __init__.py) # ** It is harmless to point to paths containing no tests. # -test_path_1 = "wwpdb/utils/tests_oe_util" +test_path_1 = "tests" # These are placeholders valid source directories without tests files test_path_2 = "wwpdb/utils/oe_util" test_path_3 = "wwpdb/utils/oe_util" test_path_4 = "wwpdb/utils/oe_util" # # Comma separate list of directories/patterns for which test coverage will be evaluated -coverage_source_paths = "wwpdb/utils/oe_util,wwpdb/utils/tests_oe_utils" -coverage_exclude_paths = "wwpdb/__init__.py,wwpdb/utils/tests_oe_utils/test-output/*,wwpdb/utils/oe_util/simple-example.py" +coverage_source_paths = "wwpdb/utils/oe_util,tests" +coverage_exclude_paths = "wwpdb/__init__.py,tests/test-output/*,wwpdb/utils/oe_util/simple-example.py" coverage_cutoff = 64 # # Comma list of directories to exclude from flake -flake_exclude_paths = --exclude wwpdb/utils/tests_oe_utils/test-output +flake_exclude_paths = --exclude tests/test-output ## -------------------------------------------------------------------------- ## ---------- No project specific setting beyond this point -------------- @@ -38,7 +38,7 @@ flake_exclude_paths = --exclude wwpdb/utils/tests_oe_utils/test-output [tox] # The complete list of supported test environments to setup and invoke # py27 not enabled by default as need to obtain openeye separately -envlist = format_pep8-{py310}, lint_pylint-{py310}, format_black-{py310}, {py310}, test_coverage-{py310} +envlist = format_pep8-{py310}, lint_pylint-{py310}, mypy-{py310}, {py310}, test_coverage-{py310} # minversion = 3.4.0 skip_missing_interpreters = true @@ -55,7 +55,7 @@ basepython = py312: python3.12 py39: python3.9 py27: python2.7 -[testenv:py3{9,10,11,12},py27] +[testenv:py3{9,10,11,12,13},py27] description = 'Run unit tests (unittest runner) using {envpython}' platform= macos: darwin @@ -76,7 +76,7 @@ commands = echo "Completed {envname}" # -[testenv:format_pep8-py3{9,10,11,12}] +[testenv:format_pep8-py3{9,10,11,12,13}] description = 'Run selected PEP8 compliance checks (flake8)' platform= macos: darwin @@ -89,7 +89,7 @@ commands = flake8 --max-line-length=185 --ignore=D,I,E203,W503 {[local_settings]source_paths} {[local_settings]flake_exclude_paths} # -[testenv:lint_pylint-py3{9,10,11,12}] +[testenv:lint_pylint-py3{9,10,11,12,13}] description = 'Run linting compliance checks (pylint)' platform= macos: darwin @@ -104,7 +104,7 @@ commands = echo "Completed {envname}" # -[testenv:format_black-py3{9,10,11,12}] +[testenv:format_black-py3{9,10,11,12,13}] description = 'Run format compliance checks (black)' platform= macos: darwin @@ -120,7 +120,7 @@ commands = echo "Completed {envname}" # -[testenv:test_coverage-py3{9,10,11,12}] +[testenv:test_coverage-py3{9,10,11,12,13}] description = 'Run test coverage analysis' platform= macos: darwin @@ -144,4 +144,15 @@ commands = echo " ------- Building {envname} reports ----------" coverage report --fail-under={[local_settings]coverage_cutoff} - coverage xml - echo "Completed {envname}" \ No newline at end of file + echo "Completed {envname}" + +[testenv:mypy-py3{8,9,10,11,12,13}] +description = 'Run mypy tests' +platform= + macos: darwin + linux: linux +deps = -r requirements.txt + mypy +commands = + mypy -p wwpdb -p tests + diff --git a/wwpdb/__init__.py b/wwpdb/__init__.py deleted file mode 100644 index 69e3be5..0000000 --- a/wwpdb/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/wwpdb/mock-data b/wwpdb/mock-data deleted file mode 160000 index 8b189f7..0000000 --- a/wwpdb/mock-data +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8b189f7db0e7a7cb09892d5510b570904ea10547 diff --git a/wwpdb/utils/__init__.py b/wwpdb/utils/__init__.py deleted file mode 100644 index 69e3be5..0000000 --- a/wwpdb/utils/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/wwpdb/utils/oe_util/build/OeBuildModelMol.py b/wwpdb/utils/oe_util/build/OeBuildModelMol.py index c43e789..db30fd7 100644 --- a/wwpdb/utils/oe_util/build/OeBuildModelMol.py +++ b/wwpdb/utils/oe_util/build/OeBuildModelMol.py @@ -12,6 +12,7 @@ Classes to build OE molecule objects from chemical component model instances. """ + __docformat__ = "restructuredtext en" __author__ = "John Westbrook" __email__ = "jwest@rcsb.rutgers.edu" @@ -22,22 +23,30 @@ import sys import traceback -from mmcif_utils.chemcomp.PdbxChemCompModel import (PdbxChemCompModel, - PdbxChemCompModelAtom, - PdbxChemCompModelBond) +from mmcif_utils.chemcomp.PdbxChemCompModel import PdbxChemCompModel, PdbxChemCompModelAtom, PdbxChemCompModelBond from mmcif_utils.chemcomp.PdbxChemCompModelIo import PdbxChemCompModelIo -from openeye.oechem import (OE3DToInternalStereo, OEAroModelOpenEye, - OEAssignAromaticFlags, OECreateCanSmiString, - OECreateInChI, OECreateInChIKey, - OECreateIsoSmiString, OEFindRingAtomsAndBonds, - OEFormat_OEB, OEMol, OEMolecularFormula, - OEPerceiveCIPStereo, OESuppressHydrogens, - OEWriteMolecule, oemolistream, oemolostream) - - -class OeBuildModelMol(object): - ''' Utility methods for constructing OEMols from chemical component model instances. - ''' +from openeye.oechem import ( + OE3DToInternalStereo, + OEAroModelOpenEye, + OEAssignAromaticFlags, + OECreateCanSmiString, + OECreateInChI, + OECreateInChIKey, + OECreateIsoSmiString, + OEFindRingAtomsAndBonds, + OEFormat_OEB, + OEMol, + OEMolecularFormula, + OEPerceiveCIPStereo, + OESuppressHydrogens, + OEWriteMolecule, + oemolistream, + oemolostream, +) + + +class OeBuildModelMol: + """Utility methods for constructing OEMols from chemical component model instances.""" def __init__(self, verbose=True, log=sys.stderr): self.__verbose = verbose @@ -70,15 +79,15 @@ def setChemCompModelPath(self, modelPath): try: ccm = PdbxChemCompModelIo(verbose=self.__verbose, log=self.__lfh) ccm.setFilePath(modelPath) - ccDL = ccm.getAttribDictList(catName='pdbx_chem_comp_model') + ccDL = ccm.getAttribDictList(catName="pdbx_chem_comp_model") cmp = PdbxChemCompModel(ccDL[0], self.__verbose, self.__lfh) self.__modelId = cmp.getId() self.__ccId = cmp.getCompId() - self.__ccAtomDL = ccm.getAttribDictList(catName='pdbx_chem_comp_model_atom') - self.__ccBondDL = ccm.getAttribDictList(catName='pdbx_chem_comp_model_bond') + self.__ccAtomDL = ccm.getAttribDictList(catName="pdbx_chem_comp_model_atom") + self.__ccBondDL = ccm.getAttribDictList(catName="pdbx_chem_comp_model_bond") return self.__modelId - except Exception as e: + except Exception as e: # noqa: BLE001 self.__lfh.write("OeBuildModelMol(setChemCompModelPath) Fails for %s %s\n" % (modelPath, str(e))) traceback.print_exc(file=self.__lfh) return None @@ -88,25 +97,25 @@ def __clear(self): self.__eD = {} def serialize(self): - """ Create a string representing the content of the current OE molecule. This - serialization uses the OE internal binary format. + """Create a string representing the content of the current OE molecule. This + serialization uses the OE internal binary format. """ oms = oemolostream() oms.SetFormat(OEFormat_OEB) oms.openstring() OEWriteMolecule(oms, self.__oeMol) - if (self.__debug): + if self.__debug: self.__lfh.write("OeBuildModelMol(Serialize) SMILES %s\n" % OECreateCanSmiString(self.__oeMol)) self.__lfh.write("OeBuildModelMol(Serialize) atoms = %d\n" % self.__oeMol.NumAtoms()) return oms.GetString() def deserialize(self, oeS): - """ Reconstruct an OE molecule from the input string serialization (OE binary). + """Reconstruct an OE molecule from the input string serialization (OE binary). - The deserialized molecule is used to initialize the internal OE molecule - within this object. + The deserialized molecule is used to initialize the internal OE molecule + within this object. - Returns True for success or False otherwise. + Returns True for success or False otherwise. """ self.__clear() ims = oemolistream() @@ -117,29 +126,25 @@ def deserialize(self, oeS): mList = [] # for mol in ims.GetOEGraphMols(): for mol in ims.GetOEMols(): - if (self.__debug): + if self.__debug: self.__lfh.write("OeBuildModelMol(deserialize) SMILES %s\n" % OECreateCanSmiString(mol)) self.__lfh.write("OeBuildModelMol(deserialize) title %s\n" % mol.GetTitle()) self.__lfh.write("OeBuildModelMol(deserialize) atoms %d\n" % mol.NumAtoms()) # mList.append(OEGraphMol(mol)) mList.append(OEMol(mol)) nmol += 1 - # if nmol >= 1: self.__oeMol = mList[0] self.__ccId = self.__oeMol.GetTitle() - # - if (self.__debug): + if self.__debug: self.__lfh.write("OeBuildModelMol(deserialize) mols %d\n" % nmol) self.__lfh.write("OeBuildModelMol(deserialize) id %s\n" % self.__ccId) self.__lfh.write("OeBuildModelMol(deserialize) atoms %d\n" % self.__oeMol.NumAtoms()) return True - else: - return False + return False def getElementCounts(self): - """ Get the dictionary of element counts (eg. eD[iAtNo]=iCount). - """ + """Get the dictionary of element counts (eg. eD[iAtNo]=iCount).""" if len(self.__eD) == 0: # calculate from current oeMol try: @@ -163,11 +168,9 @@ def build3D(self): return False def __build3D(self): - """ Build OE molecule using model instance 3D coordinates and OE stereo perception. - """ + """Build OE molecule using model instance 3D coordinates and OE stereo perception.""" self.__clear() self.__oeMol = OEMol() - # self.__oeMol.SetTitle(self.__modelId) aL = [] @@ -209,8 +212,10 @@ def __build3D(self): # if (self.__verbose): # self.__lfh.write("CC %s Atom - %s cTup %r\n" % (self.__ccId,atName,cTup)) self.__oeMol.SetCoords(oeAt, cTup) - if (self.__debug): - self.__lfh.write("Atom - %s type %s atno %d isotope %d fc %d (xyz) %r\n" % (atName, atType, atNo, isotope, fc, cTup)) + if self.__debug: + self.__lfh.write( + "Atom - %s type %s atno %d isotope %d fc %d (xyz) %r\n" % (atName, atType, atNo, isotope, fc, cTup) + ) aL.append(oeAt) for d in self.__ccBondDL: @@ -221,7 +226,7 @@ def __build3D(self): iType = ccBnd.getIntegerType() # # arFlag=ccBnd.isAromatic() - if (self.__debug): + if self.__debug: self.__lfh.write(" %s %d -- %s %d (%d)\n" % (at1, iat1, at2, iat2, iType)) oeBnd = self.__oeMol.NewBond(aL[iat1], aL[iat2], iType) # noqa: F841 pylint: disable=unused-variable @@ -244,59 +249,48 @@ def __build3D(self): self.updateCIPStereoOE() def updateCIPStereoOE(self): - """ OE perception of CIP stereo - - """ + """OE perception of CIP stereo -""" for atom in self.__oeMol.GetAtoms(): OEPerceiveCIPStereo(self.__oeMol, atom) for bond in self.__oeMol.GetBonds(): - if (bond.GetOrder() == 2): + if bond.GetOrder() == 2: OEPerceiveCIPStereo(self.__oeMol, bond) def getGraphMolSuppressH(self): - """ Return the current constructed OE molecule with hydrogens suppressed. - """ + """Return the current constructed OE molecule with hydrogens suppressed.""" # OESuppressHydrogens(self.__oeMol, retainPolar=False,retainStereo=True,retainIsotope=True) OESuppressHydrogens(self.__oeMol) return self.__oeMol def getMol(self): - """ Return the current constructed OE molecule. - """ + """Return the current constructed OE molecule.""" return self.__oeMol def getCanSMILES(self): - """ Return the cannonical SMILES string derived from the current OD molecule. - """ + """Return the cannonical SMILES string derived from the current OD molecule.""" return OECreateCanSmiString(self.__oeMol) def getIsoSMILES(self): - """ Return the cannonical stereo SMILES string derived from the current OE molecule. - """ + """Return the cannonical stereo SMILES string derived from the current OE molecule.""" return OECreateIsoSmiString(self.__oeMol) def getFormula(self): - """ Return the Hill order formulat derived from the current OE molecule. - """ + """Return the Hill order formulat derived from the current OE molecule.""" return OEMolecularFormula(self.__oeMol) def getInChIKey(self): - """ Return the InChI key derived from the current OE molecule. - """ + """Return the InChI key derived from the current OE molecule.""" return OECreateInChIKey(self.__oeMol) def getInChI(self): - """ Return the InChI string derived from the current OE molecule. - """ + """Return the InChI string derived from the current OE molecule.""" return OECreateInChI(self.__oeMol) def getTitle(self): - """ Return the title assigned to the current OE molecule - """ + """Return the title assigned to the current OE molecule""" return self.__oeMol.GetTitle() def getCoords(self): - """ Return coordinate list if a 3D molecule is built -- otherwise an empty list -- - - """ + """Return coordinate list if a 3D molecule is built -- otherwise an empty list --""" return self.__molXyzL diff --git a/wwpdb/utils/oe_util/build/OeBuildMol.py b/wwpdb/utils/oe_util/build/OeBuildMol.py index 73e78bd..518da45 100644 --- a/wwpdb/utils/oe_util/build/OeBuildMol.py +++ b/wwpdb/utils/oe_util/build/OeBuildMol.py @@ -22,6 +22,7 @@ Classes to build OE molecule objects from chemical component definition data. """ + __docformat__ = "restructuredtext en" __author__ = "John Westbrook" __email__ = "jwest@rcsb.rutgers.edu" @@ -33,28 +34,46 @@ import traceback from mmcif.io.IoAdapterCore import IoAdapterCore as IoAdapter + # from mmcif.api.PdbxContainers import * from mmcif_utils.chemcomp.PdbxChemComp import PdbxChemCompConstants -from openeye.oechem import (OE3DToInternalStereo, OEAddExplicitHydrogens, - OEAroModelOpenEye, OEAssignAromaticFlags, - OECIPAtomStereo_R, OECIPAtomStereo_S, - OECIPBondStereo_E, OECIPBondStereo_Z, - OECreateCanSmiString, OECreateInChI, - OECreateInChIKey, OECreateIsoSmiString, - OEFindRingAtomsAndBonds, OEFloatArray, - OEFormat_OEB, OEGetAtomicSymbol, OEGraphMol, OEMol, - OEMolecularFormula, OEParseSmiles, - OEPerceiveChiral, OEPerceiveCIPStereo, - OEReadMolecule, OESetCIPStereo, - OESuppressHydrogens, OETriposAtomNames, - OEWriteMolecule, oemolistream, oemolostream) -from wwpdb.utils.cc_dict_util.persist.PdbxChemCompPersist import ( - PdbxChemCompAtomIt, PdbxChemCompBondIt) - - -class OeBuildMol(object): - ''' Utility methods for constructing OEGraphMols from chemical component definition objects. - ''' +from openeye.oechem import ( + OE3DToInternalStereo, + OEAddExplicitHydrogens, + OEAroModelOpenEye, + OEAssignAromaticFlags, + OECIPAtomStereo_R, + OECIPAtomStereo_S, + OECIPBondStereo_E, + OECIPBondStereo_Z, + OECreateCanSmiString, + OECreateInChI, + OECreateInChIKey, + OECreateIsoSmiString, + OEFindRingAtomsAndBonds, + OEFloatArray, + OEFormat_OEB, + OEGetAtomicSymbol, + OEGraphMol, + OEMol, + OEMolecularFormula, + OEParseSmiles, + OEPerceiveChiral, + OEPerceiveCIPStereo, + OEReadMolecule, + OESetCIPStereo, + OESuppressHydrogens, + OETriposAtomNames, + OEWriteMolecule, + oemolistream, + oemolostream, +) + +from wwpdb.utils.cc_dict_util.persist.PdbxChemCompPersist import PdbxChemCompAtomIt, PdbxChemCompBondIt + + +class OeBuildMol: + """Utility methods for constructing OEGraphMols from chemical component definition objects.""" def __init__(self, verbose=True, log=sys.stderr): self.__verbose = verbose @@ -76,7 +95,6 @@ def __init__(self, verbose=True, log=sys.stderr): # Source data categories objects from chemical component definitions. self.__dcChemCompAtom = None self.__dcChemCompBond = None - # self.__molXyzL = [] def setDebug(self, flag): @@ -90,22 +108,20 @@ def setChemCompPath(self, ccPath): self.__dcChemCompAtom = cL[0].getObj("chem_comp_atom") self.__dcChemCompBond = cL[0].getObj("chem_comp_bond") return self.__ccId - except Exception as e: + except Exception as e: # noqa: BLE001 self.__lfh.write("OeBuildMol(setChemCompPath) Fails for %s %s\n" % (ccPath, str(e))) traceback.print_exc(file=self.__lfh) return None def setOeMol(self, inpOeMol, ccId): - """ Load this object with an existing oeMOL() - """ + """Load this object with an existing oeMOL()""" self.__clear() self.__oeMol = OEMol(inpOeMol) self.__ccId = ccId self.getElementCounts() def set(self, ccId, dcChemCompAtom=None, dcChemCompBond=None): - """ Assign source data categories - - """ + """Assign source data categories -""" self.__ccId = ccId self.__dcChemCompAtom = dcChemCompAtom self.__dcChemCompBond = dcChemCompBond @@ -115,25 +131,25 @@ def __clear(self): self.__eD = {} def serialize(self): - """ Create a string representing the content of the current OE molecule. This - serialization uses the OE internal binary format. + """Create a string representing the content of the current OE molecule. This + serialization uses the OE internal binary format. """ oms = oemolostream() oms.SetFormat(OEFormat_OEB) oms.openstring() OEWriteMolecule(oms, self.__oeMol) - if (self.__debug): + if self.__debug: self.__lfh.write("OeBuildMol(Serialize) SMILES %s\n" % OECreateCanSmiString(self.__oeMol)) self.__lfh.write("OeBuildMol(Serialize) atoms = %d\n" % self.__oeMol.NumAtoms()) return oms.GetString() def deserialize(self, oeS): - """ Reconstruct an OE molecule from the input string serialization (OE binary). + """Reconstruct an OE molecule from the input string serialization (OE binary). - The deserialized molecule is used to initialize the internal OE molecule - within this object. + The deserialized molecule is used to initialize the internal OE molecule + within this object. - Returns True for success or False otherwise. + Returns True for success or False otherwise. """ self.__clear() ims = oemolistream() @@ -144,37 +160,32 @@ def deserialize(self, oeS): mList = [] # for mol in ims.GetOEGraphMols(): for mol in ims.GetOEMols(): - if (self.__debug): + if self.__debug: self.__lfh.write("OeBuildMol(deserialize) SMILES %s\n" % OECreateCanSmiString(mol)) self.__lfh.write("OeBuildMol(deserialize) title %s\n" % mol.GetTitle()) self.__lfh.write("OeBuildMol(deserialize) atoms %d\n" % mol.NumAtoms()) # mList.append(OEGraphMol(mol)) mList.append(OEMol(mol)) nmol += 1 - # if nmol >= 1: self.__oeMol = mList[0] self.__ccId = self.__oeMol.GetTitle() - # - if (self.__debug): + if self.__debug: self.__lfh.write("OeBuildMol(deserialize) mols %d\n" % nmol) self.__lfh.write("OeBuildMol(deserialize) id %s\n" % self.__ccId) self.__lfh.write("OeBuildMol(deserialize) atoms %d\n" % self.__oeMol.NumAtoms()) return True - else: - return False + return False def simpleAtomNames(self): - """ - """ + """ """ for atom in self.__oeMol.GetAtoms(): atom.SetIntType(atom.GetAtomicNum()) atom.SetType(OEGetAtomicSymbol(atom.GetAtomicNum())) OETriposAtomNames(self.__oeMol) def getElementCounts(self): - """ Get the dictionary of element counts (eg. eD[iAtNo]=iCount). - """ + """Get the dictionary of element counts (eg. eD[iAtNo]=iCount).""" if len(self.__eD) == 0: # calculate from current oeMol try: @@ -194,18 +205,16 @@ def build3D(self, coordType="model", setTitle=True): try: self.__build3D(coordType=coordType, setTitle=setTitle) return True - except Exception as e: + except Exception as e: # noqa: BLE001 self.__lfh.write("OeBuildMol(build3D) Failing %s\n" % str(e)) traceback.print_exc(file=self.__lfh) return False def __build3D(self, coordType="model", setTitle=True): - """ Build OE molecule using 3D coordinates and OE stereo perception. - """ + """Build OE molecule using 3D coordinates and OE stereo perception.""" self.__clear() # self.__oeMol=OEGraphMol() self.__oeMol = OEMol() - # if setTitle: self.__oeMol.SetTitle(self.__ccId) aL = [] @@ -216,7 +225,6 @@ def __build3D(self, coordType="model", setTitle=True): atomIt = PdbxChemCompAtomIt(self.__dcChemCompAtom, self.__verbose, self.__lfh) for ccAt in atomIt: - atName = ccAt.getName() aD[atName] = i i += 1 @@ -248,19 +256,21 @@ def __build3D(self, coordType="model", setTitle=True): # if (self.__debug): # self.__lfh.write("Atom - %s type %s atno %d isotope %d fc %d chFlag %r\n" % (atName,atType,atNo,isotope,fc,chFlag)) - if ((coordType == 'model') and ccAt.hasModelCoordinates()): + if (coordType == "model") and ccAt.hasModelCoordinates(): cTup = ccAt.getModelCoordinates() # if (self.__verbose): # self.__lfh.write("CC %s Atom - %s cTup %r\n" % (self.__ccId,atName,cTup)) self.__oeMol.SetCoords(oeAt, cTup) - elif ((coordType == 'ideal') and ccAt.hasIdealCoordinates()): + elif (coordType == "ideal") and ccAt.hasIdealCoordinates(): cTup = ccAt.getIdealCoordinates() self.__oeMol.SetCoords(oeAt, cTup) else: pass - if (self.__debug): - self.__lfh.write("Atom - %s type %s atno %d isotope %d fc %d (xyz) %r\n" % (atName, atType, atNo, isotope, fc, cTup)) + if self.__debug: + self.__lfh.write( + "Atom - %s type %s atno %d isotope %d fc %d (xyz) %r\n" % (atName, atType, atNo, isotope, fc, cTup) + ) aL.append(oeAt) bondIt = PdbxChemCompBondIt(self.__dcChemCompBond, self.__verbose, self.__lfh) @@ -269,9 +279,8 @@ def __build3D(self, coordType="model", setTitle=True): iat1 = aD[at1] - 1 iat2 = aD[at2] - 1 iType = ccBnd.getIntegerType() - # arFlag = ccBnd.isAromatic() # noqa: F841 pylint: disable=unused-variable - if (self.__debug): + if self.__debug: self.__lfh.write(" %s %d -- %s %d (%d)\n" % (at1, iat1, at2, iat2, iType)) oeBnd = self.__oeMol.NewBond(aL[iat1], aL[iat2], iType) # noqa: F841 pylint: disable=unused-variable @@ -302,16 +311,15 @@ def updatePerceptions3D(self): self.updateCIPStereoOE() def updateCIPStereoOE(self): - """ OE perception of CIP stereo - - """ + """OE perception of CIP stereo -""" for atom in self.__oeMol.GetAtoms(): OEPerceiveCIPStereo(self.__oeMol, atom) for bond in self.__oeMol.GetBonds(): - if (bond.GetOrder() == 2): + if bond.GetOrder() == 2: OEPerceiveCIPStereo(self.__oeMol, bond) - def build2D(self, setTitle=True): # pylint: disable=unused-argument + def build2D(self, setTitle=True): # noqa: ARG002 pylint: disable=unused-argument try: self.__build2D(setTitle=True) return True @@ -319,8 +327,7 @@ def build2D(self, setTitle=True): # pylint: disable=unused-argument return False def __build2D(self, setTitle=True): - """ Build molecule using existing assignments of chemical information in the CC definition. - """ + """Build molecule using existing assignments of chemical information in the CC definition.""" self.__clear() self.__oeMol = OEGraphMol() if setTitle: @@ -356,10 +363,13 @@ def __build2D(self, setTitle=True): oeAt.SetAromatic(arFlag) if chFlag: st = ccAt.getCIPStereo() - if st == 'S' or st == 'R': + if st == "S" or st == "R": oeAt.SetStringData("StereoInfo", st) - if (self.__debug): - self.__lfh.write("Atom - %s type %s atno %d isotope %d fc %d chFlag %r\n" % (atName, atType, atNo, isotope, fc, chFlag)) + if self.__debug: + self.__lfh.write( + "Atom - %s type %s atno %d isotope %d fc %d chFlag %r\n" + % (atName, atType, atNo, isotope, fc, chFlag) + ) aL.append(oeAt) bondIt = PdbxChemCompBondIt(self.__dcChemCompBond, self.__verbose, self.__lfh) @@ -369,7 +379,7 @@ def __build2D(self, setTitle=True): iat2 = aD[at2] - 1 iType = ccBnd.getIntegerType() arFlag = ccBnd.isAromatic() - if (self.__debug): + if self.__debug: self.__lfh.write(" %s %d -- %s %d (%d)\n" % (at1, iat1, at2, iat2, iType)) oeBnd = self.__oeMol.NewBond(aL[iat1], aL[iat2], iType) @@ -377,7 +387,7 @@ def __build2D(self, setTitle=True): if arFlag: oeBnd.SetIntType(5) st = ccBnd.getStereo() - if st == 'E' or st == 'Z': + if st == "E" or st == "Z": oeBnd.SetStringData("StereoInfo", st) # @@ -387,24 +397,24 @@ def __build2D(self, setTitle=True): for oeAt in self.__oeMol.GetAtoms(): st = oeAt.GetStringData("StereoInfo") - if st == 'R': + if st == "R": OESetCIPStereo(self.__oeMol, oeAt, OECIPAtomStereo_R) - elif st == 'S': + elif st == "S": OESetCIPStereo(self.__oeMol, oeAt, OECIPAtomStereo_S) for oeBnd in self.__oeMol.GetBonds(): st = oeBnd.GetStringData("StereoInfo") - if st == 'E': + if st == "E": OESetCIPStereo(self.__oeMol, oeBnd, OECIPBondStereo_E) - elif st == 'Z': + elif st == "Z": OESetCIPStereo(self.__oeMol, oeBnd, OECIPBondStereo_Z) - if (self.__debug): + if self.__debug: for ii, atm in enumerate(self.__oeMol.GetAtoms()): self.__lfh.write("OeBuildMol.build2d - atom %d %s\n" % (ii, atm.GetName())) - def importFile(self, filePath, type='2D'): # pylint: disable=redefined-builtin - """ Contruct a OEGraphMol using the content of the input file. The input - file must have a file extension recognized by the OE toolkit (e.g. .sdf) + def importFile(self, filePath, type="2D"): # noqa: A002 pylint: disable=redefined-builtin + """Contruct a OEGraphMol using the content of the input file. The input + file must have a file extension recognized by the OE toolkit (e.g. .sdf) """ ifs = oemolistream() if not ifs.open(filePath): @@ -414,25 +424,25 @@ def importFile(self, filePath, type='2D'): # pylint: disable=redefined-builtin self.__oeMol = OEMol() OEReadMolecule(ifs, self.__oeMol) # OETriposAtomNames(self.__oeMol) - if type == '2D': + if type == "2D": # run standard perceptions -- OEFindRingAtomsAndBonds(self.__oeMol) OEPerceiveChiral(self.__oeMol) for oeAt in self.__oeMol.GetAtoms(): st = oeAt.GetStringData("StereoInfo") - if st == 'R': + if st == "R": OESetCIPStereo(self.__oeMol, oeAt, OECIPAtomStereo_R) - elif st == 'S': + elif st == "S": OESetCIPStereo(self.__oeMol, oeAt, OECIPAtomStereo_S) for oeBnd in self.__oeMol.GetBonds(): st = oeBnd.GetStringData("StereoInfo") - if st == 'E': + if st == "E": OESetCIPStereo(self.__oeMol, oeBnd, OECIPBondStereo_E) - elif st == 'Z': + elif st == "Z": OESetCIPStereo(self.__oeMol, oeBnd, OECIPBondStereo_Z) - elif type == '3D': + elif type == "3D": # run standard perceptions -- # self.__oeMol.SetDimension(3) @@ -452,75 +462,63 @@ def importFile(self, filePath, type='2D'): # pylint: disable=redefined-builtin else: aC[iAtNum] = 1 # Less than idea - should have an API - atName = PdbxChemCompConstants._periodicTable[iAtNum - 1] + str(aC[iAtNum]) # pylint: disable=protected-access + atName = PdbxChemCompConstants._periodicTable[iAtNum - 1] + str(aC[iAtNum]) # noqa: SLF001 pylint: disable=protected-access atm.SetName(atName) - # xyzL = OEFloatArray(3) self.__oeMol.GetCoords(atm, xyzL) - self.__molXyzL.append((ii, atm.GetIdx(), atm.GetAtomicNum(), atm.GetName(), atm.GetType(), xyzL[0], xyzL[1], xyzL[2])) + self.__molXyzL.append( + (ii, atm.GetIdx(), atm.GetAtomicNum(), atm.GetName(), atm.GetType(), xyzL[0], xyzL[1], xyzL[2]) + ) return True def importSmiles(self, smiles): - """ Contruct a OEGraphMol using the input descriptor. - """ + """Contruct a OEGraphMol using the input descriptor.""" self.__oeMol = OEGraphMol() if OEParseSmiles(self.__oeMol, smiles): OEFindRingAtomsAndBonds(self.__oeMol) OEPerceiveChiral(self.__oeMol) return True - # return False def getGraphMolSuppressH(self): - """ Return the current constructed OE molecule with hydrogens suppressed. - """ + """Return the current constructed OE molecule with hydrogens suppressed.""" # OESuppressHydrogens(self.__oeMol, retainPolar=False,retainStereo=True,retainIsotope=True) OESuppressHydrogens(self.__oeMol) return self.__oeMol def getMol(self): - """ Return the current constructed OE molecule. - """ + """Return the current constructed OE molecule.""" return OEMol(self.__oeMol) def getCanSMILES(self): - """ Return the cannonical SMILES string derived from the current OD molecule. - """ + """Return the cannonical SMILES string derived from the current OD molecule.""" return OECreateCanSmiString(self.__oeMol) def getIsoSMILES(self): - """ Return the cannonical stereo SMILES string derived from the current OE molecule. - """ + """Return the cannonical stereo SMILES string derived from the current OE molecule.""" return OECreateIsoSmiString(self.__oeMol) def getFormula(self): - """ Return the Hill order formulat derived from the current OE molecule. - """ + """Return the Hill order formulat derived from the current OE molecule.""" return OEMolecularFormula(self.__oeMol) def getInChIKey(self): - """ Return the InChI key derived from the current OE molecule. - """ + """Return the InChI key derived from the current OE molecule.""" return OECreateInChIKey(self.__oeMol) def getInChI(self): - """ Return the InChI string derived from the current OE molecule. - """ + """Return the InChI string derived from the current OE molecule.""" return OECreateInChI(self.__oeMol) def getTitle(self): - """ Return the title assigned to the current OE molecule - """ + """Return the title assigned to the current OE molecule""" return self.__oeMol.GetTitle() def getCcId(self): - """ Return the CC id of this object - - """ + """Return the CC id of this object -""" return self.__ccId def getCoords(self): - """ Return coordinate list if a 3D molecule is built -- otherwise an empty list -- - - """ + """Return coordinate list if a 3D molecule is built -- otherwise an empty list --""" return self.__molXyzL diff --git a/wwpdb/utils/oe_util/build/OeChemCompIoUtils.py b/wwpdb/utils/oe_util/build/OeChemCompIoUtils.py index 510db85..3eb7e92 100644 --- a/wwpdb/utils/oe_util/build/OeChemCompIoUtils.py +++ b/wwpdb/utils/oe_util/build/OeChemCompIoUtils.py @@ -12,6 +12,7 @@ provided to manage the chemical component definition IO """ + __docformat__ = "restructuredtext en" __author__ = "John Westbrook" __email__ = "jwest@rcsb.rutgers.edu" @@ -27,29 +28,25 @@ # # Storage adapater can be changed here -- -if sys.platform in ['darwin']: - from mmcif_utils.persist.PdbxPyIoAdapter import \ - PdbxPyIoAdapter as PdbxIoAdapter +if sys.platform == "darwin": + from mmcif_utils.persist.PdbxPyIoAdapter import PdbxPyIoAdapter as PdbxIoAdapter else: - from mmcif_utils.persist.PdbxPyIoAdapter import \ - PdbxPyIoAdapter as PdbxIoAdapter + from mmcif_utils.persist.PdbxPyIoAdapter import PdbxPyIoAdapter as PdbxIoAdapter -class OeChemCompIoUtils(object): - ''' Construct OE mol data structures from chemical component definitions. Methods are provided - provided to manage the chemical component definition IO - ''' +class OeChemCompIoUtils: + """Construct OE mol data structures from chemical component definitions. Methods are provided + provided to manage the chemical component definition IO + """ - def __init__(self, topCachePath='/data/components/ligand-dict-v3', verbose=True, log=sys.stderr): + def __init__(self, topCachePath="/data/components/ligand-dict-v3", verbose=True, log=sys.stderr): self.__topCachePath = topCachePath self.__verbose = verbose self.__debug = False self.__lfh = log - # def getFromPathList(self, pathList, use3D=True, coordType="model", setTitle=True): - """ Return a list of OE mols constructed from the input pathList of chemical definitions. - """ + """Return a list of OE mols constructed from the input pathList of chemical definitions.""" oemList = [] try: for pth in pathList: @@ -58,29 +55,32 @@ def getFromPathList(self, pathList, use3D=True, coordType="model", setTitle=True for container in myReader.getContainerList(): oem = OeBuildMol(verbose=self.__verbose, log=self.__lfh) oem.setDebug(self.__debug) - oem.set(container.getName(), - dcChemCompAtom=container.getObj("chem_comp_atom"), - dcChemCompBond=container.getObj("chem_comp_bond")) + oem.set( + container.getName(), + dcChemCompAtom=container.getObj("chem_comp_atom"), + dcChemCompBond=container.getObj("chem_comp_bond"), + ) if use3D: oem.build3D(coordType=coordType, setTitle=setTitle) else: oem.build2D(setTitle=setTitle) - # oemList.append(oem) - # if self.__debug: self.__lfh.write("+OeChemCompIoUtils.getOeMols() Title = %s\n" % oem.getTitle()) - self.__lfh.write("+OeChemCompIoUtils.getOeMols() SMILES (canonical) = %s\n" % oem.getCanSMILES()) - self.__lfh.write("+OeChemCompIoUtils.getOeMols() SMILES (isomeric) = %s\n" % oem.getIsoSMILES()) - except Exception as e: + self.__lfh.write( + "+OeChemCompIoUtils.getOeMols() SMILES (canonical) = %s\n" % oem.getCanSMILES() + ) + self.__lfh.write( + "+OeChemCompIoUtils.getOeMols() SMILES (isomeric) = %s\n" % oem.getIsoSMILES() + ) + except Exception as e: # noqa: BLE001 if self.__verbose: self.__lfh.write("+OeChemCompIoUtils.getOeMols() Failed %s\n" % str(e)) traceback.print_exc(file=self.__lfh) return oemList def getFromIdList(self, idList, use3D=True, coordType="model", setTitle=True): - """ Return a list of OE mols constructed from the input Id of chemical definitions. - """ + """Return a list of OE mols constructed from the input Id of chemical definitions.""" pathList = [] for ide in idList: if len(ide) < 1: @@ -88,10 +88,10 @@ def getFromIdList(self, idList, use3D=True, coordType="model", setTitle=True): idU = str(ide).upper() if idU.startswith("PRDCC_"): hashd = idU[-1] - pth = os.path.join(self.__topCachePath, hashd, idU + '.cif') + pth = os.path.join(self.__topCachePath, hashd, idU + ".cif") else: hashd = self.__getCcdHash(idU) - pth = os.path.join(self.__topCachePath, hashd, idU, idU + '.cif') + pth = os.path.join(self.__topCachePath, hashd, idU, idU + ".cif") pathList.append(pth) return self.getFromPathList(pathList, use3D=use3D, coordType=coordType, setTitle=setTitle) diff --git a/wwpdb/utils/oe_util/build/OeDescriptorUtils.py b/wwpdb/utils/oe_util/build/OeDescriptorUtils.py index fca5bdc..17aa4f9 100644 --- a/wwpdb/utils/oe_util/build/OeDescriptorUtils.py +++ b/wwpdb/utils/oe_util/build/OeDescriptorUtils.py @@ -11,6 +11,7 @@ Utilities to standardize chemical descriptors """ + __docformat__ = "restructuredtext en" __author__ = "John Westbrook" __email__ = "jwest@rcsb.rutgers.edu" @@ -24,21 +25,18 @@ logger = logging.getLogger(__name__) -class OeDescriptorUtils(object): - ''' Utilities to standardize chemical descriptors - ''' +class OeDescriptorUtils: + """Utilities to standardize chemical descriptors""" def __init__(self): pass - # - def standardizeSmiles(self, smiles, type="ISOMERIC"): # pylint: disable=redefined-builtin - """ Return a standardized SMILES (type) or None - """ + def standardizeSmiles(self, smiles, type="ISOMERIC"): # noqa: A002 pylint: disable=redefined-builtin + """Return a standardized SMILES (type) or None""" smilesOut = None try: mol = oechem.OEGraphMol() - if (oechem.OEParseSmiles(mol, smiles) == 1): + if oechem.OEParseSmiles(mol, smiles) == 1: oechem.OEAssignAromaticFlags(mol) if type == "CANNONICAL": smilesOut = oechem.OECreateCanSmiString(mol) diff --git a/wwpdb/utils/oe_util/build/OePersist.py b/wwpdb/utils/oe_util/build/OePersist.py index 910110c..7ae87dc 100644 --- a/wwpdb/utils/oe_util/build/OePersist.py +++ b/wwpdb/utils/oe_util/build/OePersist.py @@ -10,6 +10,7 @@ Class supporting persistant storage of serialized OE molecules. """ + __docformat__ = "restructuredtext en" __author__ = "John Westbrook" __email__ = "jwest@rcsb.rutgers.edu" @@ -17,29 +18,22 @@ __version__ = "V0.01" -import shelve +import pickle # noqa: S403 +import shelve # noqa: S403 import shutil import sys import traceback -try: - import cPickle as pickle -except ImportError: - import pickle - from mmcif_utils.persist.LockFile import LockFile -class OePersist(object): - """ Persistent storage for instances of OE molecules. - - """ +class OePersist: + """Persistent storage for instances of OE molecules.""" def __init__(self, verbose=True, log=sys.stderr): self.__verbose = verbose self.__debug = True self.__lfh = log - # self.__moleculeList = [] self.__moleculeNameList = [] @@ -50,115 +44,111 @@ def __init__(self, verbose=True, log=sys.stderr): # placeholder for LockFile object for open/close methods self.__lockObj = None self.__isExpired = True - # self.__db = None def __reIndex(self): - """ Rebuild name and type lists from molecule object list. - """ - # + """Rebuild name and type lists from molecule object list.""" self.__moleculeNameList = [] for molecule in self.__moleculeList: - self.__moleculeNameList.append(molecule['name']) - # + self.__moleculeNameList.append(molecule["name"]) self.__isExpired = False def __getMoleculeIndex(self, name): try: - if (self.__isExpired): + if self.__isExpired: self.__reIndex() return self.__moleculeNameList.index(name) except: # noqa: E722 pylint: disable=bare-except return None def setMoleculeList(self, moleculeList=None): - """ Initialize molecule data in the internal molecule to be persisted to the data store. - """ + """Initialize molecule data in the internal molecule to be persisted to the data store.""" try: self.__moleculeList = moleculeList self.__isExpired = True - if (self.__debug): + if self.__debug: self.__lfh.write("+OePersist.setMoleculeList() - Container list length %d\n" % len(self.__moleculeList)) return True - except Exception as e: - if (self.__verbose): + except Exception as e: # noqa: BLE001 + if self.__verbose: self.__lfh.write("+ERROR- OePersist.setMoleculeList() initialization failed %s\n" % str(e)) - if (self.__debug): + if self.__debug: traceback.print_exc(file=self.__lfh) return False def appendMoleculeList(self, moleculeList=None): - """ Append container data to the internal moleculeList to be persisted to the data store. - """ + """Append container data to the internal moleculeList to be persisted to the data store.""" try: self.__moleculeList.extend(moleculeList) self.__isExpired = True - if (self.__debug): - self.__lfh.write("+OePersist.appendMoleculeList() - Container list length %d\n" % len(self.__moleculeList)) + if self.__debug: + self.__lfh.write( + "+OePersist.appendMoleculeList() - Container list length %d\n" % len(self.__moleculeList) + ) return True - except Exception as e: - if (self.__verbose): + except Exception as e: # noqa: BLE001 + if self.__verbose: self.__lfh.write("+ERROR- OePersist.appendMoleculeList() initialization failed %s\n" % str(e)) - if (self.__debug): + if self.__debug: traceback.print_exc(file=self.__lfh) return False def getMolecule(self, moleculeName): - """ Return the molecule from internal MoleculeList corresponding to the input molecule name. + """Return the molecule from internal MoleculeList corresponding to the input molecule name. - **Note that this method is NOT directly fetching data from the internal store. First recover the - the store to internal storage before calling this method. + **Note that this method is NOT directly fetching data from the internal store. First recover the + the store to internal storage before calling this method. """ idx = self.__getMoleculeIndex(moleculeName) if idx is not None: return self.__moleculeList[idx] - else: - return None + return None def getMoleculeList(self): - """ Return the current molecule list. - """ + """Return the current molecule list.""" return self.__moleculeList def getMoleculeNameList(self): - """ Return the current list of molecule names. - """ - if (self.__isExpired): + """Return the current list of molecule names.""" + if self.__isExpired: self.__reIndex() return self.__moleculeNameList - # - def open(self, dbFileName="my.db", flag='r'): - """ Open the persistent store with the input database file name and access mode. + def open(self, dbFileName="my.db", flag="r"): + """Open the persistent store with the input database file name and access mode. - flag = 'r read-only' - 'c/n new/create' - 'w read/write' + flag = 'r read-only' + 'c/n new/create' + 'w read/write' """ try: - self.__lockObj = LockFile(dbFileName, timeoutSeconds=self.__timeoutSeconds, retrySeconds=self.__retrySeconds, - verbose=self.__verbose, log=self.__lfh) + self.__lockObj = LockFile( + dbFileName, + timeoutSeconds=self.__timeoutSeconds, + retrySeconds=self.__retrySeconds, + verbose=self.__verbose, + log=self.__lfh, + ) self.__lockObj.acquire() - self.__db = shelve.open(dbFileName, flag=flag, protocol=pickle.HIGHEST_PROTOCOL) + self.__db = shelve.open(dbFileName, flag=flag, protocol=pickle.HIGHEST_PROTOCOL) # noqa: S301 return True - except Exception as e: + except Exception as e: # noqa: BLE001 if self.__lockObj is not None: self.__lockObj.release() - if (self.__verbose): + if self.__verbose: self.__lfh.write("+ERROR- OePersist.open() write failed for file %s %s\n" % (dbFileName, str(e))) - if (self.__debug): + if self.__debug: traceback.print_exc(file=self.__lfh) return False def getStoreMoleculeIndex(self): try: - return self.__db['__index__'] + return self.__db["__index__"] except: # noqa: E722 pylint: disable=bare-except return [] def close(self): - """ Close the persistent store - """ + """Close the persistent store""" try: self.__db.close() if self.__lockObj is not None: @@ -171,131 +161,159 @@ def close(self): return False def moveStore(self, srcDbFilePath, dstDbFilePath): - """ Move source store to destination store with destination locking. + """Move source store to destination store with destination locking. - No locking is performed on the source file. + No locking is performed on the source file. """ - with LockFile(dstDbFilePath, timeoutSeconds=self.__timeoutSeconds, retrySeconds=self.__retrySeconds, - verbose=self.__verbose, log=self.__lfh) as lf: # noqa: F841 pylint: disable=unused-variable + with LockFile( + dstDbFilePath, + timeoutSeconds=self.__timeoutSeconds, + retrySeconds=self.__retrySeconds, + verbose=self.__verbose, + log=self.__lfh, + ) as lf: # noqa: F841 pylint: disable=unused-variable retVal = self.__moveStore(srcDbFilePath, dstDbFilePath) return retVal def store(self, dbFileName="my.db"): - """ Store the current molecule list in persistent database. - """ - with LockFile(dbFileName, timeoutSeconds=self.__timeoutSeconds, retrySeconds=self.__retrySeconds, - verbose=self.__verbose, log=self.__lfh) as lf: # noqa: F841 pylint: disable=unused-variable + """Store the current molecule list in persistent database.""" + with LockFile( + dbFileName, + timeoutSeconds=self.__timeoutSeconds, + retrySeconds=self.__retrySeconds, + verbose=self.__verbose, + log=self.__lfh, + ) as lf: # noqa: F841 pylint: disable=unused-variable retVal = self.__storeShelve(dbFileName) return retVal def recover(self, dbFileName="my.db"): - """ Recover the stored state to the current in-memory molecule representation. - """ - with LockFile(dbFileName, timeoutSeconds=self.__timeoutSeconds, retrySeconds=self.__retrySeconds, - verbose=self.__verbose, log=self.__lfh) as lf: # noqa: F841 pylint: disable=unused-variable + """Recover the stored state to the current in-memory molecule representation.""" + with LockFile( + dbFileName, + timeoutSeconds=self.__timeoutSeconds, + retrySeconds=self.__retrySeconds, + verbose=self.__verbose, + log=self.__lfh, + ) as lf: # noqa: F841 pylint: disable=unused-variable retVal = self.__recoverShelve(dbFileName) return retVal def getIndex(self, dbFileName="my.db"): - """ Recover the index of the persistent store. - """ - with LockFile(dbFileName, timeoutSeconds=self.__timeoutSeconds, retrySeconds=self.__retrySeconds, - verbose=self.__verbose, log=self.__lfh) as lf: # noqa: F841 pylint: disable=unused-variable + """Recover the index of the persistent store.""" + with LockFile( + dbFileName, + timeoutSeconds=self.__timeoutSeconds, + retrySeconds=self.__retrySeconds, + verbose=self.__verbose, + log=self.__lfh, + ) as lf: # noqa: F841 pylint: disable=unused-variable retVal = self.__indexShelve(dbFileName) return retVal def updateOneMolecule(self, inputMolecule, dbFileName="my.db"): - """ Update or append a molecule to an existing store. - """ - with LockFile(dbFileName, timeoutSeconds=self.__timeoutSeconds, retrySeconds=self.__retrySeconds, - verbose=self.__verbose, log=self.__lfh) as lf: # noqa: F841 pylint: disable=unused-variable + """Update or append a molecule to an existing store.""" + with LockFile( + dbFileName, + timeoutSeconds=self.__timeoutSeconds, + retrySeconds=self.__retrySeconds, + verbose=self.__verbose, + log=self.__lfh, + ) as lf: # noqa: F841 pylint: disable=unused-variable retVal = self.__updateMoleculeShelve(dbFileName=dbFileName, inputMolecule=inputMolecule) return retVal def updateMoleculeList(self, dbFileName="my.db", moleculeList=None): - """ Update or append the contents of the input molecule list to an existing store. - """ - with LockFile(dbFileName, timeoutSeconds=self.__timeoutSeconds, retrySeconds=self.__retrySeconds, - verbose=self.__verbose, log=self.__lfh) as lf: # noqa: F841 pylint: disable=unused-variable + """Update or append the contents of the input molecule list to an existing store.""" + with LockFile( + dbFileName, + timeoutSeconds=self.__timeoutSeconds, + retrySeconds=self.__retrySeconds, + verbose=self.__verbose, + log=self.__lfh, + ) as lf: # noqa: F841 pylint: disable=unused-variable retVal = self.__updateMoleculeListShelve(dbFileName=dbFileName, updateMoleculeList=moleculeList) return retVal - # def fetchOneMolecule(self, dbFileName="my.db", moleculeName=None): - """ Fetch a single object from a named molecule. This is atomic operation with respect to the store. - """ - with LockFile(dbFileName, timeoutSeconds=self.__timeoutSeconds, retrySeconds=self.__retrySeconds, - verbose=self.__verbose, log=self.__lfh) as lf: # noqa: F841 pylint: disable=unused-variable + """Fetch a single object from a named molecule. This is atomic operation with respect to the store.""" + with LockFile( + dbFileName, + timeoutSeconds=self.__timeoutSeconds, + retrySeconds=self.__retrySeconds, + verbose=self.__verbose, + log=self.__lfh, + ) as lf: # noqa: F841 pylint: disable=unused-variable retVal = self.__fetchOneMoleculeShelve(dbFileName, moleculeName) return retVal def fetchMolecule(self, moleculeName=None): - """ Fetch molecule from an open store. + """Fetch molecule from an open store. - Use this method to extract multiple molecules from an open store. + Use this method to extract multiple molecules from an open store. """ return self.__fetchMoleculeShelve(moleculeName) def __moveStore(self, src, dst): - """ Internal method to perform file move. - """ + """Internal method to perform file move.""" try: shutil.move(src, dst) return True - except Exception as e: - if (self.__verbose): + except Exception as e: # noqa: BLE001 + if self.__verbose: self.__lfh.write("+ERROR- OePersist.__moveStore() move failed for file %s %s\n" % (src, str(e))) - if (self.__debug): + if self.__debug: traceback.print_exc(file=self.__lfh) return False def __storeShelve(self, dbFileName="my.db"): - """ Create a new persistent store using the internal molecule list. - """ + """Create a new persistent store using the internal molecule list.""" try: - if (self.__isExpired): + if self.__isExpired: self.__reIndex() - db = shelve.open(dbFileName, flag='c', protocol=pickle.HIGHEST_PROTOCOL) - db['__index__'] = self.__moleculeNameList - if (self.__debug): + db = shelve.open(dbFileName, flag="c", protocol=pickle.HIGHEST_PROTOCOL) # noqa: S301 + db["__index__"] = self.__moleculeNameList + if self.__debug: self.__lfh.write("+OePersist.__storeShelve() - Molecule list length %d\n" % len(self.__moleculeList)) for molecule in self.__moleculeList: - ky = molecule['name'] + ky = molecule["name"] db[ky] = molecule db.close() return True - except Exception as e: - if (self.__verbose): - self.__lfh.write("+ERROR- OePersist.__storeShelve() shelve store failed for file %s %s\n" % (dbFileName, str(e))) - if (self.__debug): + except Exception as e: # noqa: BLE001 + if self.__verbose: + self.__lfh.write( + "+ERROR- OePersist.__storeShelve() shelve store failed for file %s %s\n" % (dbFileName, str(e)) + ) + if self.__debug: traceback.print_exc(file=self.__lfh) return False def __indexShelve(self, dbFileName="my.db"): - """ Recover the index of molecules in the persistent store. - """ + """Recover the index of molecules in the persistent store.""" try: - db = shelve.open(dbFileName, flag='r', protocol=pickle.HIGHEST_PROTOCOL) - self.__moleculeNameList = db['__index__'] + db = shelve.open(dbFileName, flag="r", protocol=pickle.HIGHEST_PROTOCOL) # noqa: S301 + self.__moleculeNameList = db["__index__"] db.close() self.__isExpired = False return self.__moleculeNameList - except Exception as e: - if (self.__verbose): - self.__lfh.write("+ERROR- OePersist.__indexShelve() shelve index failed for file %s %s\n" % (dbFileName, str(e))) - if (self.__debug): + except Exception as e: # noqa: BLE001 + if self.__verbose: + self.__lfh.write( + "+ERROR- OePersist.__indexShelve() shelve index failed for file %s %s\n" % (dbFileName, str(e)) + ) + if self.__debug: traceback.print_exc(file=self.__lfh) return {} def __recoverShelve(self, dbFileName="my.db"): - """ Recover the list of molecules from the persistent store. - """ + """Recover the list of molecules from the persistent store.""" try: self.__moleculeList = [] - db = shelve.open(dbFileName, flag='r', protocol=pickle.HIGHEST_PROTOCOL) - self.__moleculeNameList = db['__index__'] - if (self.__debug): + db = shelve.open(dbFileName, flag="r", protocol=pickle.HIGHEST_PROTOCOL) # noqa: S301 + self.__moleculeNameList = db["__index__"] + if self.__debug: self.__lfh.write("+OePersist.__recoverShelve() - Molecule name list %r\n" % self.__moleculeNameList) for moleculeName in self.__moleculeNameList: @@ -303,64 +321,67 @@ def __recoverShelve(self, dbFileName="my.db"): db.close() return True - except Exception as e: - if (self.__verbose): - self.__lfh.write("+ERROR- OePersist.__recoverShelve() shelve recover failed for file %s %s\n" % (dbFileName, str(e))) - if (self.__debug): + except Exception as e: # noqa: BLE001 + if self.__verbose: + self.__lfh.write( + "+ERROR- OePersist.__recoverShelve() shelve recover failed for file %s %s\n" % (dbFileName, str(e)) + ) + if self.__debug: traceback.print_exc(file=self.__lfh) return False - def __fetchOneMoleculeShelve(self, dbFileName="my.db", moleculeName=None,): - """ Recover the molecule from from persistent store corresponding to the - input molecule name. + def __fetchOneMoleculeShelve( + self, + dbFileName="my.db", + moleculeName=None, + ): + """Recover the molecule from from persistent store corresponding to the + input molecule name. """ try: - # - db = shelve.open(dbFileName, flag='r', protocol=pickle.HIGHEST_PROTOCOL) + db = shelve.open(dbFileName, flag="r", protocol=pickle.HIGHEST_PROTOCOL) # noqa: S301 ky = moleculeName molecule = db[ky] db.close() return molecule - except Exception as e: - if (self.__verbose): - self.__lfh.write("+ERROR- OePersist.__fetchOneMoleculeShelve() shelve fetch failed for file %s %s %s\n" - % (dbFileName, moleculeName, str(e))) - if (self.__debug): + except Exception as e: # noqa: BLE001 + if self.__verbose: + self.__lfh.write( + "+ERROR- OePersist.__fetchOneMoleculeShelve() shelve fetch failed for file %s %s %s\n" + % (dbFileName, moleculeName, str(e)) + ) + if self.__debug: traceback.print_exc(file=self.__lfh) return None def __fetchMoleculeShelve(self, moleculeName=None): - """ Recover the molecule from from persistent store corresponding to the - input molecule name. + """Recover the molecule from from persistent store corresponding to the + input molecule name. - shelve store must be opened from prior call. + shelve store must be opened from prior call. """ try: - # ky = moleculeName molecule = self.__db[ky] return molecule - except Exception as e: - if (self.__debug): - self.__lfh.write("+ERROR- OePersist.__fetchObjectShelve() shelve fetch failed %s %s\n" - % (moleculeName, str(e))) - if (self.__debug): + except Exception as e: # noqa: BLE001 + if self.__debug: + self.__lfh.write( + "+ERROR- OePersist.__fetchObjectShelve() shelve fetch failed %s %s\n" % (moleculeName, str(e)) + ) + if self.__debug: traceback.print_exc(file=self.__lfh) - # return None def __updateMoleculeShelve(self, dbFileName="my.db", inputMolecule=None): - """ Update/append the single input molecule object into the persistent store. - """ + """Update/append the single input molecule object into the persistent store.""" try: - # - moleculeName = inputMolecule['name'] - # - db = shelve.open(dbFileName, flag='w', protocol=pickle.HIGHEST_PROTOCOL) + moleculeName = inputMolecule["name"] + db = shelve.open(dbFileName, flag="w", protocol=pickle.HIGHEST_PROTOCOL) # noqa: S301 # # get molecule index - # - moleculeNameList = db['__index__'] + moleculeNameList = db["__index__"] # # Modify or append input molecule -- # @@ -372,7 +393,7 @@ def __updateMoleculeShelve(self, dbFileName="my.db", inputMolecule=None): # # store updated molecule index lists - # - db['__index__'] = moleculeNameList + db["__index__"] = moleculeNameList # # ------------------------------------------ # Update the object contents -- @@ -381,26 +402,27 @@ def __updateMoleculeShelve(self, dbFileName="my.db", inputMolecule=None): db[ky] = inputMolecule db.close() return True - except Exception as e: - if (self.__verbose): - self.__lfh.write("+ERROR- OePersist.__updateObjectShelve() update failed for file %s %s %s\n" % (dbFileName, moleculeName, str(e))) - if (self.__debug): + except Exception as e: # noqa: BLE001 + if self.__verbose: + self.__lfh.write( + "+ERROR- OePersist.__updateObjectShelve() update failed for file %s %s %s\n" + % (dbFileName, moleculeName, str(e)) + ) + if self.__debug: traceback.print_exc(file=self.__lfh) return False def __updateMoleculeListShelve(self, dbFileName="my.db", updateMoleculeList=None): - """ Update/append the contents of the input molecule list into an existing persistent store. - """ + """Update/append the contents of the input molecule list into an existing persistent store.""" try: - db = shelve.open(dbFileName, flag='w', protocol=pickle.HIGHEST_PROTOCOL) + db = shelve.open(dbFileName, flag="w", protocol=pickle.HIGHEST_PROTOCOL) # noqa: S301 # # get molecule index - # - moleculeNameList = db['__index__'] + moleculeNameList = db["__index__"] for updateMolecule in updateMoleculeList: - # - updateMoleculeName = updateMolecule['name'] + updateMoleculeName = updateMolecule["name"] # # Modify or append input molecule -- # @@ -412,17 +434,19 @@ def __updateMoleculeListShelve(self, dbFileName="my.db", updateMoleculeList=None # # Store updated molecule index lists - # - db['__index__'] = moleculeNameList + db["__index__"] = moleculeNameList ky = updateMoleculeName db[ky] = updateMolecule - # db.close() return True - except Exception as e: - if (self.__verbose): - self.__lfh.write("+ERROR- OePersist.__updateMoleculeListShelve() update failed for store %s %s\n" % (dbFileName, str(e))) - if (self.__debug): + except Exception as e: # noqa: BLE001 + if self.__verbose: + self.__lfh.write( + "+ERROR- OePersist.__updateMoleculeListShelve() update failed for store %s %s\n" + % (dbFileName, str(e)) + ) + if self.__debug: traceback.print_exc(file=self.__lfh) return False diff --git a/wwpdb/utils/oe_util/build/PdbxBuildChemComp.py b/wwpdb/utils/oe_util/build/PdbxBuildChemComp.py index 7107cc9..8d779f6 100644 --- a/wwpdb/utils/oe_util/build/PdbxBuildChemComp.py +++ b/wwpdb/utils/oe_util/build/PdbxBuildChemComp.py @@ -12,6 +12,7 @@ Utilities to build chemical component definitions from OE molecule objects. """ + __docformat__ = "restructuredtext en" __author__ = "John Westbrook" __email__ = "jwest@rcsb.rutgers.edu" @@ -24,22 +25,32 @@ from mmcif_utils.style.ChemCompCategoryStyle import ChemCompCategoryStyle from mmcif_utils.style.PdbxStyleIoUtil import PdbxStyleIoUtil -from openeye.oechem import (OECalculateMolecularWeight, - OECIPAtomStereo_NotStereo, OECIPAtomStereo_R, - OECIPAtomStereo_S, OECIPAtomStereo_UnspecStereo, - OECIPBondStereo_E, OECIPBondStereo_NotStereo, - OECIPBondStereo_UnspecStereo, OECIPBondStereo_Z, - OECreateCanSmiString, OECreateInChI, - OECreateInChIKey, OECreateIsoSmiString, - OEGetAtomicSymbol, OEMol, OEMolecularFormula, - OEPerceiveCIPStereo, OEWriteConstMolecule, - OEWriteMolecule, oemolostream) +from openeye.oechem import ( + OECalculateMolecularWeight, + OECIPAtomStereo_NotStereo, + OECIPAtomStereo_R, + OECIPAtomStereo_S, + OECIPAtomStereo_UnspecStereo, + OECIPBondStereo_E, + OECIPBondStereo_NotStereo, + OECIPBondStereo_UnspecStereo, + OECIPBondStereo_Z, + OECreateCanSmiString, + OECreateInChI, + OECreateInChIKey, + OECreateIsoSmiString, + OEGetAtomicSymbol, + OEMol, + OEMolecularFormula, + OEPerceiveCIPStereo, + OEWriteConstMolecule, + OEWriteMolecule, + oemolostream, +) class PdbxBuildChemComp(PdbxStyleIoUtil): - ''' Methods to build chemical component definitions from OE molecule objects. - - ''' + """Methods to build chemical component definitions from OE molecule objects.""" def __init__(self, verbose=True, log=sys.stderr): super(PdbxBuildChemComp, self).__init__(styleObject=ChemCompCategoryStyle(), verbose=verbose, log=log) @@ -47,19 +58,18 @@ def __init__(self, verbose=True, log=sys.stderr): # self.__verbose = verbose # self.__debug = False self.__lfh = log - # - def getCategory(self, catName='chem_comp'): + def getCategory(self, catName="chem_comp"): return self.getItemDictList(catName) - def getChemCompCategory(self, catName='chem_comp'): + def getChemCompCategory(self, catName="chem_comp"): return self.getItemDictList(catName) def getChemCompDict(self): - return self.getItemDictList(catName='chem_comp') + return self.getItemDictList(catName="chem_comp") def getBondList(self): - return self.getRowDataList(catName='chem_comp_bond') + return self.getRowDataList(catName="chem_comp_bond") def complyStyle(self): return self.testStyleComplete(self.__lfh) @@ -76,43 +86,36 @@ def update(self, catName, attributeName, value, iRow=0): def write(self, filePath): return self.writeFile(filePath) - # def setOeMol(self, oeMol, ccId, name=None, missingModelXyz=True): ccIdU = str(ccId).strip().upper() self.newContainer(containerName=ccIdU, overWrite=True) self.setContainer(containerName=ccIdU) - # - self.newCategory('chem_comp', container=None, overWrite=True) - # + self.newCategory("chem_comp", container=None, overWrite=True) formula = OEMolecularFormula(oeMol) fCharge = self.__getFormalCharge(oeMol) fWeight = OECalculateMolecularWeight(oeMol) # JDW - rowD = self.__makeChemCompCategory(ccIdU, name=name, formula=formula, charge=fCharge, fW=fWeight, site='RCSB', missingModelXyz=missingModelXyz) - self.updateRowByAttribute(rowD, 'chem_comp', iRow=0) - # - self.newCategory('chem_comp_atom', container=None, overWrite=True) + rowD = self.__makeChemCompCategory( + ccIdU, name=name, formula=formula, charge=fCharge, fW=fWeight, site="RCSB", missingModelXyz=missingModelXyz + ) + self.updateRowByAttribute(rowD, "chem_comp", iRow=0) + self.newCategory("chem_comp_atom", container=None, overWrite=True) rowDL = self.__makeChemCompAtomCategory(ccIdU, oeMol) for ii, rowD in enumerate(rowDL): - self.updateRowByAttribute(rowD, 'chem_comp_atom', iRow=ii) - # - self.newCategory('chem_comp_bond', container=None, overWrite=True) + self.updateRowByAttribute(rowD, "chem_comp_atom", iRow=ii) + self.newCategory("chem_comp_bond", container=None, overWrite=True) rowDL = self.__makeChemCompBondCategory(ccIdU, oeMol) for ii, rowD in enumerate(rowDL): - self.updateRowByAttribute(rowD, 'chem_comp_bond', iRow=ii) - # - self.newCategory('pdbx_chem_comp_descriptor', container=None, overWrite=True) + self.updateRowByAttribute(rowD, "chem_comp_bond", iRow=ii) + self.newCategory("pdbx_chem_comp_descriptor", container=None, overWrite=True) rowDL = self.__makeChemCompDescriptorCategory(ccIdU, oeMol) for ii, rowD in enumerate(rowDL): - self.updateRowByAttribute(rowD, 'pdbx_chem_comp_descriptor', iRow=ii) - # - self.newCategory('pdbx_chem_comp_audit', container=None, overWrite=True) + self.updateRowByAttribute(rowD, "pdbx_chem_comp_descriptor", iRow=ii) + self.newCategory("pdbx_chem_comp_audit", container=None, overWrite=True) rowD = self.__makeChemCompAuditRow(ccIdU) - self.updateRowByAttribute(rowD, 'pdbx_chem_comp_audit', iRow=0) - # - # + self.updateRowByAttribute(rowD, "pdbx_chem_comp_audit", iRow=0) - def writeOther(self, oeMol, filePath, title='None', constantMol=False): + def writeOther(self, oeMol, filePath, title="None", constantMol=False): try: ofs = oemolostream() ofs.open(filePath) @@ -124,7 +127,7 @@ def writeOther(self, oeMol, filePath, title='None', constantMol=False): else: OEWriteMolecule(ofs, myMol) return True - except Exception as e: + except Exception as e: # noqa: BLE001 self.__lfh.write("+PdbxBuildChemComp.writeOther FAILING %s\n" % str(e)) traceback.print_exc(file=self.__lfh) return False @@ -135,161 +138,154 @@ def __getFormalCharge(self, oeMol): fCharge += atom.GetFormalCharge() return fCharge - def __makeChemCompAuditRow(self, ccId, action='CREATE', date=None, processingSite='RCSB', annotator='?', details='?'): - ''' - loop_ - _pdbx_chem_comp_audit.comp_id - _pdbx_chem_comp_audit.action_type - _pdbx_chem_comp_audit.date - _pdbx_chem_comp_audit.processing_site - _pdbx_chem_comp_audit.annotator - _pdbx_chem_comp_audit.details - ARG "Create component" 1999-07-08 RCSB ? ? + def __makeChemCompAuditRow( + self, ccId, action="CREATE", date=None, processingSite="RCSB", annotator="?", details="?" + ): + """ + loop_ + _pdbx_chem_comp_audit.comp_id + _pdbx_chem_comp_audit.action_type + _pdbx_chem_comp_audit.date + _pdbx_chem_comp_audit.processing_site + _pdbx_chem_comp_audit.annotator + _pdbx_chem_comp_audit.details + ARG "Create component" 1999-07-08 RCSB ? ? - ''' + """ aRow = {} - aRow['comp_id'] = ccId - aRow['action_type'] = action + aRow["comp_id"] = ccId + aRow["action_type"] = action if date is None: date = time.strftime("%Y-%m-%d", time.localtime()) - aRow['date'] = date - aRow['processing_site'] = processingSite - aRow['annotator'] = annotator - aRow['details'] = details - # + aRow["date"] = date + aRow["processing_site"] = processingSite + aRow["annotator"] = annotator + aRow["details"] = details return aRow def __makeChemCompDescriptorCategory(self, ccId, oeMol): - ''' - loop_ - _pdbx_chem_comp_descriptor.comp_id - _pdbx_chem_comp_descriptor.type - _pdbx_chem_comp_descriptor.program - _pdbx_chem_comp_descriptor.program_version - _pdbx_chem_comp_descriptor.descriptor - ARG SMILES ACDLabs 10.04 "O=C(O)C(N)CCCN\\C(=[NH2+])N" - ARG SMILES_CANONICAL CACTVS 3.341 "N[C@@H](CCCNC(N)=[NH2+])C(O)=O" - ARG SMILES CACTVS 3.341 "N[CH](CCCNC(N)=[NH2+])C(O)=O" - ARG SMILES_CANONICAL "OpenEye OEToolkits" 1.5.0 "C(C[C@@H](C(=O)O)N)CNC(=[NH2+])N" - ARG SMILES "OpenEye OEToolkits" 1.5.0 "C(CC(C(=O)O)N)CNC(=[NH2+])N" - ARG InChI InChI 1.03 "InChI=1S/C6H14N4O2/c7-4(5(11)12)2-1-3-1..... " - ARG InChIKey InChI 1.03 ODKSFYDXXFIFQN-BYPYZUCNSA-O - # - ''' - rowL = [] + """ + loop_ + _pdbx_chem_comp_descriptor.comp_id + _pdbx_chem_comp_descriptor.type + _pdbx_chem_comp_descriptor.program + _pdbx_chem_comp_descriptor.program_version + _pdbx_chem_comp_descriptor.descriptor + ARG SMILES ACDLabs 10.04 "O=C(O)C(N)CCCN\\C(=[NH2+])N" + ARG SMILES_CANONICAL CACTVS 3.341 "N[C@@H](CCCNC(N)=[NH2+])C(O)=O" + ARG SMILES CACTVS 3.341 "N[CH](CCCNC(N)=[NH2+])C(O)=O" + ARG SMILES_CANONICAL "OpenEye OEToolkits" 1.5.0 "C(C[C@@H](C(=O)O)N)CNC(=[NH2+])N" + ARG SMILES "OpenEye OEToolkits" 1.5.0 "C(CC(C(=O)O)N)CNC(=[NH2+])N" + ARG InChI InChI 1.03 "InChI=1S/C6H14N4O2/c7-4(5(11)12)2-1-3-1..... " + ARG InChIKey InChI 1.03 ODKSFYDXXFIFQN-BYPYZUCNSA-O # + """ + rowL = [] aRow = {} - aRow['comp_id'] = ccId - aRow['type'] = 'SMILES_CANONICAL' - aRow['program'] = "OpenEye OEToolkits" - aRow['program_version'] = '2016.2' - aRow['descriptor'] = OECreateIsoSmiString(oeMol) + aRow["comp_id"] = ccId + aRow["type"] = "SMILES_CANONICAL" + aRow["program"] = "OpenEye OEToolkits" + aRow["program_version"] = "2016.2" + aRow["descriptor"] = OECreateIsoSmiString(oeMol) rowL.append(aRow) - # aRow = {} - aRow['comp_id'] = ccId - aRow['type'] = 'SMILES' - aRow['program'] = "OpenEye OEToolkits" - aRow['program_version'] = '2016.2' - aRow['descriptor'] = OECreateCanSmiString(oeMol) + aRow["comp_id"] = ccId + aRow["type"] = "SMILES" + aRow["program"] = "OpenEye OEToolkits" + aRow["program_version"] = "2016.2" + aRow["descriptor"] = OECreateCanSmiString(oeMol) rowL.append(aRow) - # aRow = {} - aRow['comp_id'] = ccId - aRow['type'] = 'InChI' - aRow['program'] = "OpenEye OEToolkits" - aRow['program_version'] = '2016.2' - aRow['descriptor'] = OECreateInChI(oeMol) + aRow["comp_id"] = ccId + aRow["type"] = "InChI" + aRow["program"] = "OpenEye OEToolkits" + aRow["program_version"] = "2016.2" + aRow["descriptor"] = OECreateInChI(oeMol) rowL.append(aRow) - # aRow = {} - aRow['comp_id'] = ccId - aRow['type'] = 'InChIKey' - aRow['program'] = "OpenEye OEToolkits" - aRow['program_version'] = '2016.2' - aRow['descriptor'] = OECreateInChIKey(oeMol) + aRow["comp_id"] = ccId + aRow["type"] = "InChIKey" + aRow["program"] = "OpenEye OEToolkits" + aRow["program_version"] = "2016.2" + aRow["descriptor"] = OECreateInChIKey(oeMol) rowL.append(aRow) - # return rowL - def __makeChemCompCategory(self, ccId, name=None, formula=None, charge=None, fW=None, site='RCSB', missingModelXyz=False): - # + def __makeChemCompCategory( + self, ccId, name=None, formula=None, charge=None, fW=None, site="RCSB", missingModelXyz=False + ): lt = time.strftime("%Y-%m-%d", time.localtime()) ccRow = {} - ccRow['id'] = ccId + ccRow["id"] = ccId if name is not None: - ccRow['name'] = name + ccRow["name"] = name else: - ccRow['name'] = '?' - ccRow['type'] = 'NON-POLYMER' - ccRow['pdbx_type'] = '?' + ccRow["name"] = "?" + ccRow["type"] = "NON-POLYMER" + ccRow["pdbx_type"] = "?" if formula is not None: - ccRow['formula'] = formula + ccRow["formula"] = formula else: - ccRow['formula'] = '?' - ccRow['mon_nstd_parent_comp_id'] = '?' - ccRow['pdbx_synonyms'] = '?' + ccRow["formula"] = "?" + ccRow["mon_nstd_parent_comp_id"] = "?" + ccRow["pdbx_synonyms"] = "?" if charge is not None: - ccRow['pdbx_formal_charge'] = charge + ccRow["pdbx_formal_charge"] = charge else: - ccRow['pdbx_formal_charge'] = '?' - ccRow['pdbx_ambiguous_flag'] = 'N' - ccRow['pdbx_initial_date'] = lt - ccRow['pdbx_modified_date'] = lt - ccRow['pdbx_release_status'] = 'HOLD' - ccRow['pdbx_replaced_by'] = '?' - ccRow['pdbx_replaces'] = '?' + ccRow["pdbx_formal_charge"] = "?" + ccRow["pdbx_ambiguous_flag"] = "N" + ccRow["pdbx_initial_date"] = lt + ccRow["pdbx_modified_date"] = lt + ccRow["pdbx_release_status"] = "HOLD" + ccRow["pdbx_replaced_by"] = "?" + ccRow["pdbx_replaces"] = "?" if fW is not None: - ccRow['formula_weight'] = fW + ccRow["formula_weight"] = fW else: - ccRow['formula_weight'] = '?' - ccRow['one_letter_code'] = '?' + ccRow["formula_weight"] = "?" + ccRow["one_letter_code"] = "?" tlc = ccId.split("_")[0] - ccRow['three_letter_code'] = tlc - ccRow['pdbx_model_coordinates_details'] = '?' - ccRow['pdbx_ideal_coordinates_details'] = '?' + ccRow["three_letter_code"] = tlc + ccRow["pdbx_model_coordinates_details"] = "?" + ccRow["pdbx_ideal_coordinates_details"] = "?" if missingModelXyz: - ccRow['pdbx_model_coordinates_missing_flag'] = 'Y' + ccRow["pdbx_model_coordinates_missing_flag"] = "Y" else: - ccRow['pdbx_model_coordinates_missing_flag'] = 'N' - ccRow['pdbx_model_coordinates_db_code'] = '?' - ccRow['pdbx_processing_site'] = site - ccRow['pdbx_subcomponent_list'] = '?' + ccRow["pdbx_model_coordinates_missing_flag"] = "N" + ccRow["pdbx_model_coordinates_db_code"] = "?" + ccRow["pdbx_processing_site"] = site + ccRow["pdbx_subcomponent_list"] = "?" return ccRow def __makeChemCompAtomCategory(self, ccId, oeMol): - """ Populate elements of chemical component definition for atoms and bonds. - """ - # + """Populate elements of chemical component definition for atoms and bonds.""" idCode = ccId - # rowL = [] for ii, atom in enumerate(oeMol.GetAtoms()): - # atRow = {} - atRow['comp_id'] = idCode + atRow["comp_id"] = idCode (x, y, z) = oeMol.GetCoords(atom) # pdbx_model_Cartn_x_ideal - atRow['pdbx_model_Cartn_x_ideal'] = '%0.3f' % x - atRow['pdbx_model_Cartn_y_ideal'] = '%0.3f' % y - atRow['pdbx_model_Cartn_z_ideal'] = '%0.3f' % z - atRow['atom_id'] = atom.GetName().strip() - atRow['alt_atom_id'] = atom.GetName().strip() - atRow['type_symbol'] = OEGetAtomicSymbol(atom.GetAtomicNum()) - atRow['charge'] = atom.GetFormalCharge() - if atom.GetStringData('pdbx_leaving_atom_flag') in ['Y', 'N']: - atRow['pdbx_leaving_atom_flag'] = atom.GetStringData('pdbx_leaving_atom_flag') + atRow["pdbx_model_Cartn_x_ideal"] = "%0.3f" % x + atRow["pdbx_model_Cartn_y_ideal"] = "%0.3f" % y + atRow["pdbx_model_Cartn_z_ideal"] = "%0.3f" % z + atRow["atom_id"] = atom.GetName().strip() + atRow["alt_atom_id"] = atom.GetName().strip() + atRow["type_symbol"] = OEGetAtomicSymbol(atom.GetAtomicNum()) + atRow["charge"] = atom.GetFormalCharge() + if atom.GetStringData("pdbx_leaving_atom_flag") in ["Y", "N"]: + atRow["pdbx_leaving_atom_flag"] = atom.GetStringData("pdbx_leaving_atom_flag") else: - atRow['pdbx_leaving_atom_flag'] = 'N' - if len(atRow['atom_id']) > 3 or len(atRow['type_symbol']) == 2: - atRow['pdbx_align'] = 0 + atRow["pdbx_leaving_atom_flag"] = "N" + if len(atRow["atom_id"]) > 3 or len(atRow["type_symbol"]) == 2: + atRow["pdbx_align"] = 0 else: - atRow['pdbx_align'] = 1 + atRow["pdbx_align"] = 1 if atom.IsAromatic(): - atRow['pdbx_aromatic_flag'] = 'Y' + atRow["pdbx_aromatic_flag"] = "Y" else: - atRow['pdbx_aromatic_flag'] = 'N' + atRow["pdbx_aromatic_flag"] = "N" # oeSt = OEGetCIPStereo(mol, atom) oeSt = None # if atom.IsChiral(): @@ -305,15 +301,14 @@ def __makeChemCompAtomCategory(self, ccId, oeMol): oeSt = "U" # oeSt = OEGetCIPStereo(oeMol, atom) # oeSt = atom.GetCIPStereo() - if (oeSt is not None and (len(oeSt) > 0) and (oeSt == "R" or oeSt == "S")): - atRow['pdbx_stereo_config'] = oeSt + if oeSt is not None and (len(oeSt) > 0) and (oeSt == "R" or oeSt == "S"): + atRow["pdbx_stereo_config"] = oeSt else: - atRow['pdbx_stereo_config'] = 'N' - atRow['pdbx_component_atom_id'] = atom.GetName().strip() - atRow['pdbx_component_comp_id'] = idCode - atRow['pdbx_ordinal'] = str(ii + 1) + atRow["pdbx_stereo_config"] = "N" + atRow["pdbx_component_atom_id"] = atom.GetName().strip() + atRow["pdbx_component_comp_id"] = idCode + atRow["pdbx_ordinal"] = str(ii + 1) rowL.append(atRow) - # return rowL def __makeChemCompBondCategory(self, ccId, oeMol): @@ -325,24 +320,24 @@ def __makeChemCompBondCategory(self, ccId, oeMol): oeOrder = str(bond.GetOrder()).upper() b1 = bond.GetBgn().GetName().strip() b2 = bond.GetEnd().GetName().strip() - if ((b1 is None) or (len(b1) < 1)): + if (b1 is None) or (len(b1) < 1): continue - if ((b2 is None) or (len(b1) < 1)): + if (b2 is None) or (len(b1) < 1): continue - if (int(oeOrder) in iBondD): + if int(oeOrder) in iBondD: bndRow = {} - bndRow['comp_id'] = idCode - bndRow['atom_id_1'] = b1 - bndRow['atom_id_2'] = b2 - bndRow['value_order'] = iBondD[int(oeOrder)] + bndRow["comp_id"] = idCode + bndRow["atom_id_1"] = b1 + bndRow["atom_id_2"] = b2 + bndRow["value_order"] = iBondD[int(oeOrder)] if bond.IsAromatic(): - bndRow['pdbx_aromatic_flag'] = 'Y' + bndRow["pdbx_aromatic_flag"] = "Y" else: - bndRow['pdbx_aromatic_flag'] = 'N' + bndRow["pdbx_aromatic_flag"] = "N" oeSt = None - if (bond.GetOrder() == 2): + if bond.GetOrder() == 2: cip = OEPerceiveCIPStereo(oeMol, bond) if bond.HasStereoSpecified(): if cip == OECIPBondStereo_E: @@ -353,11 +348,11 @@ def __makeChemCompBondCategory(self, ccId, oeMol): oeSt = None if cip == OECIPBondStereo_UnspecStereo: oeSt = None - if (oeSt is not None and (len(oeSt) > 0) and (oeSt == "E" or oeSt == "Z")): - bndRow['pdbx_stereo_config'] = oeSt + if oeSt is not None and (len(oeSt) > 0) and (oeSt == "E" or oeSt == "Z"): + bndRow["pdbx_stereo_config"] = oeSt else: - bndRow['pdbx_stereo_config'] = 'N' + bndRow["pdbx_stereo_config"] = "N" - bndRow['pdbx_ordinal'] = str(ii + 1) + bndRow["pdbx_ordinal"] = str(ii + 1) rowL.append(bndRow) return rowL diff --git a/wwpdb/utils/oe_util/oedepict/OeAlignDepict.py b/wwpdb/utils/oe_util/oedepict/OeAlignDepict.py index 8c82ee0..89d907b 100644 --- a/wwpdb/utils/oe_util/oedepict/OeAlignDepict.py +++ b/wwpdb/utils/oe_util/oedepict/OeAlignDepict.py @@ -14,6 +14,7 @@ Classes to depict MCS alignments. """ + __docformat__ = "restructuredtext en" __author__ = "John Westbrook" __email__ = "jwest@rcsb.rutgers.edu" @@ -66,12 +67,12 @@ OEWriteImage, OEWriteMultiPageImage, ) + from wwpdb.utils.cc_dict_util.timeout.TimeoutMultiProc import timeout from wwpdb.utils.oe_util.build.OeBuildMol import OeBuildMol -class OeDepictMCSAlign(object): - +class OeDepictMCSAlign: """Create 2D depictions of MCSS alignments. Targets can be chemical component identifiers or paths to chemical component definition files. Inputs can be in the the form of pairs, lists, and pair lists of chemical component definitions. @@ -79,33 +80,24 @@ class OeDepictMCSAlign(object): """ def __init__(self, verbose=True, log=sys.stderr): - # self.__verbose = verbose self.__debug = False self.__lfh = log - # self.__refId = None self.__refmol = None self.__refTitle = None - # self.__fitId = None self.__fitmol = None self.__fitTitle = None - # self.__pairTupleList = [] - # self.__minAtomMatchFraction = 0.50 self.__pageOrientation = "portrait" - # self.__searchType = "default" - # self.__refFD = {} self.__fitFD = {} - # self.__refPath = None self.__fitPath = None self.__mcss = None - # self.__image = None self.__grid = None self.__opts = None @@ -141,12 +133,10 @@ def setRefId(self, ccId, title=None, suppressHydrogens=False, cachePath="/data/c else: self.__refmol.SetTitle(self.__refId) self.__refTitle = None - # - # OEPrepareDepiction(self.__refmol) self.__setupMCSS(self.__refmol) - def setRefPath(self, ccPath, title=None, suppressHydrogens=False, type="CC", importType="2D"): # pylint: disable=redefined-builtin + def setRefPath(self, ccPath, title=None, suppressHydrogens=False, type="CC", importType="2D"): # noqa: A002 pylint: disable=redefined-builtin """Set the query molecule for MCSS comparison using the input file path. The file type is either ['CC'] for a chemical component definition or another file type @@ -159,10 +149,14 @@ def setRefPath(self, ccPath, title=None, suppressHydrogens=False, type="CC", imp The hydrogen flag can be used to perform the MCSS using only heavy atoms. """ self.__refPath = ccPath - if type in ["CC"]: - (self.__refId, self.__refmol, self.__refFD) = self.__getCCDefFile(ccPath, suppressHydrogens=suppressHydrogens) + if type == "CC": + (self.__refId, self.__refmol, self.__refFD) = self.__getCCDefFile( + ccPath, suppressHydrogens=suppressHydrogens + ) else: - (self.__refId, self.__refmol, self.__refFD) = self.__getMiscFile(ccPath, suppressHydrogens=suppressHydrogens, importType=importType) + (self.__refId, self.__refmol, self.__refFD) = self.__getMiscFile( + ccPath, suppressHydrogens=suppressHydrogens, importType=importType + ) if self.__verbose: self.__lfh.write("Derived ref ID = %s\n" % self.__refId) @@ -184,7 +178,9 @@ def setFitId(self, ccId, title=None, suppressHydrogens=False, cachePath="/data/c self.__fitId = ccId ccIdU = ccId.upper() self.__fitPath = os.path.join(cachePath, ccIdU[0], ccIdU, ccIdU + ".cif") - self.__fitId, self.__fitmol, self.__fitFD = self.__getCCDefFile(self.__fitPath, suppressHydrogens=suppressHydrogens) + self.__fitId, self.__fitmol, self.__fitFD = self.__getCCDefFile( + self.__fitPath, suppressHydrogens=suppressHydrogens + ) if self.__verbose: self.__lfh.write("Fit ID = %s\n" % self.__fitId) self.__lfh.write("SMILES (isomeric) = %s\n" % self.__fitFD["SMILES_STEREO"]) @@ -205,7 +201,7 @@ def setFitPath(self, ccPath, title=None, suppressHydrogens=False): self.__fitmol.SetTitle(self.__fitId) self.__fitTitle = None - def setFitIdList(self, ccIdList, cachePath="/data/components/ligand-dict-v3", suppressHydrogens=False): # pylint: disable=unused-argument + def setFitIdList(self, ccIdList, cachePath="/data/components/ligand-dict-v3", suppressHydrogens=False): # noqa: ARG002 pylint: disable=unused-argument """Set the list of IDs to be compared with reference molecule by MCSS. From the input ID list build the internal pair list of @@ -215,31 +211,28 @@ def setFitIdList(self, ccIdList, cachePath="/data/components/ligand-dict-v3", su for ccId in ccIdList: refId = self.__refId refPath = self.__refPath - # fitId = ccId ccIdU = ccId.upper() fitPath = os.path.join(cachePath, ccIdU[0], ccIdU, ccIdU + ".cif") - # refTitle = refId + "/" + fitId fitTitle = fitId + "/" + refId self.__pairTupleList.append((refId, refPath, refTitle, fitId, fitPath, fitTitle)) - def setFitPathList(self, fitPathTupList, suppressHydrogens=False): # pylint: disable=unused-argument + def setFitPathList(self, fitPathTupList, suppressHydrogens=False): # noqa: ARG002 pylint: disable=unused-argument """Set the list of paths for the target/library molecules to be compared with reference molecule by MCSS. From the input path tuple list build the internal pair list of tuples [(fitId,fitPath,fitTitle),(),...] """ self.__pairTupleList = [] - for fitId, fitPath, fitTitle in fitPathTupList: + for fitId, fitPath, _fitTitle in fitPathTupList: refId = self.__refId refPath = self.__refPath - # refTitle = refId + "/" + fitId - fitTitle = fitId + "/" + refId - self.__pairTupleList.append((refId, refPath, refTitle, fitId, fitPath, fitTitle)) + newFitTitle = fitId + "/" + refId + self.__pairTupleList.append((refId, refPath, refTitle, fitId, fitPath, newFitTitle)) - def setPairIdList(self, pairIdList, cachePath="/data/components/ligand-dict-v3", suppressHydrogens=False): # pylint: disable=unused-argument + def setPairIdList(self, pairIdList, cachePath="/data/components/ligand-dict-v3", suppressHydrogens=False): # noqa: ARG002 pylint: disable=unused-argument """Set the list of ID pais to be aligned by MCSS. From the input ID list build the internal pair list of @@ -250,10 +243,8 @@ def setPairIdList(self, pairIdList, cachePath="/data/components/ligand-dict-v3", for refId, fitId in pairIdList: ccIdU = refId.upper() refPath = os.path.join(cachePath, ccIdU[0], ccIdU, ccIdU + ".cif") - # ccIdU = fitId.upper() fitPath = os.path.join(cachePath, ccIdU[0], ccIdU, ccIdU + ".cif") - # refTitle = refId + "/" + fitId fitTitle = fitId + "/" + refId self.__pairTupleList.append((refId, refPath, refTitle, fitId, fitPath, fitTitle)) @@ -263,7 +254,6 @@ def __getCCDefFile(self, ccPath, suppressHydrogens=False): for comparison and depiction. """ - # oem = OeBuildMol(verbose=self.__verbose, log=self.__lfh) ccId = oem.setChemCompPath(ccPath) oem.build2D() @@ -278,12 +268,17 @@ def __getCCDefFile(self, ccPath, suppressHydrogens=False): self.__lfh.write(" InChI = %s\n" % oem.getInChI()) fD = {} - fD = {"Formula": oem.getFormula(), "SMILES": oem.getCanSMILES(), "SMILES_STEREO": oem.getIsoSMILES(), "InChI": oem.getInChI(), "InChIKey": oem.getInChIKey()} + fD = { + "Formula": oem.getFormula(), + "SMILES": oem.getCanSMILES(), + "SMILES_STEREO": oem.getIsoSMILES(), + "InChI": oem.getInChI(), + "InChIKey": oem.getInChIKey(), + } if suppressHydrogens: return (ccId, oem.getGraphMolSuppressH(), fD) - else: - return (ccId, oem.getMol(), fD) + return (ccId, oem.getMol(), fD) def __getMiscFile(self, ccPath, suppressHydrogens=False, importType="2D"): """Fetch a miscellaneous chemical file (ccPath) and build OE molecules @@ -317,7 +312,18 @@ def __getMiscFile(self, ccPath, suppressHydrogens=False, importType="2D"): for ii, atm in enumerate(tMol.GetAtoms()): xyzL = OEFloatArray(3) tMol.GetCoords(atm, xyzL) - molXyzL.append((ii, atm.GetIdx(), atm.GetAtomicNum(), atm.GetName(), atm.GetType(), "%.3f" % xyzL[0], "%.3f" % xyzL[1], "%.3f" % xyzL[2])) + molXyzL.append( + ( + ii, + atm.GetIdx(), + atm.GetAtomicNum(), + atm.GetName(), + atm.GetType(), + "%.3f" % xyzL[0], + "%.3f" % xyzL[1], + "%.3f" % xyzL[2], + ) + ) fD = {} fD = { "Formula": oem.getFormula(), @@ -332,7 +338,10 @@ def __getMiscFile(self, ccPath, suppressHydrogens=False, importType="2D"): xyzL = OEFloatArray(3) tMol.GetCoords(atm, xyzL) if self.__verbose: - self.__lfh.write("OeAlignDepict.__getMiscFile - atom %d %s %s %s %s %r\n" % (ii, atm.GetIdx(), atm.GetAtomicNum(), atm.GetName(), atm.GetType(), xyzL)) + self.__lfh.write( + "OeAlignDepict.__getMiscFile - atom %d %s %s %s %s %r\n" + % (ii, atm.GetIdx(), atm.GetAtomicNum(), atm.GetName(), atm.GetType(), xyzL) + ) return (ccId, tMol, fD) except: # noqa: E722 pylint: disable=bare-except @@ -343,7 +352,6 @@ def __getMiscFile(self, ccPath, suppressHydrogens=False, importType="2D"): def __setupMCSS(self, refmol): """Internal initialization for the MCSS comparison.""" - # if self.__searchType == "default": self.__mcss = OEMCSSearch(OEMCSType_Approximate) atomexpr = OEExprOpts_DefaultAtoms @@ -382,12 +390,11 @@ def __setupMCSS(self, refmol): # self.__mcss.SetMinAtoms(nAtomsRef/2) @timeout(15) - def testAlign(self, suppressHydrogens=False, unique=True, minFrac=1.0): # pylint: disable=unused-argument + def testAlign(self, suppressHydrogens=False, unique=True, minFrac=1.0): # noqa: ARG002 pylint: disable=unused-argument """Test the MCSS comparison between current reference and fit molecules - Return list of corresponding atoms on success or an empty list otherwise. """ atomMap = [] - # nAtomsRef = self.__refmol.NumAtoms() nAtomsFit = self.__fitmol.NumAtoms() minAtoms = int(min(nAtomsRef, nAtomsFit) * minFrac) @@ -404,17 +411,26 @@ def testAlign(self, suppressHydrogens=False, unique=True, minFrac=1.0): # pylin match = miter.Target() for mAt in match.GetAtoms(): # atomMap.append( (self.__refId,mAt.pattern.GetName(),self.__fitId,mAt.target.GetName() )) - atomMap.append((self.__refId, mAt.pattern.GetIdx(), mAt.pattern.GetType(), mAt.pattern.GetName(), self.__fitId, mAt.target.GetIdx(), mAt.target.GetName())) + atomMap.append( + ( + self.__refId, + mAt.pattern.GetIdx(), + mAt.pattern.GetType(), + mAt.pattern.GetName(), + self.__fitId, + mAt.target.GetIdx(), + mAt.target.GetName(), + ) + ) return atomMap @timeout(30) - def doAlign(self, suppressHydrogens=False, unique=True, minFrac=1.0): # pylint: disable=unused-argument + def doAlign(self, suppressHydrogens=False, unique=True, minFrac=1.0): # noqa: ARG002 pylint: disable=unused-argument """Test the MCSS comparison between current reference and fit molecules - Return list of corresponding atoms on success or an empty list otherwise. """ atomMap = [] - # nAtomsRef = self.__refmol.NumAtoms() nAtomsFit = self.__fitmol.NumAtoms() minAtoms = int(min(nAtomsRef, nAtomsFit) * minFrac) @@ -431,17 +447,26 @@ def doAlign(self, suppressHydrogens=False, unique=True, minFrac=1.0): # pylint: match = miter.Target() for mAt in match.GetAtoms(): # atomMap.append( (self.__refId,mAt.pattern.GetName(),self.__fitId,mAt.target.GetName() )) - atomMap.append((self.__refId, mAt.pattern.GetIdx(), mAt.pattern.GetType(), mAt.pattern.GetName(), self.__fitId, mAt.target.GetIdx(), mAt.target.GetName())) + atomMap.append( + ( + self.__refId, + mAt.pattern.GetIdx(), + mAt.pattern.GetType(), + mAt.pattern.GetName(), + self.__fitId, + mAt.target.GetIdx(), + mAt.target.GetName(), + ) + ) return (nAtomsRef, self.__refFD["SMILES_STEREO"], nAtomsFit, self.__fitFD["SMILES_STEREO"], atomMap) @timeout(30) - def doAlignAlt(self, suppressHydrogens=False, unique=True, minFrac=1.0): # pylint: disable=unused-argument + def doAlignAlt(self, suppressHydrogens=False, unique=True, minFrac=1.0): # noqa: ARG002 pylint: disable=unused-argument """Test the MCSS comparison between current reference and fit molecules - Return list of corresponding atoms on success or an empty list otherwise. """ atomMap = [] - # nAtomsRef = self.__refmol.NumAtoms() nAtomsFit = self.__fitmol.NumAtoms() minAtoms = int(min(nAtomsRef, nAtomsFit) * minFrac) @@ -474,7 +499,6 @@ def doAlignAlt(self, suppressHydrogens=False, unique=True, minFrac=1.0): # pyli def __setupImage(self, imageX=400, imageY=400): """Internal method to configure a single pair alignment image.""" - # self.__image = OEImage(imageX, imageY) rows = 1 cols = 2 @@ -486,10 +510,8 @@ def __setupImage(self, imageX=400, imageY=400): def __setupImageMulti(self, gridRows=2, gridCols=2): """Internal method to configure a multipage image.""" - # self.__gridRows = gridRows self.__gridCols = gridCols - # if self.__pageOrientation == "landscape": self.__multi = OEMultiPageImageFile(OEPageOrientation_Landscape, OEPageSize_US_Letter) else: @@ -527,7 +549,6 @@ def alignPair(self, imagePath="mcs-match.svg", imageX=400, imageY=400): self.__refmol.SetTitle(self.__refTitle) OEPrepareDepiction(self.__refmol) - # if self.__fitTitle is None: self.__fitTitle = self.__fitId + "/" + self.__refId self.__fitmol.SetTitle(self.__fitTitle) @@ -597,18 +618,14 @@ def alignPairList( Image Output is in multipage layout. """ - # self.__setupImageMulti(gridRows=gridRows, gridCols=gridCols) - # atomMap = [] - # numRows = self.__grid.NumRows() rowIdx = 0 - for (refId, refPath, refTitle, fitId, fitPath, fitTitle) in self.__pairTupleList: + for refId, refPath, refTitle, fitId, fitPath, fitTitle in self.__pairTupleList: self.setRefPath(refPath, title=refTitle, suppressHydrogens=suppressHydrogens) OEPrepareDepiction(self.__refmol) - # _tId, fitmol, _fitFD = self.__getCCDefFile(fitPath, suppressHydrogens=suppressHydrogens) fitmol.SetTitle(fitTitle) # @@ -662,7 +679,10 @@ def alignPairList( optInverseFit = True - self.__lfh.write("+OeAlignDepict.alignPairList refId %s fitId %s nAtomsRef %d nAtomsFit %s mcssMinAtoms %d\n" % (refId, fitId, nAtomsRef, nAtomsFit, mcssMinAtoms)) + self.__lfh.write( + "+OeAlignDepict.alignPairList refId %s fitId %s nAtomsRef %d nAtomsFit %s mcssMinAtoms %d\n" + % (refId, fitId, nAtomsRef, nAtomsFit, mcssMinAtoms) + ) unique = True miter = self.__mcss.Match(fitmol, unique) diff --git a/wwpdb/utils/oe_util/oedepict/OeAlignDepictUtils.py b/wwpdb/utils/oe_util/oedepict/OeAlignDepictUtils.py index f6a6a49..912a82f 100644 --- a/wwpdb/utils/oe_util/oedepict/OeAlignDepictUtils.py +++ b/wwpdb/utils/oe_util/oedepict/OeAlignDepictUtils.py @@ -13,6 +13,7 @@ Classes to depict aligned 2D chemical diagrams. """ + __docformat__ = "restructuredtext en" __author__ = "John Westbrook" __email__ = "jwest@rcsb.rutgers.edu" @@ -66,38 +67,34 @@ OEWriteImage, OEWriteMultiPageImage, ) + from wwpdb.utils.cc_dict_util.timeout.TimeoutMultiProc import TimeoutException, timeout from wwpdb.utils.oe_util.build.OeChemCompIoUtils import OeChemCompIoUtils from wwpdb.utils.oe_util.oedepict.OeDepict import OeDepictBase # Note for pylint testing. This base class references self._opt and self._param, but it is defined in a child class of a parallel class. We do not init it -class OeDepictAlignBase(object): +class OeDepictAlignBase: """""" # pylint: disable=no-member def __init__(self, verbose=True, log=sys.stderr): super(OeDepictAlignBase, self).__init__() - # self.__verbose = verbose # self.__debug = False self.__lfh = log - # self._refId = None self._refPath = None self._refMol = None self._refTitle = None self._refImagePath = None - # self._fitId = None self._fitPath = None self._fitMol = None self._fitTitle = None self._fitImagePath = None - # self._pairMolList = [] - # self._searchType = "default" self._minAtomMatchFraction = 0.50 self._mcss = None @@ -111,14 +108,12 @@ def setRefMol(self, oeMol, ccId, title=None, imagePath=None): try: self._refId = ccId self._refMol = oeMol - # if title is not None: self._refMol.SetTitle(title) self._refTitle = title else: self._refMol.SetTitle(self._refId) self._refTitle = None - # self._refImagePath = imagePath if imagePath is not None else self._refId + ".svg" return True except: # noqa: E722 pylint: disable=bare-except @@ -126,7 +121,9 @@ def setRefMol(self, oeMol, ccId, title=None, imagePath=None): traceback.print_exc(file=self.__lfh) return False - def setRefId(self, ccId, title=None, imagePath=None, suppressHydrogens=False, cachePath="/data/components/ligand-dict-v3"): + def setRefId( + self, ccId, title=None, imagePath=None, suppressHydrogens=False, cachePath="/data/components/ligand-dict-v3" + ): """Set the query reference molecule for MCSS comparison using the input chemical component ID. It is assumed that the definition for this ID can be obtained from the chemical component repository (in cachePath). @@ -143,7 +140,9 @@ def setRefId(self, ccId, title=None, imagePath=None, suppressHydrogens=False, ca ccIdU = ccId.upper() self._refPath = os.path.join(cachePath, ccIdU[0], ccIdU, ccIdU + ".cif") - _id, self._refMol, _refIsoSMILES = self.__makeMolfromCCDef(path=self._refPath, suppressHydrogens=suppressHydrogens) + _id, self._refMol, _refIsoSMILES = self.__makeMolfromCCDef( + path=self._refPath, suppressHydrogens=suppressHydrogens + ) # # Insert title here - if title is not None: @@ -152,7 +151,6 @@ def setRefId(self, ccId, title=None, imagePath=None, suppressHydrogens=False, ca else: self._refMol.SetTitle(self._refId) self._refTitle = None - # self._refImagePath = imagePath if imagePath is not None else self._refId + ".svg" return True except: # noqa: E722 pylint: disable=bare-except @@ -172,7 +170,9 @@ def setRefPath(self, refId, ccPath, title=None, imagePath=None, suppressHydrogen try: self._refPath = ccPath self._refId = refId - (_rId, self._refMol, _refIsoSMILES) = self.__makeMolfromCCDef(path=self._refPath, suppressHydrogens=suppressHydrogens) + (_rId, self._refMol, _refIsoSMILES) = self.__makeMolfromCCDef( + path=self._refPath, suppressHydrogens=suppressHydrogens + ) # Insert title here - if title is not None: @@ -193,14 +193,12 @@ def setFitMol(self, oeMol, ccId, title=None, imagePath=None): try: self._fitId = ccId self._fitMol = oeMol - # if title is not None: self._fitMol.SetTitle(title) self._fitTitle = title else: self._fitMol.SetTitle(self._fitId) self._fitTitle = None - # self._fitImagePath = imagePath if imagePath is not None else self._fitId + ".svg" return True except: # noqa: E722 pylint: disable=bare-except @@ -208,7 +206,9 @@ def setFitMol(self, oeMol, ccId, title=None, imagePath=None): traceback.print_exc(file=self.__lfh) return False - def setFitId(self, ccId, title=None, imagePath=None, suppressHydrogens=False, cachePath="/data/components/ligand-dict-v3"): + def setFitId( + self, ccId, title=None, imagePath=None, suppressHydrogens=False, cachePath="/data/components/ligand-dict-v3" + ): """Set the test/fit molecule for MCSS comparison using the input chemical component ID. It is assumed that the definition for this ID can be obtained from the chemical component repository (in cachePath). @@ -224,7 +224,9 @@ def setFitId(self, ccId, title=None, imagePath=None, suppressHydrogens=False, ca self._fitId = ccId ccIdU = ccId.upper() self._fitPath = os.path.join(cachePath, ccIdU[0], ccIdU, ccIdU + ".cif") - self._fitId, self._fitMol, _fitIsoSMILES = self.__makeMolfromCCDef(path=self._fitPath, suppressHydrogens=suppressHydrogens) + self._fitId, self._fitMol, _fitIsoSMILES = self.__makeMolfromCCDef( + path=self._fitPath, suppressHydrogens=suppressHydrogens + ) if title is not None: self._fitMol.SetTitle(title) self._fitTitle = title @@ -238,7 +240,7 @@ def setFitId(self, ccId, title=None, imagePath=None, suppressHydrogens=False, ca traceback.print_exc(file=self.__lfh) return False - def setFitPath(self, fitId, ccPath, title=None, imagePath=None, suppressHydrogens=False): # pylint: disable=unused-argument + def setFitPath(self, fitId, ccPath, title=None, imagePath=None, suppressHydrogens=False): # noqa: ARG002 pylint: disable=unused-argument """Set the test/fit molecule for MCSS comparison using the input file path. A title and imagePath are optionally provided otherwise the component Id will be used for title and @@ -247,7 +249,9 @@ def setFitPath(self, fitId, ccPath, title=None, imagePath=None, suppressHydrogen The hydrogen flag can be used to perform the MCSS using only heavy atoms. """ try: - (self._fitId, self._fitMol, _fitIsoSMILES) = self.__makeMolfromCCDef(path=ccPath, suppressHydrogens=suppressHydrogens) + (self._fitId, self._fitMol, _fitIsoSMILES) = self.__makeMolfromCCDef( + path=ccPath, suppressHydrogens=suppressHydrogens + ) if title is not None: self._fitMol.SetTitle(title) self._fitTitle = title @@ -261,7 +265,9 @@ def setFitPath(self, fitId, ccPath, title=None, imagePath=None, suppressHydrogen traceback.print_exc(file=self.__lfh) return False - def setFitIdList(self, ccIdList, cachePath="/data/components/ligand-dict-v3", suppressHydrogens=False, imageDirPath="."): + def setFitIdList( + self, ccIdList, cachePath="/data/components/ligand-dict-v3", suppressHydrogens=False, imageDirPath="." + ): """Set the list of IDs to be compared with reference molecule by MCSS. It is assumed that each definition on the list can be obtained from the chemical component @@ -273,13 +279,16 @@ def setFitIdList(self, ccIdList, cachePath="/data/components/ligand-dict-v3", su self._pairMolList = [] try: for ccId in ccIdList: - (refId, refMol, _refIsoSMILES) = self.__makeMolfromCCDef(path=self._refPath, suppressHydrogens=suppressHydrogens) + (refId, refMol, _refIsoSMILES) = self.__makeMolfromCCDef( + path=self._refPath, suppressHydrogens=suppressHydrogens + ) refTitle = refId refImagePath = os.path.join(imageDirPath, refId.upper() + ".svg") - # ccIdU = ccId.upper() fitPath = os.path.join(cachePath, ccIdU[0], ccIdU, ccIdU + ".cif") - (fitId, fitMol, _fitIsoSMILES) = self.__makeMolfromCCDef(path=fitPath, suppressHydrogens=suppressHydrogens) + (fitId, fitMol, _fitIsoSMILES) = self.__makeMolfromCCDef( + path=fitPath, suppressHydrogens=suppressHydrogens + ) fitTitle = fitId + "/" + refId fitImagePath = os.path.join(imageDirPath, ccIdU + ".svg") self._pairMolList.append((refId, refMol, refTitle, refImagePath, fitId, fitMol, fitTitle, fitImagePath)) @@ -311,7 +320,9 @@ def addFitPath(self, fitId, ccPath, title=None, suppressHydrogens=False, imagePa fitImagePath = imagePath if imagePath is not None else fitId + ".svg" - self._pairMolList.append((self._refId, self._refMol, self._refTitle, self._refImagePath, fitId, fitMol, fitTitle, fitImagePath)) + self._pairMolList.append( + (self._refId, self._refMol, self._refTitle, self._refImagePath, fitId, fitMol, fitTitle, fitImagePath) + ) return True except: # noqa: E722 pylint: disable=bare-except @@ -319,7 +330,9 @@ def addFitPath(self, fitId, ccPath, title=None, suppressHydrogens=False, imagePa traceback.print_exc(file=self.__lfh) return False - def setPairIdList(self, pairIdList, cachePath="/data/components/ligand-dict-v3", suppressHydrogens=False, imageDirPath="."): + def setPairIdList( + self, pairIdList, cachePath="/data/components/ligand-dict-v3", suppressHydrogens=False, imageDirPath="." + ): """Set the list of ID pairs to be aligned by MCSS. It is assumed that each definition on the list can be obtained from the chemical component @@ -328,18 +341,19 @@ def setPairIdList(self, pairIdList, cachePath="/data/components/ligand-dict-v3", From the input pair ID list build the internal pair list (self._pairMolList). """ self._pairMolList = [] - # try: for refId, fitId in pairIdList: ccIdU = refId.upper() refPath = os.path.join(cachePath, ccIdU[0], ccIdU, ccIdU + ".cif") - (_rId, refMol, _refIsoSMILES) = self.__makeMolfromCCDef(path=refPath, suppressHydrogens=suppressHydrogens) + (_rId, refMol, _refIsoSMILES) = self.__makeMolfromCCDef( + path=refPath, suppressHydrogens=suppressHydrogens + ) refImagePath = os.path.join(imageDirPath, ccIdU + ".svg") - # ccIdU = fitId.upper() fitPath = os.path.join(cachePath, ccIdU[0], ccIdU, ccIdU + ".cif") - (_fId, fitMol, _fitIsoSMILES) = self.__makeMolfromCCDef(path=fitPath, suppressHydrogens=suppressHydrogens) - # + (_fId, fitMol, _fitIsoSMILES) = self.__makeMolfromCCDef( + path=fitPath, suppressHydrogens=suppressHydrogens + ) refTitle = refId + "/" + fitId fitTitle = fitId + "/" + refId fitImagePath = os.path.join(imageDirPath, ccIdU + ".svg") @@ -362,18 +376,31 @@ def setFitPathList(self, fitPathTupList, suppressHydrogens=False, imagePath=None try: for fitId, fitPath, title in fitPathTupList: - fitId = fitId.upper() - (_fId, fitMol, _fitIsoSMILES) = self.__makeMolfromCCDef(path=fitPath, suppressHydrogens=suppressHydrogens) + fitIdUc = fitId.upper() + (_fId, fitMol, _fitIsoSMILES) = self.__makeMolfromCCDef( + path=fitPath, suppressHydrogens=suppressHydrogens + ) if title is not None: fitMol.SetTitle(title) fitTitle = title else: - fitMol.SetTitle(fitId) - fitTitle = fitId + "/" + self._refId - - fitImagePath = imagePath if imagePath is not None else fitId + ".svg" - - self._pairMolList.append((self._refId, self._refMol, self._refTitle, self._refImagePath, fitId, fitMol, fitTitle, fitImagePath)) + fitMol.SetTitle(fitIdUc) + fitTitle = fitIdUc + "/" + self._refId + + fitImagePath = imagePath if imagePath is not None else fitIdUc + ".svg" + + self._pairMolList.append( + ( + self._refId, + self._refMol, + self._refTitle, + self._refImagePath, + fitIdUc, + fitMol, + fitTitle, + fitImagePath, + ) + ) return True except: # noqa: E722 pylint: disable=bare-except @@ -397,13 +424,11 @@ def __makeMolfromCCDef(self, path=None, suppressHydrogens=False, use3D=False, co self.__lfh.write("Creating OEMOL for %s SMILES: %s PATH: %s\n" % (ccId, isoSmiles, path)) if suppressHydrogens: return (ccId, oem.getGraphMolSuppressH(), isoSmiles) - else: - return (ccId, oem.getMol(), isoSmiles) + return (ccId, oem.getMol(), isoSmiles) except: # noqa: E722 pylint: disable=bare-except if self.__verbose: traceback.print_exc(file=self.__lfh) return (None, None, None) - # def setSearchType(self, sType="default"): self._searchType = sType @@ -446,7 +471,6 @@ def _setupMCSS(self, refmol): def _setHighlightStyleRef(self, matchObj, refMol): refdisp = OE2DMolDisplay(refMol, self._opts) - # optInverseFit = False if self._params["highlightStyleRef"] == "ballAndStick": hstyle = OEHighlightStyle_BallAndStick @@ -479,11 +503,12 @@ def _setHighlightStyleRef(self, matchObj, refMol): else: myHighLightNotMatchColor = OEBlueTint - # matchedatoms = OEIsAtomMember(matchObj.GetPatternAtoms()) matchedbonds = OEIsBondMember(matchObj.GetPatternBonds()) if optInverseFit: - OEAddHighlighting(refdisp, myHighLightNotMatchColor, hstyle, OENotAtom(matchedatoms), OENotBond(matchedbonds)) + OEAddHighlighting( + refdisp, myHighLightNotMatchColor, hstyle, OENotAtom(matchedatoms), OENotBond(matchedbonds) + ) else: OEAddHighlighting(refdisp, myHighLightMatchColor, hstyle, matchedatoms, matchedbonds) @@ -531,7 +556,9 @@ def _setHighlightStyleFit(self, matchObj, fitMol): matchedbonds = OEIsBondMember(matchObj.GetTargetBonds()) if optInverseFit: - OEAddHighlighting(fitdisp, myHighLightNotMatchColor, hstyle, OENotAtom(matchedatoms), OENotBond(matchedbonds)) + OEAddHighlighting( + fitdisp, myHighLightNotMatchColor, hstyle, OENotAtom(matchedatoms), OENotBond(matchedbonds) + ) else: OEAddHighlighting(fitdisp, myHighLightMatchColor, hstyle, matchedatoms, matchedbonds) @@ -549,11 +576,9 @@ class OeDepictMCSAlignMulti(OeDepictAlignBase, OeDepictBase): def __init__(self, verbose=False, log=sys.stderr): super(OeDepictMCSAlignMulti, self).__init__(verbose=verbose, log=log) - # self.__debug = False self.__verbose = verbose self.__lfh = log - # self.__grid = None self.__gridRows = None self.__gridCols = None @@ -569,7 +594,7 @@ def alignPairListMulti(self, imagePath="multi.pdf"): except TimeoutException: self.__lfh.write("+OeDepictMCSAlignMulti.alignPairListMulti timeout exception\n") self.__lfh.write("+OeDepictMCSAlignMulti.alignPairListMulti no output written to %r\n" % imagePath) - except Exception as e: + except Exception as e: # noqa: BLE001 self.__lfh.write("+OeDepictMCSAlignMulti.alignPairListMulti general exception %s\n" % str(e)) if self.__verbose: traceback.print_exc(file=self.__lfh) @@ -582,7 +607,7 @@ def alignOneWithListMulti(self, imagePath="multi.pdf"): except TimeoutException: self.__lfh.write("+OeDepictMCSAlignMulti.alignOneWithListMulti timeout exception\n") self.__lfh.write("+OeDepictMCSAlignMulti.alignOneWithListMulti no output written to %r\n" % imagePath) - except Exception as e: + except Exception as e: # noqa: BLE001 self.__lfh.write("+OeDepictMCSAlignMulti.alignOneWithListMulti general exception here %s\n" % str(e)) if self.__verbose: traceback.print_exc(file=self.__lfh) @@ -590,10 +615,8 @@ def alignOneWithListMulti(self, imagePath="multi.pdf"): def __setupImageMulti(self): """Internal method to configure a multipage image.""" - # self.__gridRows = self._params["gridRows"] self.__gridCols = self._params["gridCols"] - # if self._params["pageOrientation"] == "landscape": self.__multi = OEMultiPageImageFile(OEPageOrientation_Landscape, OEPageSize_US_Letter) else: @@ -626,25 +649,21 @@ def __alignListMultiWorker(self, imagePath="multi.pdf", layout="pairs"): Image Output is in multipage layout. """ - # self.__setupImageMulti() - # atomMap = [] firstOne = True iCount = 0 - for (refId, refMol, _refTitle, _refImagePath, fitId, fitMol, fitTitle, _fitImagePath) in self._pairMolList: - iCount += 1 + for refId, refMol, _refTitle, _refImagePath, fitId, fitMol, fitTitle, _fitImagePath in self._pairMolList: + iCount += 1 # noqa: SIM113 self.__lfh.write( - "+OeDepictMCSAlignMulti.__alignListMultiWorker Starting match pair refId %s fitId %s count %d of %d\n" % (refId, fitId, iCount, len(self._pairMolList)) + "+OeDepictMCSAlignMulti.__alignListMultiWorker Starting match pair refId %s fitId %s count %d of %d\n" + % (refId, fitId, iCount, len(self._pairMolList)) ) - # OEPrepareDepiction(refMol) self._setupMCSS(refMol) - # fitMol.SetTitle(fitTitle) OEPrepareDepiction(fitMol) - # nAtomsRef = refMol.NumAtoms() nAtomsFit = fitMol.NumAtoms() minAtoms = min(nAtomsRef, nAtomsFit) @@ -658,17 +677,21 @@ def __alignListMultiWorker(self, imagePath="multi.pdf", layout="pairs"): unique = True self.__lfh.write( - "+OeDepictMCSAlignMulti.__alignListMultiWorker refId %s fitId %s nAtomsRef %d nAtomsFit %d mcssMinAtoms %d\n" % (refId, fitId, nAtomsRef, nAtomsFit, mcssMinAtoms) + "+OeDepictMCSAlignMulti.__alignListMultiWorker refId %s fitId %s nAtomsRef %d nAtomsFit %d mcssMinAtoms %d\n" + % (refId, fitId, nAtomsRef, nAtomsFit, mcssMinAtoms) ) self._miter = self._mcss.Match(fitMol, unique) - self.__lfh.write("+OeDepictMCSAlignMulti.__alignListMultiWorker mcss match completed for refId %s fitId %s\n" % (refId, fitId)) + self.__lfh.write( + "+OeDepictMCSAlignMulti.__alignListMultiWorker mcss match completed for refId %s fitId %s\n" + % (refId, fitId) + ) if self._miter.IsValid(): match = self._miter.Target() OEPrepareAlignedDepiction(fitMol, self._mcss.GetPattern(), match) # Depict reference molecule with MCS highlighting - if (firstOne and (layout in ["list"])) or (layout in ["pairs"]): + if (firstOne and (layout == "list")) or (layout == "pairs"): firstOne = False refdisp = self._setHighlightStyleRef(matchObj=match, refMol=self._mcss.GetPattern()) if not self.__citer.IsValid(): @@ -693,12 +716,14 @@ def __alignListMultiWorker(self, imagePath="multi.pdf", layout="pairs"): for mAt in match.GetAtoms(): atomMap.append((refId, mAt.pattern.GetName(), fitId, mAt.target.GetName())) - self.__lfh.write("+OeDepictMCSAlignMulti.__alignListMultiWorker mcss match completed for refId %s fitId %s total map length %d \n" % (refId, fitId, len(atomMap))) + self.__lfh.write( + "+OeDepictMCSAlignMulti.__alignListMultiWorker mcss match completed for refId %s fitId %s total map length %d \n" + % (refId, fitId, len(atomMap)) + ) self.__lfh.write("+OeDepictMCSAlignMulti.__alignListMultiWorker writing image %s\n" % imagePath) OEWriteMultiPageImage(imagePath, self.__multi) self.__lfh.write("+OeDepictMCSAlignMulti.__alignListMultiWorker completed with map lenth %d\n" % len(atomMap)) - # return atomMap @@ -712,18 +737,15 @@ class OeDepictMCSAlign(OeDepictAlignBase, OeDepictBase): def __init__(self, verbose=False, log=sys.stderr): super(OeDepictMCSAlign, self).__init__(verbose=verbose, log=log) - # self.__debug = True # self.__verbose = verbose self.__lfh = log - # self.__image = None self.__grid = None self.__citer = None def __setupImage(self): """Internal method to configure a single pair alignment image.""" - # self.__image = OEImage(self._params["imageSizeX"], self._params["imageSizeY"]) rows = self._params["gridRows"] cols = self._params["gridCols"] @@ -737,8 +759,6 @@ def __setupImage(self): self._assignDisplayOptions() self.__citer = self.__grid.GetCells() - # - def alignPair(self, imagePath="single-pair.png"): """Depict a single aligned ref/fit molecule pair or the first ref/fit molecule pair on the current _pairMolList. Display options set for a single grid row with two columns. @@ -746,7 +766,9 @@ def alignPair(self, imagePath="single-pair.png"): self._params["gridCols"] = 2 self._params["gridRows"] = 1 if len(self._pairMolList) < 1: - self._pairMolList.append((self._refId, self._refMol, self._refTitle, None, self._fitId, self._fitMol, self._fitTitle, None)) + self._pairMolList.append( + (self._refId, self._refMol, self._refTitle, None, self._fitId, self._fitMol, self._fitTitle, None) + ) return self.__alignListWorker(imagePath=imagePath, layout="pairs") def alignPairList(self, imagePath="single-pair-list.png"): @@ -766,22 +788,16 @@ def __alignListWorker(self, imagePath="single.pdf", layout="pairs"): Output image is a single-page with grid layout. """ - # self.__setupImage() - # atomMap = [] firstOne = True - for (refId, refMol, _refTitle, _refImagePath, fitId, fitMol, fitTitle, _fitImagePath) in self._pairMolList: - # + for refId, refMol, _refTitle, _refImagePath, fitId, fitMol, fitTitle, _fitImagePath in self._pairMolList: OEPrepareDepiction(refMol) self._setupMCSS(refMol) - # fitMol.SetTitle(fitTitle) OEPrepareDepiction(fitMol) - # - # nAtomsRef = refMol.NumAtoms() nAtomsFit = fitMol.NumAtoms() minAtoms = min(nAtomsRef, nAtomsFit) @@ -800,7 +816,7 @@ def __alignListWorker(self, imagePath="single.pdf", layout="pairs"): OEPrepareAlignedDepiction(fitMol, self._mcss.GetPattern(), match) # Depict reference molecule with MCS highlighting - if (firstOne and (layout in ["list"])) or (layout in ["pairs"]): + if (firstOne and (layout == "list")) or (layout == "pairs"): firstOne = False refdisp = self._setHighlightStyleRef(matchObj=match, refMol=self._mcss.GetPattern()) if not self.__citer.IsValid(): @@ -845,11 +861,9 @@ def __init__(self, verbose=False, log=sys.stderr): # self.__lfh = log self.__imageRef = None self.__imageFit = None - # def __setupImage(self): """Internal method to configure a single page image.""" - # self.__imageRef = OEImage(self._params["imageSizeX"], self._params["imageSizeY"]) self.__imageFit = OEImage(self._params["imageSizeX"], self._params["imageSizeY"]) self._opts = OE2DMolDisplayOptions(self.__imageRef.GetWidth(), self.__imageRef.GetHeight(), OEScale_AutoScale) @@ -860,7 +874,18 @@ def alignPair(self): current _pairMolList. Display options set for a single grid row with two columns. """ if len(self._pairMolList) < 1: - self._pairMolList.append((self._refId, self._refMol, self._refTitle, self._refImagePath, self._fitId, self._fitMol, self._fitTitle, self._fitImagePath)) + self._pairMolList.append( + ( + self._refId, + self._refMol, + self._refTitle, + self._refImagePath, + self._fitId, + self._fitMol, + self._fitTitle, + self._fitImagePath, + ) + ) return self.__alignListWorker() def alignPairList(self): @@ -879,19 +904,15 @@ def __alignListWorker(self): Output image is a single-page with grid layout. """ - # atomMap = [] firstOne = True - for (refId, refMol, _refTitle, refImagePath, fitId, fitMol, _fitTitle, fitImagePath) in self._pairMolList: - # + for refId, refMol, _refTitle, refImagePath, fitId, fitMol, _fitTitle, fitImagePath in self._pairMolList: self.__setupImage() - # OEPrepareDepiction(refMol) self._setupMCSS(refMol) OEPrepareDepiction(fitMol) - # nAtomsRef = refMol.NumAtoms() nAtomsFit = fitMol.NumAtoms() minAtoms = min(nAtomsRef, nAtomsFit) @@ -947,7 +968,6 @@ def doAlign(self): """ atomMap = [] self._setupMCSS(self._refMol) - # nAtomsRef = self._refMol.NumAtoms() nAtomsFit = self._fitMol.NumAtoms() minAtoms = min(nAtomsRef, nAtomsFit) @@ -1002,11 +1022,8 @@ def doTestAlign(self): unique = True atomMap = [] self._setupMCSS(self._refMol) - # nAtomsRef = self._refMol.NumAtoms() nAtomsFit = self._fitMol.NumAtoms() - # - # minAtoms = min(nAtomsRef, nAtomsFit) self._mcss.SetMCSFunc(OEMCSMaxAtoms()) self._mcss.SetMinAtoms(int(minAtoms * self._minAtomMatchFraction)) @@ -1018,7 +1035,10 @@ def doTestAlign(self): for mAt in match.GetAtoms(): atomMap.append((self._refId, mAt.pattern.GetName(), self._fitId, mAt.target.GetName())) - self.__lfh.write("+OeTestMCSAlign.doTestAlign nAtomsRef %d nAtomsFit %d match length %d \n" % (nAtomsRef, nAtomsFit, len(atomMap))) + self.__lfh.write( + "+OeTestMCSAlign.doTestAlign nAtomsRef %d nAtomsFit %d match length %d \n" + % (nAtomsRef, nAtomsFit, len(atomMap)) + ) return atomMap @@ -1031,21 +1051,18 @@ def doAlignWithAnal(self): unique = True atomMap = [] self._setupMCSS(self._refMol) - # nAtomsRef = self._refMol.NumAtoms() nAtomsFit = self._fitMol.NumAtoms() - # atomRefD = self.__getAtomIndex(self._refMol) atomFitD = self.__getAtomIndex(self._fitMol) - # chgRefD = self.__getChargeIndex(self._refMol) chgFitD = self.__getChargeIndex(self._fitMol) - # minAtoms = min(nAtomsRef, nAtomsFit) - # self._mcss.SetMaxMatches(self.__maxMatches) nlim = OEGetMCSExhaustiveSearchTruncationLimit() - self.__lfh.write("+OeTestMCSAlign.doAlignWithAnal search limit %d max matches %d \n" % (nlim, self.__maxMatches)) + self.__lfh.write( + "+OeTestMCSAlign.doAlignWithAnal search limit %d max matches %d \n" % (nlim, self.__maxMatches) + ) self._mcss.SetMCSFunc(OEMCSMaxAtoms()) self._mcss.SetMinAtoms(int(minAtoms * self._minAtomMatchFraction)) unique = False @@ -1059,7 +1076,10 @@ def doAlignWithAnal(self): atomMap.append((self._refId, mAt.pattern.GetName(), self._fitId, mAt.target.GetName())) atomRefMatchD[mAt.pattern.GetName()] = mAt.target.GetName().strip() atomFitMatchD[mAt.target.GetName()] = mAt.pattern.GetName().strip() - self.__lfh.write("+OeTestMCSAlign.doAlignWithAnal nAtomsRef %d nAtomsFit %d match length %d \n" % (nAtomsRef, nAtomsFit, len(atomMap))) + self.__lfh.write( + "+OeTestMCSAlign.doAlignWithAnal nAtomsRef %d nAtomsFit %d match length %d \n" + % (nAtomsRef, nAtomsFit, len(atomMap)) + ) # # Get unmapped reference and fit atoms - @@ -1069,20 +1089,15 @@ def doAlignWithAnal(self): for atN in atomRefD: if atN not in atomRefMatchD: uRefAtomList.append(atN) - # if len(uRefAtomList) > 0: uRefNList = self.__getNeighbors(self._refMol, uRefAtomList) - # uFitAtomList = [] uFitNList = [] for atN in atomFitD: if atN not in atomFitMatchD: uFitAtomList.append(atN) - # - # if len(uFitAtomList) > 0: uFitNList = self.__getNeighbors(self._fitMol, uFitAtomList) - # chgDifRefD = {} for atN0 in chgRefD: if atN0 in atomRefMatchD: @@ -1090,7 +1105,6 @@ def doAlignWithAnal(self): # if ((atN not in chgFitD) or (chgRefD[atN0] != chgFitD[atN])): if chgRefD[atN0] != chgFitD[atN]: chgDifRefD[atN] = chgRefD[atN0] - # chgDifFitD = {} for atN0 in chgFitD: if atN0 in atomFitMatchD: @@ -1110,11 +1124,8 @@ def doAlignList(self): """ atomMap = [] - for (refId, refMol, _refTitle, _refImagePath, fitId, fitMol, _fitTitle, _fitImagePath) in self._pairMolList: - # + for refId, refMol, _refTitle, _refImagePath, fitId, fitMol, _fitTitle, _fitImagePath in self._pairMolList: self._setupMCSS(refMol) - # - # nAtomsRef = refMol.NumAtoms() nAtomsFit = fitMol.NumAtoms() minAtoms = min(nAtomsRef, nAtomsFit) diff --git a/wwpdb/utils/oe_util/oedepict/OeDepict.py b/wwpdb/utils/oe_util/oedepict/OeDepict.py old mode 100755 new mode 100644 index a62b84b..acb1a7e --- a/wwpdb/utils/oe_util/oedepict/OeDepict.py +++ b/wwpdb/utils/oe_util/oedepict/OeDepict.py @@ -13,6 +13,7 @@ Classes to build 2D OE molecule depictions from ChemComp definitions. """ + __docformat__ = "restructuredtext en" __author__ = "John Westbrook" __email__ = "jwest@rcsb.rutgers.edu" @@ -63,11 +64,10 @@ def CreateCopy(self): return copy.__disown__() -class OeDepictBase(object): - +class OeDepictBase: """Base class for 2D depictions in single and multi-page format.""" - def __init__(self, verbose=True, log=sys.stderr): # pylint: disable=unused-argument + def __init__(self, verbose=True, log=sys.stderr): # noqa: ARG002 pylint: disable=unused-argument super(OeDepictBase, self).__init__() # self.__verbose = verbose # self.__debug = False @@ -142,11 +142,9 @@ def _assignDisplayOptions(self): # # 5.0 is minimum size - self._opts.SetTitleHeight(5.0) - # class OeDepictMultiPage(OeDepictBase): - """Create 2D depictions in multipage format from a list of OE molecules and title strings""" def __init__(self, verbose=True, log=sys.stderr, useTitle=True): @@ -155,7 +153,6 @@ def __init__(self, verbose=True, log=sys.stderr, useTitle=True): # self.__debug = False # self.__lfh = log self.__useTitle = useTitle - # self.__multi = None self.__image = None @@ -185,7 +182,6 @@ def prepare(self): citer = grid.GetCells() cell = citer.Target() - # if self._params["suppressHydrogens"]: mol = oeMol.getGraphMolSuppressH() else: @@ -196,8 +192,6 @@ def prepare(self): self._opts.SetTitleHeight(5.0) else: mol.SetTitle("") - # - # OEPrepareDepiction(mol) self._opts.SetDimensions(cell.GetWidth(), cell.GetHeight(), OEScale_AutoScale) self._assignDisplayOptions() @@ -213,7 +207,6 @@ def write(self, imagePath): class OeDepict(OeDepictBase): - """Create 2D depictions in single-page format from a list of OE molecules & title strings""" def __init__(self, verbose=True, log=sys.stderr, useTitle=True): @@ -222,19 +215,16 @@ def __init__(self, verbose=True, log=sys.stderr, useTitle=True): self.__debug = False self.__lfh = log self.__useTitle = useTitle - # self.__image = None self.__grid = None def __setupImage(self): """Internal method to configure a single page image.""" - # self.__image = OEImage(self._params["imageSizeX"], self._params["imageSizeY"]) self.__grid = OEImageGrid(self.__image, self._params["gridRows"], self._params["gridCols"]) self.__grid.SetCellGap(self._params["cellGap"]) self.__grid.SetMargins(self._params["cellMargin"]) self._opts = OE2DMolDisplayOptions(self.__grid.GetCellWidth(), self.__grid.GetCellHeight(), OEScale_AutoScale) - # if self.__debug: self.__lfh.write("Num columns %d\n" % self.__grid.NumCols()) self.__lfh.write("Num rows %d\n" % self.__grid.NumRows()) @@ -245,7 +235,6 @@ def prepare(self): mollist = list(self._molTitleList) for idx, cell in enumerate(self.__grid.GetCells()): _ccId, oeMol, title = mollist[idx] - # if self._params["suppressHydrogens"]: mol = oeMol.getGraphMolSuppressH() else: @@ -255,8 +244,6 @@ def prepare(self): self._opts.SetTitleHeight(5.0) else: mol.SetTitle("") - # - # OEPrepareDepiction(mol) self._opts.SetDimensions(cell.GetWidth(), cell.GetHeight(), OEScale_AutoScale) diff --git a/wwpdb/utils/oe_util/oedepict/simple-example.py b/wwpdb/utils/oe_util/oedepict/simple-example.py index 39a4fa0..1038445 100644 --- a/wwpdb/utils/oe_util/oedepict/simple-example.py +++ b/wwpdb/utils/oe_util/oedepict/simple-example.py @@ -11,6 +11,7 @@ An example of generating 2D chemical diagrams in svg format from chemical component definition. """ + __docformat__ = "restructuredtext en" __author__ = "John Westbrook" __email__ = "jwest@rcsb.rutgers.edu" @@ -49,12 +50,19 @@ def testDepictIdList(self): oeMolTitleList = self.__makeFromIdList(idList=self.__idList) if self.__verbose: self.__lfh.write("molTitleList length is %d\n" % len(oeMolTitleList)) - # for ccId, mol, title in oeMolTitleList: imagePath = ccId + ".svg" oed = OeDepict(verbose=self.__verbose, log=self.__lfh) oed.setMolTitleList([(ccId, mol, title)]) - oed.setDisplayOptions(imageX=250, imageY=250, labelAtomName=True, labelAtomCIPStereo=True, labelAtomIndex=False, labelBondIndex=False, bondDisplayWidth=0.5) + oed.setDisplayOptions( + imageX=250, + imageY=250, + labelAtomName=True, + labelAtomCIPStereo=True, + labelAtomIndex=False, + labelBondIndex=False, + bondDisplayWidth=0.5, + ) oed.setGridOptions(rows=1, cols=1) oed.prepare() oed.write(imagePath) @@ -88,4 +96,3 @@ def suiteDepict(): if __name__ == "__main__": mySuite2 = suiteDepict() unittest.TextTestRunner(verbosity=2).run(mySuite2) - #