diff --git a/utils/.gitattributes b/utils/.gitattributes new file mode 100644 index 00000000..0653a6d1 --- /dev/null +++ b/utils/.gitattributes @@ -0,0 +1,3 @@ +*.pdb filter=lfs diff=lfs merge=lfs -text +*.pdbqt filter=lfs diff=lfs merge=lfs -text +*.mol2 filter=lfs diff=lfs merge=lfs -text diff --git a/utils/pre-process/minimize/obmin-tool/.bumpversion.cfg b/utils/pre-process/minimize/obmin-tool/.bumpversion.cfg new file mode 100644 index 00000000..238ee83c --- /dev/null +++ b/utils/pre-process/minimize/obmin-tool/.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/obmin/__init__.py] diff --git a/utils/pre-process/minimize/obmin-tool/.dockerignore b/utils/pre-process/minimize/obmin-tool/.dockerignore new file mode 100644 index 00000000..7c603f81 --- /dev/null +++ b/utils/pre-process/minimize/obmin-tool/.dockerignore @@ -0,0 +1,4 @@ +.venv +out +tests +__pycache__ diff --git a/utils/pre-process/minimize/obmin-tool/.gitignore b/utils/pre-process/minimize/obmin-tool/.gitignore new file mode 100644 index 00000000..c04bc49f --- /dev/null +++ b/utils/pre-process/minimize/obmin-tool/.gitignore @@ -0,0 +1 @@ +poetry.lock diff --git a/utils/pre-process/minimize/obmin-tool/CHANGELOG.md b/utils/pre-process/minimize/obmin-tool/CHANGELOG.md new file mode 100644 index 00000000..b67793f7 --- /dev/null +++ b/utils/pre-process/minimize/obmin-tool/CHANGELOG.md @@ -0,0 +1,5 @@ +# CHANGELOG + +## 0.1.0 + +Initial release. diff --git a/utils/pre-process/minimize/obmin-tool/Dockerfile b/utils/pre-process/minimize/obmin-tool/Dockerfile new file mode 100644 index 00000000..4a6d88f6 --- /dev/null +++ b/utils/pre-process/minimize/obmin-tool/Dockerfile @@ -0,0 +1,4 @@ +# docker build -f Dockerfile -t polusai/openbabel-tool . +FROM condaforge/mambaforge +# NOT mambaforge-pypy3 (openbabel is incompatible with pypy) +RUN mamba install -c conda-forge openbabel diff --git a/utils/pre-process/minimize/obmin-tool/README.md b/utils/pre-process/minimize/obmin-tool/README.md new file mode 100644 index 00000000..f5852e41 --- /dev/null +++ b/utils/pre-process/minimize/obmin-tool/README.md @@ -0,0 +1,14 @@ +# obmin (0.1.0) + +Minimize a molecule using Open Babel + +## Options + +This plugin takes 3 input arguments and 1 output argument: + +| Name | Description | I/O | Type | Default | +|---------------|-------------------------|--------|--------|---------| +| script | Minimize script | Input | string | string | +| input_mol2_path | Input mol2 file | Input | File | File | +| output_mol2_path | Output mol2 filename | Input | string | string | +| output_mol2_path | Output mol2 file | Output | File | File | diff --git a/utils/pre-process/minimize/obmin-tool/VERSION b/utils/pre-process/minimize/obmin-tool/VERSION new file mode 100644 index 00000000..6e8bf73a --- /dev/null +++ b/utils/pre-process/minimize/obmin-tool/VERSION @@ -0,0 +1 @@ +0.1.0 diff --git a/utils/pre-process/minimize/obmin-tool/ict.yml b/utils/pre-process/minimize/obmin-tool/ict.yml new file mode 100644 index 00000000..e5955deb --- /dev/null +++ b/utils/pre-process/minimize/obmin-tool/ict.yml @@ -0,0 +1,51 @@ +specVersion: "0.1.0" +name: obmin +version: 0.1.0 +container: obmin-tool +entrypoint: +title: obmin +description: Minimize a molecule using OpenBabel +author: Brandon Walker, OpenBabel +contact: brandon.walker@axleinfo.com +repository: +documentation: +citation: + +inputs: + - name: script + required: true + description: + type: string + - name: input_mol2_path + required: true + description: + type: File + format: + uri: edam:format_3816 + - name: output_mol2_path + required: true + description: + type: string + defaultValue: system.mol2 + format: + uri: edam:format_3816 +outputs: + - name: output_mol2_path + required: true + description: + type: File + format: + uri: edam:format_3816 +ui: + - key: inputs.script + title: "script: " + description: "" + type: string + - key: inputs.input_mol2_path + title: "input_mol2_path: " + description: "" + type: File + - key: inputs.output_mol2_path + title: "output_mol2_path: " + description: "" + type: string diff --git a/utils/pre-process/minimize/obmin-tool/obmin_0@1@0.cwl b/utils/pre-process/minimize/obmin-tool/obmin_0@1@0.cwl new file mode 100644 index 00000000..017ebd77 --- /dev/null +++ b/utils/pre-process/minimize/obmin-tool/obmin_0@1@0.cwl @@ -0,0 +1,50 @@ +#!/usr/bin/env cwl-runner +cwlVersion: v1.0 + +class: CommandLineTool + +label: Run a Bash script + +doc: | + Run a Bash script + +baseCommand: bash + +hints: + DockerRequirement: + dockerPull: polusai/openbabel-tool@sha256:e685b764da702f37da5688766f976fc4b989054e090830e9c95c2510fe3112c6 + +inputs: + script: + type: string + inputBinding: + position: 1 + + input_mol2_path: + type: File + format: edam:format_3816 + inputBinding: + position: 2 + + output_mol2_path: + type: string + format: edam:format_3816 +# inputBinding: +# position: 3 + default: system.mol2 + +outputs: + output_mol2_path: + type: File + format: edam:format_3816 # 'Textual format' + streamable: true + outputBinding: + glob: $(inputs.output_mol2_path) + +stdout: $(inputs.output_mol2_path) + +$namespaces: + edam: https://edamontology.org/ + +$schemas: +- https://raw.githubusercontent.com/edamontology/edamontology/master/EDAM_dev.owl diff --git a/utils/pre-process/minimize/obmin-tool/obminimize.sh b/utils/pre-process/minimize/obmin-tool/obminimize.sh new file mode 100644 index 00000000..8bc1209a --- /dev/null +++ b/utils/pre-process/minimize/obmin-tool/obminimize.sh @@ -0,0 +1,6 @@ +#!/bin/bash -e +# -cg is the default minimization algorithm, but it falsely claims to reach +# convergence on the second timestep. (same with -newton) +# Use steepest descent because it's the only one that works! +obminimize -sd -o mol2 "$1" > temp.mol2 # -xu is ignored here +obabel temp.mol2 -o mol2 -O "$2" -xu diff --git a/utils/pre-process/minimize/obmin-tool/pyproject.toml b/utils/pre-process/minimize/obmin-tool/pyproject.toml new file mode 100644 index 00000000..799e57b7 --- /dev/null +++ b/utils/pre-process/minimize/obmin-tool/pyproject.toml @@ -0,0 +1,28 @@ +[tool.poetry] +name = "polus-mm-utils-obmin" +version = "0.1.0" +description = "Run a Bash script" +authors = ["Data Scientist "] +readme = "README.md" + +[tool.poetry.dependencies] +python = ">=3.9,<3.12" +sophios = "0.1.1" + +[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/pre-process/minimize/obmin-tool/tests/__init__.py b/utils/pre-process/minimize/obmin-tool/tests/__init__.py new file mode 100644 index 00000000..517ec5ee --- /dev/null +++ b/utils/pre-process/minimize/obmin-tool/tests/__init__.py @@ -0,0 +1 @@ +"""Tests for obmin.""" diff --git a/utils/pre-process/minimize/obmin-tool/tests/benzene.mol2 b/utils/pre-process/minimize/obmin-tool/tests/benzene.mol2 new file mode 100644 index 00000000..dc5f18ae --- /dev/null +++ b/utils/pre-process/minimize/obmin-tool/tests/benzene.mol2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:52fbd7a9840ed9778ac3037fe6b0d22b53b3200cbf27bd59dba0f273e595edc5 +size 1625 diff --git a/utils/pre-process/minimize/obmin-tool/tests/test_obmin.py b/utils/pre-process/minimize/obmin-tool/tests/test_obmin.py new file mode 100644 index 00000000..e8fd959a --- /dev/null +++ b/utils/pre-process/minimize/obmin-tool/tests/test_obmin.py @@ -0,0 +1,32 @@ +"""Tests for obmin.""" +from pathlib import Path + +from sophios.api.pythonapi import Step +from sophios.api.pythonapi import Workflow + + +def test_obmin() -> None: + """Test obmin.""" + cwl_file = Path("obmin_0@1@0.cwl") + + # Create the step for the CWL file + obmin_step = Step(clt_path=cwl_file) + + # Set up the inputs for the step + obmin_step.script = "/obminimize.sh" + obmin_step.input_mol2_path = str(Path(__file__).resolve().parent / "benzene.mol2") + obmin_step.output_mol2_path = "system.mol2" + + # Define the workflow with the step + steps = [obmin_step] + filename = "obmin_workflow" + workflow = Workflow(steps, filename) + + # Run the workflow + workflow.run() + + # Check for the existence of the output file + outdir = Path("outdir") + assert any( + file.name == "system.mol2" for file in outdir.rglob("*") + ), "The file system.mol2 was not found."