Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
autodock_vina_rescore
Browse files Browse the repository at this point in the history
ndonyapour committed Dec 26, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 92d2d65 commit 3367d06
Showing 16 changed files with 408 additions and 0 deletions.
29 changes: 29 additions & 0 deletions utils/autodock-vina-rescore-plugin/.bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[bumpversion]
current_version = 0.1.0
commit = False
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+)(?P<dev>\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]
4 changes: 4 additions & 0 deletions utils/autodock-vina-rescore-plugin/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.venv
out
tests
__pycache__
2 changes: 2 additions & 0 deletions utils/autodock-vina-rescore-plugin/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.pdb filter=lfs diff=lfs merge=lfs -text
*.pdbqt filter=lfs diff=lfs merge=lfs -text
1 change: 1 addition & 0 deletions utils/autodock-vina-rescore-plugin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
poetry.lock
5 changes: 5 additions & 0 deletions utils/autodock-vina-rescore-plugin/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# CHANGELOG

## 0.1.0

Initial release.
22 changes: 22 additions & 0 deletions utils/autodock-vina-rescore-plugin/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 .
19 changes: 19 additions & 0 deletions utils/autodock-vina-rescore-plugin/README.md
Original file line number Diff line number Diff line change
@@ -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 |
1 change: 1 addition & 0 deletions utils/autodock-vina-rescore-plugin/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.0
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions utils/autodock-vina-rescore-plugin/build-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

version=$(<VERSION)
docker build . -t polusai/polusai/autodock-vina-tool:${version}
89 changes: 89 additions & 0 deletions utils/autodock-vina-rescore-plugin/ict.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
specVersion: "0.1.0"
name: autodock_vina_rescore
version: 0.1.0
container: autodock-vina-rescore-plugin
entrypoint:
title: autodock_vina_rescore
description: Wrapper of the AutoDock Vina software.
author: Data Scientist
contact: [email protected]
repository:
documentation:
citation:

inputs:
- name: input_ligand_pdbqt_path
required: true
description: 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:
uri: edam:format_1476
- name: input_receptor_pdbqt_path
required: true
description: 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:
uri: edam:format_1476
- name: local_only
required: true
description: Do local search only
type: boolean
- name: score_only
required: true
description: Do not do any conformational search; simply rescore.
type: boolean
- name: output_ligand_pdbqt_path
required: true
description: 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:
uri: edam:format_1476
- name: output_log_path
required: true
description: 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
defaultValue: system.log
format:
uri: edam:format_2330
outputs:
- name: output_ligand_pdbqt_path
required: true
description: Path to the output PDBQT files
type: {'type': 'array', 'items': 'File'}
format:
uri: edam:format_1476
- name: output_log_path
required: true
description: Path to the log file
type: File
format:
uri: edam:format_2330
- name: docking_score
required: true
description: Estimated Free Energy of Binding
type: float
ui:
- key: inputs.input_ligand_pdbqt_path
title: "input_ligand_pdbqt_path: "
description: "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
- key: inputs.input_receptor_pdbqt_path
title: "input_receptor_pdbqt_path: "
description: "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
- key: inputs.local_only
title: "local_only: "
description: "Do local search only"
type: checkbox
- key: inputs.score_only
title: "score_only: "
description: "Do not do any conformational search; simply rescore."
type: checkbox
- key: inputs.output_ligand_pdbqt_path
title: "output_ligand_pdbqt_path: "
description: "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
- key: inputs.output_log_path
title: "output_log_path: "
description: "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
30 changes: 30 additions & 0 deletions utils/autodock-vina-rescore-plugin/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[tool.poetry]
name = "polus-mm-utils-autodock-vina-rescore"
version = "0.1.0"
description = "Wrapper of the AutoDock Vina software."
authors = ["Data Scientist <[email protected]>"]
readme = "README.md"

[tool.poetry.dependencies]
python = ">=3.9,<3.12"
typer = "^0.7.0"
cwl-utils = "0.33"
cwltool = "3.1.20240404144621"

[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 = [
"."
]
1 change: 1 addition & 0 deletions utils/autodock-vina-rescore-plugin/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Tests for autodock_vina_rescore."""
3 changes: 3 additions & 0 deletions utils/autodock-vina-rescore-plugin/tests/ligand.pdbqt
Git LFS file not shown
3 changes: 3 additions & 0 deletions utils/autodock-vina-rescore-plugin/tests/receptor.pdbqt
Git LFS file not shown
Original file line number Diff line number Diff line change
@@ -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."

0 comments on commit 3367d06

Please sign in to comment.