Skip to content

Commit

Permalink
obmin
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon Duane Walker authored and Brandon Duane Walker committed May 31, 2024
1 parent 6d5007e commit 2b58b7e
Show file tree
Hide file tree
Showing 15 changed files with 227 additions and 0 deletions.
3 changes: 3 additions & 0 deletions utils/.gitattributes
Original file line number Diff line number Diff line change
@@ -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
29 changes: 29 additions & 0 deletions utils/pre-process/minimize/obmin-tool/.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/obmin/__init__.py]
4 changes: 4 additions & 0 deletions utils/pre-process/minimize/obmin-tool/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.venv
out
tests
__pycache__
1 change: 1 addition & 0 deletions utils/pre-process/minimize/obmin-tool/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
poetry.lock
5 changes: 5 additions & 0 deletions utils/pre-process/minimize/obmin-tool/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# CHANGELOG

## 0.1.0

Initial release.
4 changes: 4 additions & 0 deletions utils/pre-process/minimize/obmin-tool/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# docker build -f Dockerfile -t mrbrandonwalker/openbabel-tool .
FROM condaforge/mambaforge
# NOT mambaforge-pypy3 (openbabel is incompatible with pypy)
RUN mamba install -c conda-forge openbabel
14 changes: 14 additions & 0 deletions utils/pre-process/minimize/obmin-tool/README.md
Original file line number Diff line number Diff line change
@@ -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 |
1 change: 1 addition & 0 deletions utils/pre-process/minimize/obmin-tool/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.0
51 changes: 51 additions & 0 deletions utils/pre-process/minimize/obmin-tool/ict.yml
Original file line number Diff line number Diff line change
@@ -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: [email protected]
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
50 changes: 50 additions & 0 deletions utils/pre-process/minimize/obmin-tool/obmin.cwl
Original file line number Diff line number Diff line change
@@ -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: mrbrandonwalker/openbabel-tool

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
6 changes: 6 additions & 0 deletions utils/pre-process/minimize/obmin-tool/obminimize.sh
Original file line number Diff line number Diff line change
@@ -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
30 changes: 30 additions & 0 deletions utils/pre-process/minimize/obmin-tool/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[tool.poetry]
name = "polus-mm-utils-obmin"
version = "0.1.0"
description = "Run a Bash script"
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/pre-process/minimize/obmin-tool/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Tests for obmin."""
3 changes: 3 additions & 0 deletions utils/pre-process/minimize/obmin-tool/tests/benzene.mol2
Git LFS file not shown
25 changes: 25 additions & 0 deletions utils/pre-process/minimize/obmin-tool/tests/test_obmin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""Tests for obmin."""
import sys
from pathlib import Path

current_dir = Path(__file__).resolve().parent
target_dir = current_dir.parent.parent.parent / "cwl_utils"
sys.path.append(str(target_dir))

from cwl_utilities import call_cwltool # noqa: E402
from cwl_utilities import create_input_yaml # noqa: E402
from cwl_utilities import parse_cwl_arguments # noqa: E402


def test_obmin() -> None:
"""Test obmin."""
cwl_file = Path("obmin.cwl")
input_to_props = parse_cwl_arguments(cwl_file)
input_to_props["script"] = "/obminimize.sh"
file_path_str = "benzene.mol2"
file_path = str(Path(__file__).resolve().parent / Path(file_path_str))
input_to_props["input_mol2_path"]["path"] = file_path
input_yaml_path = Path("obmin.yml")
create_input_yaml(input_to_props, input_yaml_path)
call_cwltool(cwl_file, input_yaml_path)
assert Path("system.mol2").exists()

0 comments on commit 2b58b7e

Please sign in to comment.