From 4f35e0460055bb3ce610680d419cf93db43ce16c Mon Sep 17 00:00:00 2001 From: Nazanin Donyapour Date: Wed, 10 Apr 2024 16:22:13 -0400 Subject: [PATCH] autodock_vina_rescore --- .../.bumpversion.cfg | 29 ++++ .../.dockerignore | 4 + .../.gitattributes | 2 + utils/autodock-vina-rescore-plugin/.gitignore | 1 + .../autodock-vina-rescore-plugin/CHANGELOG.md | 5 + utils/autodock-vina-rescore-plugin/Dockerfile | 22 +++ utils/autodock-vina-rescore-plugin/README.md | 19 +++ utils/autodock-vina-rescore-plugin/VERSION | 1 + .../autodock_vina_rescore_0@1@0.cwl | 161 ++++++++++++++++++ .../build-docker.sh | 4 + utils/autodock-vina-rescore-plugin/ict.yml | 89 ++++++++++ .../pyproject.toml | 30 ++++ .../tests/__init__.py | 1 + .../tests/ligand.pdbqt | 3 + .../tests/receptor.pdbqt | 3 + .../tests/test_autodock_vina_rescore.py | 34 ++++ 16 files changed, 408 insertions(+) create mode 100644 utils/autodock-vina-rescore-plugin/.bumpversion.cfg create mode 100644 utils/autodock-vina-rescore-plugin/.dockerignore create mode 100644 utils/autodock-vina-rescore-plugin/.gitattributes create mode 100644 utils/autodock-vina-rescore-plugin/.gitignore create mode 100644 utils/autodock-vina-rescore-plugin/CHANGELOG.md create mode 100644 utils/autodock-vina-rescore-plugin/Dockerfile create mode 100644 utils/autodock-vina-rescore-plugin/README.md create mode 100644 utils/autodock-vina-rescore-plugin/VERSION create mode 100644 utils/autodock-vina-rescore-plugin/autodock_vina_rescore_0@1@0.cwl create mode 100644 utils/autodock-vina-rescore-plugin/build-docker.sh create mode 100644 utils/autodock-vina-rescore-plugin/ict.yml create mode 100644 utils/autodock-vina-rescore-plugin/pyproject.toml create mode 100644 utils/autodock-vina-rescore-plugin/tests/__init__.py create mode 100644 utils/autodock-vina-rescore-plugin/tests/ligand.pdbqt create mode 100644 utils/autodock-vina-rescore-plugin/tests/receptor.pdbqt create mode 100644 utils/autodock-vina-rescore-plugin/tests/test_autodock_vina_rescore.py diff --git a/utils/autodock-vina-rescore-plugin/.bumpversion.cfg b/utils/autodock-vina-rescore-plugin/.bumpversion.cfg new file mode 100644 index 00000000..107cb1ca --- /dev/null +++ b/utils/autodock-vina-rescore-plugin/.bumpversion.cfg @@ -0,0 +1,29 @@ +[bumpversion] +current_version = 0.1.0 +commit = False +tag = False +parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\-(?P[a-z]+)(?P\d+))? +serialize = + {major}.{minor}.{patch}-{release}{dev} + {major}.{minor}.{patch} + +[bumpversion:part:release] +optional_value = _ +first_value = dev +values = + dev + _ + +[bumpversion:part:dev] + +[bumpversion:file:pyproject.toml] +search = version = "{current_version}" +replace = version = "{new_version}" + +[bumpversion:file:VERSION] + +[bumpversion:file:README.md] + +[bumpversion:file:plugin.json] + +[bumpversion:file:src/polus/mm/utils/autodock_vina_rescore/__init__.py] diff --git a/utils/autodock-vina-rescore-plugin/.dockerignore b/utils/autodock-vina-rescore-plugin/.dockerignore new file mode 100644 index 00000000..7c603f81 --- /dev/null +++ b/utils/autodock-vina-rescore-plugin/.dockerignore @@ -0,0 +1,4 @@ +.venv +out +tests +__pycache__ diff --git a/utils/autodock-vina-rescore-plugin/.gitattributes b/utils/autodock-vina-rescore-plugin/.gitattributes new file mode 100644 index 00000000..2fb87472 --- /dev/null +++ b/utils/autodock-vina-rescore-plugin/.gitattributes @@ -0,0 +1,2 @@ +*.pdb filter=lfs diff=lfs merge=lfs -text +*.pdbqt filter=lfs diff=lfs merge=lfs -text diff --git a/utils/autodock-vina-rescore-plugin/.gitignore b/utils/autodock-vina-rescore-plugin/.gitignore new file mode 100644 index 00000000..c04bc49f --- /dev/null +++ b/utils/autodock-vina-rescore-plugin/.gitignore @@ -0,0 +1 @@ +poetry.lock diff --git a/utils/autodock-vina-rescore-plugin/CHANGELOG.md b/utils/autodock-vina-rescore-plugin/CHANGELOG.md new file mode 100644 index 00000000..b67793f7 --- /dev/null +++ b/utils/autodock-vina-rescore-plugin/CHANGELOG.md @@ -0,0 +1,5 @@ +# CHANGELOG + +## 0.1.0 + +Initial release. diff --git a/utils/autodock-vina-rescore-plugin/Dockerfile b/utils/autodock-vina-rescore-plugin/Dockerfile new file mode 100644 index 00000000..14a1eafa --- /dev/null +++ b/utils/autodock-vina-rescore-plugin/Dockerfile @@ -0,0 +1,22 @@ +FROM condaforge/miniforge3 +# NOT miniforge-pypy3 (The build process is incompatible with pypy) + +# RUN conda install -c conda-forge vina + +RUN apt-get update && apt-get install -y git +RUN git clone https://github.com/ccsb-scripps/AutoDock-Vina.git + +# Prevent being prompted for geographical region +ARG DEBIAN_FRONTEND=noninteractive + +# Build vina binary +RUN apt-get update && apt-get install -y build-essential libboost-all-dev swig +RUN cd AutoDock-Vina/build/linux/release && make +# Since there is no make install, manually copy vina +RUN cp AutoDock-Vina/build/linux/release/vina /usr/bin/ + +# Build and install python bindings +RUN conda install -c conda-forge numpy boost-cpp swig +RUN cd AutoDock-Vina/build/python && python setup.py build install + +ADD Dockerfile . diff --git a/utils/autodock-vina-rescore-plugin/README.md b/utils/autodock-vina-rescore-plugin/README.md new file mode 100644 index 00000000..99f49514 --- /dev/null +++ b/utils/autodock-vina-rescore-plugin/README.md @@ -0,0 +1,19 @@ +# autodock_vina_rescore (0.1.0) + +Wrapper of the AutoDock Vina software. + +## Options + +This plugin takes 6 input arguments and 3 output argument: + +| Name | Description | I/O | Type | Default | +|---------------|-------------------------|--------|--------|---------| +| input_ligand_pdbqt_path | Path to the input PDBQT ligand, Type: string, File type: input, Accepted formats: pdbqt, Example file: https://github.com/bioexcel/biobb_vs/raw/master/biobb_vs/test/data/vina/vina_ligand.pdbqt | Input | File | File | +| input_receptor_pdbqt_path | Path to the input PDBQT receptor, Type: string, File type: input, Accepted formats: pdbqt, Example file: https://github.com/bioexcel/biobb_vs/raw/master/biobb_vs/test/data/vina/vina_receptor.pdbqt | Input | File | File | +| local_only | Do local search only | Input | boolean | boolean | +| score_only | Do not do any conformational search; simply rescore. | Input | boolean | boolean | +| output_ligand_pdbqt_path | Path to the output PDBQT ligand, Type: string, File type: output, Accepted formats: pdbqt, Example file: https://github.com/bioexcel/biobb_vs/raw/master/biobb_vs/test/reference/vina/ref_output_vina.pdbqt | Input | string | string | +| output_log_path | Path to the log file, Type: string, File type: output, Accepted formats: log, Example file: https://github.com/bioexcel/biobb_vs/raw/master/biobb_vs/test/reference/vina/ref_output_vina.log | Input | string | string | +| output_ligand_pdbqt_path | Path to the output PDBQT files | Output | {'type': 'array', 'items': 'File'} | {'type': 'array', 'items': 'File'} | +| output_log_path | Path to the log file | Output | File | File | +| docking_score | Estimated Free Energy of Binding | Output | float | float | diff --git a/utils/autodock-vina-rescore-plugin/VERSION b/utils/autodock-vina-rescore-plugin/VERSION new file mode 100644 index 00000000..6e8bf73a --- /dev/null +++ b/utils/autodock-vina-rescore-plugin/VERSION @@ -0,0 +1 @@ +0.1.0 diff --git a/utils/autodock-vina-rescore-plugin/autodock_vina_rescore_0@1@0.cwl b/utils/autodock-vina-rescore-plugin/autodock_vina_rescore_0@1@0.cwl new file mode 100644 index 00000000..54155df9 --- /dev/null +++ b/utils/autodock-vina-rescore-plugin/autodock_vina_rescore_0@1@0.cwl @@ -0,0 +1,161 @@ + +#!/usr/bin/env cwl-runner +cwlVersion: v1.0 + +# NOTE: This file is nearly identical to autodock_vina_batch with the primary difference that +# --input_batch_pdbqt_path is replaced with --input_ligand_pdbqt_path. +# (For no obvious reason, --score_only only works with --ligand, not --batch) + +class: CommandLineTool + +label: Wrapper of the AutoDock Vina software. + +doc: |- + This class performs docking of the ligand to a set of grids describing the target protein via the AutoDock Vina software. + +baseCommand: vina # NOTE: Only version >=1.2 supports --batch! +arguments: +- "--autobox" +# NOTE: The documentation for --score_only claims "search space can be omitted" which is not quite correct; +# if you omit --center_* and --size_* you get "ERROR: Grid box dimensions must be greater than 0 Angstrom." +# However, adding --autobox works. + +hints: + DockerRequirement: + dockerPull: polusai/autodock-vina-tool@sha256:98e353a67fbe76c010647bc80e15c86bf1f1c34fef25f58a41ada1a831496114 + +requirements: + InlineJavascriptRequirement: {} +# InitialWorkDirRequirement is needed for --local_only, because vina writes out +# the optimized geometry in the same directory as input_ligand_pdbqt_path, +# which needs to be writeable. + InitialWorkDirRequirement: + listing: + - $(inputs.input_ligand_pdbqt_path) + +inputs: + input_ligand_pdbqt_path: + label: Path to the input PDBQT ligand + doc: |- + Path to the input PDBQT ligand + Type: string + File type: input + Accepted formats: pdbqt + Example file: https://github.com/bioexcel/biobb_vs/raw/master/biobb_vs/test/data/vina/vina_ligand.pdbqt + type: File + format: edam:format_1476 + inputBinding: + position: 1 + prefix: --ligand + + input_receptor_pdbqt_path: + label: Path to the input PDBQT receptor + doc: |- + Path to the input PDBQT receptor + Type: string + File type: input + Accepted formats: pdbqt + Example file: https://github.com/bioexcel/biobb_vs/raw/master/biobb_vs/test/data/vina/vina_receptor.pdbqt + type: File + format: edam:format_1476 + inputBinding: + position: 2 + prefix: --receptor + + local_only: + label: Do local search only + doc: Do local search only + type: boolean? + #format: + #- edam_format_2330 # textual format + inputBinding: + prefix: --local_only + + score_only: + label: Do not do any conformational search; simply rescore. + doc: Do not do any conformational search; simply rescore. + type: boolean? + #format: + #- edam_format_2330 # textual format + inputBinding: + prefix: --score_only + + output_ligand_pdbqt_path: + label: Path to the output PDBQT ligand + doc: |- + Path to the output PDBQT ligand + Type: string + File type: output + Accepted formats: pdbqt + Example file: https://github.com/bioexcel/biobb_vs/raw/master/biobb_vs/test/reference/vina/ref_output_vina.pdbqt + type: string? + format: edam:format_1476 + + output_log_path: + label: Path to the log file + doc: |- + Path to the log file + Type: string + File type: output + Accepted formats: log + Example file: https://github.com/bioexcel/biobb_vs/raw/master/biobb_vs/test/reference/vina/ref_output_vina.log + type: string + format: edam:format_2330 + default: system.log + +outputs: + output_ligand_pdbqt_path: + label: Path to the output PDBQT files + doc: |- + Path to the output PDBQT files + #type: File[] + type: + type: array + items: File + outputBinding: + glob: ./*_out.pdbqt # Use ./* because leading *'s are reserved syntax for Yaml aliases. + outputEval: | + ${ + if (self.length > 0) { // if --local_only + return self; + } else { // if --score_only + return [inputs.input_ligand_pdbqt_path] + } + } + format: edam:format_1476 + + output_log_path: + label: Path to the log file + doc: |- + Path to the log file + type: File + outputBinding: + glob: $(inputs.output_log_path) + format: edam:format_2330 + + docking_score: + label: Estimated Free Energy of Binding + doc: |- + Estimated Free Energy of Binding + type: float + outputBinding: + glob: $(inputs.output_log_path) + loadContents: true + outputEval: | + ${ + var lines = self[0].contents.split("\n"); + // The correct line should be of the form + // Estimated Free Energy of Binding : -6.053 (kcal/mol) [=(1)+(2)+(3)+(4)] + var bfe_line = lines.filter(function(s) {return s.split(" ")[0] == "Estimated"})[0]; + var docking_score_string = bfe_line.split(" ").filter(function(s) {return !isNaN(parseFloat(s))})[0]; + var docking_score = parseFloat(docking_score_string); + return docking_score + } + +stdout: $(inputs.output_log_path) + +$namespaces: + edam: https://edamontology.org/ + +$schemas: +- https://raw.githubusercontent.com/edamontology/edamontology/master/EDAM_dev.owl diff --git a/utils/autodock-vina-rescore-plugin/build-docker.sh b/utils/autodock-vina-rescore-plugin/build-docker.sh new file mode 100644 index 00000000..4c67bfaf --- /dev/null +++ b/utils/autodock-vina-rescore-plugin/build-docker.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +version=$("] +readme = "README.md" + +[tool.poetry.dependencies] +python = ">=3.9,<3.13" +typer = "^0.7.0" +sophios = "0.1.4" +pandas = "2.2.2" + +[tool.poetry.group.dev.dependencies] +bump2version = "^1.0.1" +pytest = "^7.4" +pytest-sugar = "^0.9.6" +pre-commit = "^3.2.1" +black = "^23.3.0" +mypy = "^1.1.1" +ruff = "^0.0.270" + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" + +[tool.pytest.ini_options] +pythonpath = [ + "." +] diff --git a/utils/autodock-vina-rescore-plugin/tests/__init__.py b/utils/autodock-vina-rescore-plugin/tests/__init__.py new file mode 100644 index 00000000..dd64d03e --- /dev/null +++ b/utils/autodock-vina-rescore-plugin/tests/__init__.py @@ -0,0 +1 @@ +"""Tests for autodock_vina_rescore.""" diff --git a/utils/autodock-vina-rescore-plugin/tests/ligand.pdbqt b/utils/autodock-vina-rescore-plugin/tests/ligand.pdbqt new file mode 100644 index 00000000..7b82743b --- /dev/null +++ b/utils/autodock-vina-rescore-plugin/tests/ligand.pdbqt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:44ac0a092c5b56afcaba295f63bb739b702b10168e08a6d917f79b25d92a9ab2 +size 4182 diff --git a/utils/autodock-vina-rescore-plugin/tests/receptor.pdbqt b/utils/autodock-vina-rescore-plugin/tests/receptor.pdbqt new file mode 100644 index 00000000..8a06236f --- /dev/null +++ b/utils/autodock-vina-rescore-plugin/tests/receptor.pdbqt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d58f78511bda2866307efc1f98fdcd7df369bc8e64cc33e9f649b5d2721382fe +size 326732 diff --git a/utils/autodock-vina-rescore-plugin/tests/test_autodock_vina_rescore.py b/utils/autodock-vina-rescore-plugin/tests/test_autodock_vina_rescore.py new file mode 100644 index 00000000..2758b38a --- /dev/null +++ b/utils/autodock-vina-rescore-plugin/tests/test_autodock_vina_rescore.py @@ -0,0 +1,34 @@ +"""Tests for autodock_vina_rescore.""" +from pathlib import Path + +from sophios.api.pythonapi import Step +from sophios.api.pythonapi import Workflow + + +def test_autodock_vina_rescore_cwl() -> None: + """Test autodock_vina_rescore CWL.""" + cwl_file = Path("autodock_vina_rescore_0@1@0.cwl") + + autodock_vina_rescore_step = Step(clt_path=cwl_file) + + ligand_path = "ligand.pdbqt" + ligand_path = str(Path(__file__).resolve().parent / Path(ligand_path)) + receptor_path = "receptor.pdbqt" + receptor_path = str(Path(__file__).resolve().parent / Path(receptor_path)) + + autodock_vina_rescore_step.input_ligand_pdbqt_path = ligand_path + autodock_vina_rescore_step.input_receptor_pdbqt_path = receptor_path + autodock_vina_rescore_step.score_only = True + autodock_vina_rescore_step.output_log_path = "vina_rescore_pdbind.log" + + steps = [autodock_vina_rescore_step] + filename = "autodock_vina_rescore" + viz = Workflow(steps, filename) + + viz.run() + + # Check for the existence of the output file + outdir = Path("outdir") + assert any( + file.name == "autodock_vina_rescore" for file in outdir.rglob("*") + ), "The file autodock_vina_rescore was not found."