From ab6bd1408ae8528f514a49558299b640522c0269 Mon Sep 17 00:00:00 2001 From: Brandon Duane Walker Date: Mon, 25 Mar 2024 16:32:49 -0400 Subject: [PATCH] add ict sanitize ligand --- .../sanitize-ligand-tool}/.bumpversion.cfg | 4 +- .../sanitize-ligand-tool}/.dockerignore | 0 .../sanitize-ligand-tool}/CHANGELOG.md | 0 .../diffdock/sanitize-ligand-tool}/Dockerfile | 19 +- .../diffdock/sanitize-ligand-tool}/README.md | 2 +- .../diffdock/sanitize-ligand-tool/VERSION | 1 + .../diffdock/sanitize-ligand-tool/ict.yml | 25 + .../sanitize-ligand-tool}/pyproject.toml | 7 +- .../sanitize_ligand_0@1@0.cwl | 65 ++ .../src/polus/mm/utils/__init__.py | 2 +- .../src/polus/mm/utils/__main__.py | 36 ++ .../src/polus/mm/utils/sanitize_ligand.py | 50 +- .../sanitize-ligand-tool}/tests/__init__.py | 0 .../sanitize-ligand-tool/tests/ligand.sdf | 606 ++++++++++++++++++ .../tests/test_sanitize.py | 52 ++ utils/sanitize-ligand-plugin/VERSION | 1 - utils/sanitize-ligand-plugin/build-docker.sh | 4 - utils/sanitize-ligand-plugin/plugin.json | 36 -- utils/sanitize-ligand-plugin/run-plugin.sh | 13 - .../src/polus/mm/utils/__main__.py | 63 -- .../tests/test_sanitize.py | 26 - 21 files changed, 820 insertions(+), 192 deletions(-) rename utils/{sanitize-ligand-plugin => docking/diffdock/sanitize-ligand-tool}/.bumpversion.cfg (89%) rename utils/{sanitize-ligand-plugin => docking/diffdock/sanitize-ligand-tool}/.dockerignore (100%) rename utils/{sanitize-ligand-plugin => docking/diffdock/sanitize-ligand-tool}/CHANGELOG.md (100%) rename utils/{sanitize-ligand-plugin => docking/diffdock/sanitize-ligand-tool}/Dockerfile (51%) rename utils/{sanitize-ligand-plugin => docking/diffdock/sanitize-ligand-tool}/README.md (95%) create mode 100644 utils/docking/diffdock/sanitize-ligand-tool/VERSION create mode 100644 utils/docking/diffdock/sanitize-ligand-tool/ict.yml rename utils/{sanitize-ligand-plugin => docking/diffdock/sanitize-ligand-tool}/pyproject.toml (87%) create mode 100644 utils/docking/diffdock/sanitize-ligand-tool/sanitize_ligand_0@1@0.cwl rename utils/{sanitize-ligand-plugin => docking/diffdock/sanitize-ligand-tool}/src/polus/mm/utils/__init__.py (82%) create mode 100644 utils/docking/diffdock/sanitize-ligand-tool/src/polus/mm/utils/__main__.py rename utils/{sanitize-ligand-plugin => docking/diffdock/sanitize-ligand-tool}/src/polus/mm/utils/sanitize_ligand.py (85%) rename utils/{sanitize-ligand-plugin => docking/diffdock/sanitize-ligand-tool}/tests/__init__.py (100%) create mode 100755 utils/docking/diffdock/sanitize-ligand-tool/tests/ligand.sdf create mode 100644 utils/docking/diffdock/sanitize-ligand-tool/tests/test_sanitize.py delete mode 100644 utils/sanitize-ligand-plugin/VERSION delete mode 100755 utils/sanitize-ligand-plugin/build-docker.sh delete mode 100644 utils/sanitize-ligand-plugin/plugin.json delete mode 100755 utils/sanitize-ligand-plugin/run-plugin.sh delete mode 100644 utils/sanitize-ligand-plugin/src/polus/mm/utils/__main__.py delete mode 100644 utils/sanitize-ligand-plugin/tests/test_sanitize.py diff --git a/utils/sanitize-ligand-plugin/.bumpversion.cfg b/utils/docking/diffdock/sanitize-ligand-tool/.bumpversion.cfg similarity index 89% rename from utils/sanitize-ligand-plugin/.bumpversion.cfg rename to utils/docking/diffdock/sanitize-ligand-tool/.bumpversion.cfg index 8897a253..8c446ec5 100644 --- a/utils/sanitize-ligand-plugin/.bumpversion.cfg +++ b/utils/docking/diffdock/sanitize-ligand-tool/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.1.1-dev1 +current_version = 0.1.1-dev2 commit = False tag = False parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\-(?P[a-z]+)(?P\d+))? @@ -24,6 +24,6 @@ replace = version = "{new_version}" [bumpversion:file:README.md] -[bumpversion:file:plugin.json] +[bumpversion:file:ict.yml] [bumpversion:file:src/polus/mm/utils/__init__.py] diff --git a/utils/sanitize-ligand-plugin/.dockerignore b/utils/docking/diffdock/sanitize-ligand-tool/.dockerignore similarity index 100% rename from utils/sanitize-ligand-plugin/.dockerignore rename to utils/docking/diffdock/sanitize-ligand-tool/.dockerignore diff --git a/utils/sanitize-ligand-plugin/CHANGELOG.md b/utils/docking/diffdock/sanitize-ligand-tool/CHANGELOG.md similarity index 100% rename from utils/sanitize-ligand-plugin/CHANGELOG.md rename to utils/docking/diffdock/sanitize-ligand-tool/CHANGELOG.md diff --git a/utils/sanitize-ligand-plugin/Dockerfile b/utils/docking/diffdock/sanitize-ligand-tool/Dockerfile similarity index 51% rename from utils/sanitize-ligand-plugin/Dockerfile rename to utils/docking/diffdock/sanitize-ligand-tool/Dockerfile index 731c9690..762651c9 100644 --- a/utils/sanitize-ligand-plugin/Dockerfile +++ b/utils/docking/diffdock/sanitize-ligand-tool/Dockerfile @@ -1,4 +1,6 @@ -FROM condaforge/mambaforge +# docker build -f Dockerfile -t mrbrandonwalker/sanitize_ligand_tool . + +FROM python:3.11-buster # environment variables defined ENV EXEC_DIR="/opt/executables" @@ -8,20 +10,11 @@ COPY pyproject.toml ${EXEC_DIR} COPY VERSION ${EXEC_DIR} COPY README.md ${EXEC_DIR} COPY CHANGELOG.md ${EXEC_DIR} +# need copy src here because pyproject.toml has a reference to the src directory +COPY src ${EXEC_DIR}/src -RUN conda install -c conda-forge rdkit --yes - -RUN pip install filepattern - -RUN conda init bash - -RUN mamba clean --all --yes +WORKDIR ${EXEC_DIR} ADD Dockerfile ${EXEC_DIR} -COPY src ${EXEC_DIR}/src - RUN pip3 install ${EXEC_DIR} --no-cache-dir -# Default command. Additional arguments are provided through the command line -ENTRYPOINT ["python3", "-m", "polus.mm.utils"] -CMD ["--help"] diff --git a/utils/sanitize-ligand-plugin/README.md b/utils/docking/diffdock/sanitize-ligand-tool/README.md similarity index 95% rename from utils/sanitize-ligand-plugin/README.md rename to utils/docking/diffdock/sanitize-ligand-tool/README.md index cb70b45e..fec11070 100644 --- a/utils/sanitize-ligand-plugin/README.md +++ b/utils/docking/diffdock/sanitize-ligand-tool/README.md @@ -1,4 +1,4 @@ -# Sanitize Ligand (0.1.1-dev1) +# Sanitize Ligand (0.1.1-dev2) Handle molecules with rdkit errors gracefully. diff --git a/utils/docking/diffdock/sanitize-ligand-tool/VERSION b/utils/docking/diffdock/sanitize-ligand-tool/VERSION new file mode 100644 index 00000000..602bf8b2 --- /dev/null +++ b/utils/docking/diffdock/sanitize-ligand-tool/VERSION @@ -0,0 +1 @@ +0.1.1-dev2 diff --git a/utils/docking/diffdock/sanitize-ligand-tool/ict.yml b/utils/docking/diffdock/sanitize-ligand-tool/ict.yml new file mode 100644 index 00000000..e63d2086 --- /dev/null +++ b/utils/docking/diffdock/sanitize-ligand-tool/ict.yml @@ -0,0 +1,25 @@ +specVersion: 0.1.0 +name: labshare/sanitize-ligand +version: 0.1.1-dev2 +container: polusai/sanitize-ligand-tool:0.1.1-dev2 +entrypoint: "" +title: Sanitize Ligand +description: Handle molecules with rdkit errors gracefully. +author: Brandon Walker (brandon.walker@axleinfo.com) +repository: https://github.com/labshare/polus-plugins +documentation: https://ncats.nih.gov/preclinical/core/informatics +citation: "" +inputs: +- name: pattern + required: true + description: Filepattern to parse files + type: string +- name: indir + required: true + description: Input collection. + type: collection +outputs: +- name: outdir + required: false + description: Output collection. + type: collection diff --git a/utils/sanitize-ligand-plugin/pyproject.toml b/utils/docking/diffdock/sanitize-ligand-tool/pyproject.toml similarity index 87% rename from utils/sanitize-ligand-plugin/pyproject.toml rename to utils/docking/diffdock/sanitize-ligand-tool/pyproject.toml index 5fc68948..b600c919 100644 --- a/utils/sanitize-ligand-plugin/pyproject.toml +++ b/utils/docking/diffdock/sanitize-ligand-tool/pyproject.toml @@ -1,15 +1,16 @@ [tool.poetry] name = "mm-polus-sanitize-ligand" -version = "0.1.1-dev1" +version = "0.1.1-dev2" description = "Handle molecules with rdkit errors gracefully." authors = ["Brandon Walker "] readme = "README.md" packages = [{include = "polus", from = "src"}] [tool.poetry.dependencies] -python = ">=3.8" +python = ">=3.9,<3.12" typer = "^0.7.0" -rdkit = "*" +rdkit = "2024.3.3" +sophios = "0.1.1" [tool.poetry.group.dev.dependencies] bump2version = "^1.0.1" diff --git a/utils/docking/diffdock/sanitize-ligand-tool/sanitize_ligand_0@1@0.cwl b/utils/docking/diffdock/sanitize-ligand-tool/sanitize_ligand_0@1@0.cwl new file mode 100644 index 00000000..2faa7dfd --- /dev/null +++ b/utils/docking/diffdock/sanitize-ligand-tool/sanitize_ligand_0@1@0.cwl @@ -0,0 +1,65 @@ +#!/usr/bin/env cwl-runner +cwlVersion: v1.0 + +class: CommandLineTool + +label: Sanitize input ligand + +doc: |- + Sanitize input ligand + +baseCommand: ["python", "-m", "polus.mm.utils"] + +hints: + DockerRequirement: + dockerPull: mrbrandonwalker/sanitize_ligand_tool@sha256:6c272a427377e05ed2a83da5cdb3c00678b74b05c248f56c78d2349201f34d2f + +requirements: + InlineJavascriptRequirement: {} + InitialWorkDirRequirement: # conditionally overwrite the input ligand, otherwise cwltool will symlink to the original + listing: + - entry: $(inputs.input_small_mol_ligand) + writable: true + +inputs: + + input_small_mol_ligand: + type: File + format: edam:format_3814 + inputBinding: + prefix: --input_small_mol_ligand + + output_ligand: + type: string? + + valid_ligand: + type: string? + +outputs: + + output_ligand: + type: File + format: edam:format_3814 + outputBinding: + glob: "*.sdf" + + valid_ligand: + type: boolean + outputBinding: + glob: valid.txt + loadContents: true + outputEval: | + ${ + // Read the contents of the file + const lines = self[0].contents.split("\n"); + // Read boolean value from the first line + const valid = lines[0].trim() === "True"; + return valid; + + } + +$namespaces: + edam: https://edamontology.org/ + +$schemas: +- https://raw.githubusercontent.com/edamontology/edamontology/master/EDAM_dev.owl diff --git a/utils/sanitize-ligand-plugin/src/polus/mm/utils/__init__.py b/utils/docking/diffdock/sanitize-ligand-tool/src/polus/mm/utils/__init__.py similarity index 82% rename from utils/sanitize-ligand-plugin/src/polus/mm/utils/__init__.py rename to utils/docking/diffdock/sanitize-ligand-tool/src/polus/mm/utils/__init__.py index e7d940c4..d0e26db4 100644 --- a/utils/sanitize-ligand-plugin/src/polus/mm/utils/__init__.py +++ b/utils/docking/diffdock/sanitize-ligand-tool/src/polus/mm/utils/__init__.py @@ -1,6 +1,6 @@ """sanitize_ligand.""" -__version__ = "0.1.1-dev1" +__version__ = "0.1.1-dev2" from polus.mm.utils.sanitize_ligand import ( # pylint: disable=unused-import sanitize_ligand, diff --git a/utils/docking/diffdock/sanitize-ligand-tool/src/polus/mm/utils/__main__.py b/utils/docking/diffdock/sanitize-ligand-tool/src/polus/mm/utils/__main__.py new file mode 100644 index 00000000..db49b568 --- /dev/null +++ b/utils/docking/diffdock/sanitize-ligand-tool/src/polus/mm/utils/__main__.py @@ -0,0 +1,36 @@ +"""Package entrypoint for the sanitize_ligand package.""" + +# Base packages +import logging +from os import environ +from pathlib import Path + +import typer +from polus.mm.utils.sanitize_ligand import sanitize_ligand + +logging.basicConfig( + format="%(asctime)s - %(name)-8s - %(levelname)-8s - %(message)s", + datefmt="%d-%b-%y %H:%M:%S", +) +POLUS_LOG = getattr(logging, environ.get("POLUS_LOG", "INFO")) +logger = logging.getLogger("polus.mm.utils.sanitize_ligand") +logger.setLevel(POLUS_LOG) + +app = typer.Typer(help="Sanitize Ligand.") + + +@app.command() +def main( + input_small_mol_ligand: Path = typer.Option( + ..., + "--input_small_mol_ligand", + help="Input input_small_mol_ligand to be processed.", + ), +) -> None: + """Sanitize Ligand.""" + logger.info(f"input_small_mol_ligand: {input_small_mol_ligand}") + sanitize_ligand(input_small_mol_ligand) + + +if __name__ == "__main__": + app() diff --git a/utils/sanitize-ligand-plugin/src/polus/mm/utils/sanitize_ligand.py b/utils/docking/diffdock/sanitize-ligand-tool/src/polus/mm/utils/sanitize_ligand.py similarity index 85% rename from utils/sanitize-ligand-plugin/src/polus/mm/utils/sanitize_ligand.py rename to utils/docking/diffdock/sanitize-ligand-tool/src/polus/mm/utils/sanitize_ligand.py index 1bedb67e..462e0d3c 100644 --- a/utils/sanitize-ligand-plugin/src/polus/mm/utils/sanitize_ligand.py +++ b/utils/docking/diffdock/sanitize-ligand-tool/src/polus/mm/utils/sanitize_ligand.py @@ -162,36 +162,28 @@ def attempt_fix_ligand( return valid_lig, molecule -def sanitize_ligand( - ligand_files: list[Path], - outdir: Path, -) -> None: +def sanitize_ligand(input_small_mol_ligand: Path) -> None: """Sanitize ligand file. Args: - ligand_files: Ligand file pattern - outdir: Output directory + input_small_mol_ligand: Ligand file """ - for input_small_mol_ligand in ligand_files: - output_small_mol_ligand = outdir / Path(input_small_mol_ligand.name) - mol: Chem.SDMolSupplier = Chem.SDMolSupplier( - input_small_mol_ligand.resolve(), - sanitize=False, - removeHs=False, - )[0] - - valid_ligand = is_valid_ligand(mol) - if not valid_ligand: - valid_ligand, rdkit_mol = attempt_fix_ligand(mol) - else: - rdkit_mol = mol - - if valid_ligand: - with Chem.SDWriter(output_small_mol_ligand) as w: - w.write(rdkit_mol) - - if len(ligand_files) == 1: - # if scattering with many files - # let the presence of the file indicate validity - with outdir.joinpath("valid.txt").open("w", encoding="utf-8") as f: - f.write(str(valid_ligand)) + output_small_mol_ligand = Path(input_small_mol_ligand.name) + mol: Chem.SDMolSupplier = Chem.SDMolSupplier( + input_small_mol_ligand.resolve(), + sanitize=False, + removeHs=False, + )[0] + + valid_ligand = is_valid_ligand(mol) + if not valid_ligand: + valid_ligand, rdkit_mol = attempt_fix_ligand(mol) + else: + rdkit_mol = mol + + if valid_ligand: + with Chem.SDWriter(output_small_mol_ligand) as w: + w.write(rdkit_mol) + + with Path("valid.txt").open("w", encoding="utf-8") as f: + f.write(str(valid_ligand)) diff --git a/utils/sanitize-ligand-plugin/tests/__init__.py b/utils/docking/diffdock/sanitize-ligand-tool/tests/__init__.py similarity index 100% rename from utils/sanitize-ligand-plugin/tests/__init__.py rename to utils/docking/diffdock/sanitize-ligand-tool/tests/__init__.py diff --git a/utils/docking/diffdock/sanitize-ligand-tool/tests/ligand.sdf b/utils/docking/diffdock/sanitize-ligand-tool/tests/ligand.sdf new file mode 100755 index 00000000..7394f02a --- /dev/null +++ b/utils/docking/diffdock/sanitize-ligand-tool/tests/ligand.sdf @@ -0,0 +1,606 @@ +5291 + -OEChem-01262416063D + + 68 72 0 0 0 0 0 0 0999 V2000 + -0.8276 0.2486 -1.0418 O 0 0 0 0 0 0 0 0 0 0 0 0 + 6.4576 0.2661 -0.6555 N 0 0 0 0 0 0 0 0 0 0 0 0 + 8.5148 -0.1616 1.3305 N 0 0 0 0 0 0 0 0 0 0 0 0 + -0.1066 -1.8326 -0.2329 N 0 0 0 0 0 0 0 0 0 0 0 0 + -4.9447 -1.8876 -0.2704 N 0 0 0 0 0 0 0 0 0 0 0 0 + -4.3746 0.3576 0.1045 N 0 0 0 0 0 0 0 0 0 0 0 0 + -6.6079 -0.2578 -0.5599 N 0 0 0 0 0 0 0 0 0 0 0 0 + -2.8521 4.8337 0.2988 N 0 0 0 0 0 0 0 0 0 0 0 0 + 6.1553 0.3240 0.7799 C 0 0 0 0 0 0 0 0 0 0 0 0 + 7.8492 0.6633 -0.9021 C 0 0 0 0 0 0 0 0 0 0 0 0 + 7.1228 -0.5578 1.5768 C 0 0 0 0 0 0 0 0 0 0 0 0 + 8.8175 -0.2175 -0.1048 C 0 0 0 0 0 0 0 0 0 0 0 0 + 5.5353 1.1080 -1.4148 C 0 0 0 0 0 0 0 0 0 0 0 0 + 9.4364 -1.0051 2.0887 C 0 0 0 0 0 0 0 0 0 0 0 0 + 4.1042 0.6761 -1.2347 C 0 0 0 0 0 0 0 0 0 0 0 0 + 3.7827 -0.6720 -1.3051 C 0 0 0 0 0 0 0 0 0 0 0 0 + 3.1263 1.6331 -1.0017 C 0 0 0 0 0 0 0 0 0 0 0 0 + 2.4565 -1.0715 -1.1393 C 0 0 0 0 0 0 0 0 0 0 0 0 + 1.8002 1.2338 -0.8357 C 0 0 0 0 0 0 0 0 0 0 0 0 + 1.4653 -0.1185 -0.9046 C 0 0 0 0 0 0 0 0 0 0 0 0 + 0.0830 -0.5355 -0.7298 C 0 0 0 0 0 0 0 0 0 0 0 0 + -1.3242 -2.5126 0.0151 C 0 0 0 0 0 0 0 0 0 0 0 0 + -3.7215 -2.5414 -0.0031 C 0 0 0 0 0 0 0 0 0 0 0 0 + -2.5228 -1.8710 -0.2463 C 0 0 0 0 0 0 0 0 0 0 0 0 + -3.7034 -3.8430 0.4979 C 0 0 0 0 0 0 0 0 0 0 0 0 + -1.2879 -3.8040 0.5124 C 0 0 0 0 0 0 0 0 0 0 0 0 + -2.4866 -4.4744 0.7558 C 0 0 0 0 0 0 0 0 0 0 0 0 + -4.9723 -4.5838 0.7689 C 0 0 0 0 0 0 0 0 0 0 0 0 + -5.3266 -0.5337 -0.2407 C 0 0 0 0 0 0 0 0 0 0 0 0 + -4.7751 1.6458 0.1230 C 0 0 0 0 0 0 0 0 0 0 0 0 + -3.7560 2.5992 0.4912 C 0 0 0 0 0 0 0 0 0 0 0 0 + -6.0569 2.0547 -0.1837 C 0 0 0 0 0 0 0 0 0 0 0 0 + -6.9398 1.0495 -0.5211 C 0 0 0 0 0 0 0 0 0 0 0 0 + -2.7243 2.2490 1.3556 C 0 0 0 0 0 0 0 0 0 0 0 0 + -3.7742 3.8929 -0.0052 C 0 0 0 0 0 0 0 0 0 0 0 0 + -1.7569 3.1894 1.6923 C 0 0 0 0 0 0 0 0 0 0 0 0 + -1.8648 4.4564 1.1418 C 0 0 0 0 0 0 0 0 0 0 0 0 + 6.2161 1.3575 1.1487 H 0 0 0 0 0 0 0 0 0 0 0 0 + 5.1467 -0.0373 1.0060 H 0 0 0 0 0 0 0 0 0 0 0 0 + 8.0827 0.5537 -1.9681 H 0 0 0 0 0 0 0 0 0 0 0 0 + 8.0090 1.7178 -0.6393 H 0 0 0 0 0 0 0 0 0 0 0 0 + 6.8911 -0.4479 2.6432 H 0 0 0 0 0 0 0 0 0 0 0 0 + 6.9627 -1.6124 1.3143 H 0 0 0 0 0 0 0 0 0 0 0 0 + 8.7669 -1.2503 -0.4758 H 0 0 0 0 0 0 0 0 0 0 0 0 + 9.8378 0.1434 -0.2827 H 0 0 0 0 0 0 0 0 0 0 0 0 + 5.6549 2.1619 -1.1291 H 0 0 0 0 0 0 0 0 0 0 0 0 + 5.7622 1.0411 -2.4869 H 0 0 0 0 0 0 0 0 0 0 0 0 + 10.4708 -0.6770 1.9372 H 0 0 0 0 0 0 0 0 0 0 0 0 + 9.3641 -2.0606 1.8025 H 0 0 0 0 0 0 0 0 0 0 0 0 + 9.2357 -0.9248 3.1628 H 0 0 0 0 0 0 0 0 0 0 0 0 + 4.5361 -1.4277 -1.5094 H 0 0 0 0 0 0 0 0 0 0 0 0 + 3.3744 2.6892 -0.9456 H 0 0 0 0 0 0 0 0 0 0 0 0 + 2.2390 -2.1304 -1.2426 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1.0439 1.9918 -0.6479 H 0 0 0 0 0 0 0 0 0 0 0 0 + 0.7149 -2.3706 0.0288 H 0 0 0 0 0 0 0 0 0 0 0 0 + -2.5694 -0.8966 -0.6987 H 0 0 0 0 0 0 0 0 0 0 0 0 + -0.3457 -4.3050 0.7161 H 0 0 0 0 0 0 0 0 0 0 0 0 + -2.4543 -5.4884 1.1455 H 0 0 0 0 0 0 0 0 0 0 0 0 + -5.7332 -2.5044 -0.4357 H 0 0 0 0 0 0 0 0 0 0 0 0 + -5.6194 -4.0112 1.4417 H 0 0 0 0 0 0 0 0 0 0 0 0 + -4.7836 -5.5486 1.2524 H 0 0 0 0 0 0 0 0 0 0 0 0 + -5.5050 -4.7850 -0.1664 H 0 0 0 0 0 0 0 0 0 0 0 0 + -6.3940 3.0829 -0.1521 H 0 0 0 0 0 0 0 0 0 0 0 0 + -7.9712 1.2730 -0.7724 H 0 0 0 0 0 0 0 0 0 0 0 0 + -2.6516 1.2546 1.7888 H 0 0 0 0 0 0 0 0 0 0 0 0 + -4.5283 4.2446 -0.7026 H 0 0 0 0 0 0 0 0 0 0 0 0 + -0.9444 2.9389 2.3645 H 0 0 0 0 0 0 0 0 0 0 0 0 + -1.1356 5.2260 1.3726 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1 21 2 0 0 0 0 + 2 9 1 0 0 0 0 + 2 10 1 0 0 0 0 + 2 13 1 0 0 0 0 + 3 11 1 0 0 0 0 + 3 12 1 0 0 0 0 + 3 14 1 0 0 0 0 + 4 21 1 0 0 0 0 + 4 22 1 0 0 0 0 + 4 55 1 0 0 0 0 + 5 23 1 0 0 0 0 + 5 29 1 0 0 0 0 + 5 59 1 0 0 0 0 + 6 29 1 0 0 0 0 + 6 30 2 0 0 0 0 + 7 29 2 0 0 0 0 + 7 33 1 0 0 0 0 + 8 35 1 0 0 0 0 + 8 37 2 0 0 0 0 + 9 11 1 0 0 0 0 + 9 38 1 0 0 0 0 + 9 39 1 0 0 0 0 + 10 12 1 0 0 0 0 + 10 40 1 0 0 0 0 + 10 41 1 0 0 0 0 + 11 42 1 0 0 0 0 + 11 43 1 0 0 0 0 + 12 44 1 0 0 0 0 + 12 45 1 0 0 0 0 + 13 15 1 0 0 0 0 + 13 46 1 0 0 0 0 + 13 47 1 0 0 0 0 + 14 48 1 0 0 0 0 + 14 49 1 0 0 0 0 + 14 50 1 0 0 0 0 + 15 16 2 0 0 0 0 + 15 17 1 0 0 0 0 + 16 18 1 0 0 0 0 + 16 51 1 0 0 0 0 + 17 19 2 0 0 0 0 + 17 52 1 0 0 0 0 + 18 20 2 0 0 0 0 + 18 53 1 0 0 0 0 + 19 20 1 0 0 0 0 + 19 54 1 0 0 0 0 + 20 21 1 0 0 0 0 + 22 24 2 0 0 0 0 + 22 26 1 0 0 0 0 + 23 24 1 0 0 0 0 + 23 25 2 0 0 0 0 + 24 56 1 0 0 0 0 + 25 27 1 0 0 0 0 + 25 28 1 0 0 0 0 + 26 27 2 0 0 0 0 + 26 57 1 0 0 0 0 + 27 58 1 0 0 0 0 + 28 60 1 0 0 0 0 + 28 61 1 0 0 0 0 + 28 62 1 0 0 0 0 + 30 31 1 0 0 0 0 + 30 32 1 0 0 0 0 + 31 34 1 0 0 0 0 + 31 35 2 0 0 0 0 + 32 33 2 0 0 0 0 + 32 63 1 0 0 0 0 + 33 64 1 0 0 0 0 + 34 36 2 0 0 0 0 + 34 65 1 0 0 0 0 + 35 66 1 0 0 0 0 + 36 37 1 0 0 0 0 + 36 67 1 0 0 0 0 + 37 68 1 0 0 0 0 +M END +> +5291 + +> +1 + +> +1 +86 +183 +155 +18 +49 +271 +197 +51 +136 +137 +264 +53 +161 +199 +59 +223 +60 +118 +279 +56 +163 +275 +127 +135 +154 +220 +196 +244 +114 +219 +200 +150 +221 +277 +145 +88 +139 +280 +283 +140 +75 +232 +43 +186 +249 +78 +133 +207 +238 +250 +132 +201 +243 +191 +102 +71 +260 +176 +187 +97 +164 +205 +255 +92 +110 +209 +106 +178 +3 +162 +265 +134 +213 +151 +72 +57 +228 +65 +23 +192 +251 +174 +138 +41 +204 +120 +242 +93 +100 +47 +165 +107 +158 +144 +214 +274 +46 +156 +113 +119 +37 +143 +245 +273 +50 +177 +281 +87 +45 +227 +152 +123 +224 +35 +171 +278 +32 +95 +44 +58 +235 +188 +80 +89 +52 +141 +157 +248 +284 +175 +40 +190 +246 +193 +166 +236 +74 +230 +101 +179 +215 +268 +14 +83 +131 +104 +239 +167 +267 +19 +234 +85 +254 +5 +229 +206 +36 +269 +153 +160 +194 +129 +108 +79 +68 +226 +67 +173 +122 +266 +55 +17 +180 +142 +61 +54 +112 +257 +76 +94 +225 +64 +272 +211 +185 +217 +121 +149 +195 +20 +169 +98 +147 +261 +105 +262 +259 +48 +212 +22 +27 +263 +222 +208 +128 +148 +117 +168 +33 +170 +15 +130 +25 +62 +90 +84 +256 +21 +4 +276 +241 +126 +270 +38 +282 +26 +124 +202 +252 +2 +109 +198 +111 +172 +77 +115 +28 +10 +181 +182 +203 +6 +231 +237 +31 +184 +69 +146 +13 +81 +247 +159 +82 +91 +210 +258 +7 +189 +29 +253 +70 +66 +218 +42 +103 +30 +11 +233 +73 +96 +63 +39 +240 +34 +16 +99 +9 +216 +12 +125 +116 +8 +24 + +> +51 +1 -0.57 +10 0.27 +11 0.27 +12 0.27 +13 0.41 +14 0.27 +15 -0.14 +16 -0.15 +17 -0.15 +18 -0.15 +19 -0.15 +2 -0.81 +20 0.09 +21 0.54 +22 0.12 +23 0.1 +24 -0.15 +25 -0.14 +26 -0.15 +27 -0.15 +28 0.14 +29 0.72 +3 -0.81 +30 0.31 +32 -0.15 +33 0.16 +34 -0.15 +35 0.16 +36 -0.15 +37 0.16 +4 -0.55 +5 -0.6 +51 0.15 +52 0.15 +53 0.15 +54 0.15 +55 0.37 +56 0.15 +57 0.15 +58 0.15 +59 0.4 +6 -0.62 +63 0.15 +64 0.15 +65 0.15 +66 0.15 +67 0.15 +68 0.15 +7 -0.62 +8 -0.62 +9 0.27 + +> +9.2 + +> +13 +1 1 acceptor +1 2 cation +1 3 cation +1 4 donor +1 5 donor +1 6 acceptor +1 8 acceptor +4 5 6 7 29 cation +6 15 16 17 18 19 20 rings +6 2 3 9 10 11 12 rings +6 22 23 24 25 26 27 rings +6 6 7 29 30 32 33 rings +6 8 31 34 35 36 37 rings + +> +37 + +> +0 + +> +0 + +> +0 + +> +0 + +> +0 + +> +1 + +> +6 + +> +000014AB00000001 + +> +127.2169 + +> +65.975 + +> +100830 39 18410860958077041852 +10951579 204 18197238974742643908 +11007060 377 18269849622327105530 +11136131 41 18044936770771598434 +11621639 254 13254505501323013082 +12104220 1 18410571777702331213 +12107183 9 18186798084917518398 +12128747 34 18130230354994079454 +12144603 126 17894916257231727846 +12202916 173 18131347506142367149 +13947947 74 18272087151057125825 +15021287 119 16732703852714263934 +15328829 1 17967526866235903152 +15351339 4 18338230471684522579 +15400415 2 17762632689221619973 +15419008 47 17703511077306660712 +15776043 110 17967251962395703306 +15890870 6 18335419046485918677 +16112460 7 18114460063985995098 +19611394 137 18201999945758235216 +21133410 221 17845067714652049024 +21639891 77 18130510820416437024 +21792964 463 17608105478808388188 +21859007 373 18202281416502593174 +23522609 53 17605017917245182908 +23569943 247 16661465382439943786 +3504750 166 18339919432792631702 +42626532 9 17974577093311653163 +5047190 69 18343860034915745032 +5085150 59 18342738516023217790 +6201320 215 18059005086968776344 +6371009 1 18409733936799028949 +9981440 41 18191600661755950473 + +> +720.71 +23.61 +5.87 +1.43 +55.18 +0.71 +-0.37 +0.19 +-5.12 +-14.21 +-2.53 +2.61 +-0.31 +-1.28 + +> +1568.426 + +> +390.1 + +> +2 +5 +10 + +$$$$ diff --git a/utils/docking/diffdock/sanitize-ligand-tool/tests/test_sanitize.py b/utils/docking/diffdock/sanitize-ligand-tool/tests/test_sanitize.py new file mode 100644 index 00000000..dad9fbf4 --- /dev/null +++ b/utils/docking/diffdock/sanitize-ligand-tool/tests/test_sanitize.py @@ -0,0 +1,52 @@ +"""Test the sanitize_ligand plugin.""" +from pathlib import Path + +import pytest +from polus.mm.utils.sanitize_ligand import attempt_fix_ligand +from rdkit import Chem +from sophios.api.pythonapi import Step +from sophios.api.pythonapi import Workflow + + +@pytest.mark.catch_error() +def test_kekulization_error_catch() -> None: + """Test catching Kekulization error. + + Can't kekulize mol. Unkekulized atoms: 6 7 8 9 10. + """ + mol = Chem.MolFromSmiles("c1ccc(cc1)-c1nnc(n1)-c1ccccc1") + valid_ligand, rdkit_mol = attempt_fix_ligand(mol) + assert not valid_ligand + + +@pytest.mark.fix_ligand() +def test_fix_explicit_valence_error() -> None: + """Test fixing explicit valence error. + + Explicit valence for atom # 1 C, 5, is greater than permitted + """ + mol = Chem.MolFromSmiles("c1c(ccc2NC(CN=c(c21)(C)C)=O)O", sanitize=False) + valid_ligand, rdkit_mol = attempt_fix_ligand(mol) + assert valid_ligand + + +def test_cwl_sanitize_ligand() -> None: + """Test the convert_pdbqt function.""" + cwl_file = Path("sanitize_ligand_0@1@0.cwl") + ligand_path = "ligand.sdf" + ligand_path = str(Path(__file__).resolve().parent / Path(ligand_path)) + sanitize_ligand_step = Step(clt_path=cwl_file) + sanitize_ligand_step.input_small_mol_ligand = ligand_path + + steps = [sanitize_ligand_step] + filename = "sanitize_ligand" + workflow = Workflow(steps, filename) + + workflow.run() + + outdir = Path("outdir") + files = list(outdir.rglob("ligand.sdf")) + + assert ( + files + ), f"The file ligand.sdf does not exist in any subdirectory of '{outdir}'." diff --git a/utils/sanitize-ligand-plugin/VERSION b/utils/sanitize-ligand-plugin/VERSION deleted file mode 100644 index 916e7d19..00000000 --- a/utils/sanitize-ligand-plugin/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.1.1-dev1 diff --git a/utils/sanitize-ligand-plugin/build-docker.sh b/utils/sanitize-ligand-plugin/build-docker.sh deleted file mode 100755 index 935ea0c1..00000000 --- a/utils/sanitize-ligand-plugin/build-docker.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -version=$( None: - """Sanitize Ligand.""" - logger.info(f"pattern: {pattern}") - logger.info(f"indir: {in_dir}") - logger.info(f"outdir: {out_dir}") - ligand_file_paths = [] - ligand_files = fp.FilePattern(in_dir, pattern) - for input_small_mol_ligand in ligand_files(): - ligand = input_small_mol_ligand[-1][0] - ligand_file_paths.append(ligand) - - sanitize_ligand(ligand_file_paths, out_dir) - - -if __name__ == "__main__": - app() diff --git a/utils/sanitize-ligand-plugin/tests/test_sanitize.py b/utils/sanitize-ligand-plugin/tests/test_sanitize.py deleted file mode 100644 index 829d7b51..00000000 --- a/utils/sanitize-ligand-plugin/tests/test_sanitize.py +++ /dev/null @@ -1,26 +0,0 @@ -"""Test the sanitize_ligand plugin.""" -import pytest -from rdkit import Chem -from src.polus.mm.utils.sanitize_ligand import attempt_fix_ligand - - -@pytest.mark.catch_error() -def test_kekulization_error_catch() -> None: - """Test catching Kekulization error. - - Can't kekulize mol. Unkekulized atoms: 6 7 8 9 10. - """ - mol = Chem.MolFromSmiles("c1ccc(cc1)-c1nnc(n1)-c1ccccc1") - valid_ligand, rdkit_mol = attempt_fix_ligand(mol) - assert not valid_ligand - - -@pytest.mark.fix_ligand() -def test_fix_explicit_valence_error() -> None: - """Test fixing explicit valence error. - - Explicit valence for atom # 1 C, 5, is greater than permitted - """ - mol = Chem.MolFromSmiles("c1c(ccc2NC(CN=c(c21)(C)C)=O)O", sanitize=False) - valid_ligand, rdkit_mol = attempt_fix_ligand(mol) - assert valid_ligand