From 4b6d066157b49699403961fbdc5b020acfbcc009 Mon Sep 17 00:00:00 2001 From: Brandon Duane Walker Date: Mon, 3 Jun 2024 14:13:17 -0400 Subject: [PATCH] refactor grompp --- utils/grompp-plugin/tests/test_grompp.py | 36 ------------------ .../gromacs/grompp-tool}/.bumpversion.cfg | 0 .../gromacs/grompp-tool}/.dockerignore | 0 .../gromacs/grompp-tool}/.gitignore | 0 .../gromacs/grompp-tool}/CHANGELOG.md | 0 .../gromacs/grompp-tool}/README.md | 0 .../gromacs/grompp-tool}/VERSION | 0 .../gromacs/grompp-tool/grompp_0@1@0.cwl} | 0 .../gromacs/grompp-tool}/ict.yml | 6 +-- .../gromacs/grompp-tool}/pyproject.toml | 3 +- .../gromacs/grompp-tool}/tests/__init__.py | 0 .../gromacs/grompp-tool}/tests/grompp.gro | 0 .../gromacs/grompp-tool}/tests/grompp.zip | Bin .../gromacs/grompp-tool/tests/test_grompp.py | 35 +++++++++++++++++ 14 files changed, 39 insertions(+), 41 deletions(-) delete mode 100644 utils/grompp-plugin/tests/test_grompp.py rename utils/{grompp-plugin => molecular-dynamics/gromacs/grompp-tool}/.bumpversion.cfg (100%) rename utils/{grompp-plugin => molecular-dynamics/gromacs/grompp-tool}/.dockerignore (100%) rename utils/{grompp-plugin => molecular-dynamics/gromacs/grompp-tool}/.gitignore (100%) rename utils/{grompp-plugin => molecular-dynamics/gromacs/grompp-tool}/CHANGELOG.md (100%) rename utils/{grompp-plugin => molecular-dynamics/gromacs/grompp-tool}/README.md (100%) rename utils/{grompp-plugin => molecular-dynamics/gromacs/grompp-tool}/VERSION (100%) rename utils/{grompp-plugin/grompp.cwl => molecular-dynamics/gromacs/grompp-tool/grompp_0@1@0.cwl} (100%) rename utils/{grompp-plugin => molecular-dynamics/gromacs/grompp-tool}/ict.yml (97%) rename utils/{grompp-plugin => molecular-dynamics/gromacs/grompp-tool}/pyproject.toml (92%) rename utils/{grompp-plugin => molecular-dynamics/gromacs/grompp-tool}/tests/__init__.py (100%) rename utils/{grompp-plugin => molecular-dynamics/gromacs/grompp-tool}/tests/grompp.gro (100%) rename utils/{grompp-plugin => molecular-dynamics/gromacs/grompp-tool}/tests/grompp.zip (100%) create mode 100644 utils/molecular-dynamics/gromacs/grompp-tool/tests/test_grompp.py diff --git a/utils/grompp-plugin/tests/test_grompp.py b/utils/grompp-plugin/tests/test_grompp.py deleted file mode 100644 index 37cb2eea..00000000 --- a/utils/grompp-plugin/tests/test_grompp.py +++ /dev/null @@ -1,36 +0,0 @@ -"""Tests for grompp.""" -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_grompp_cwl() -> None: - """Tests grompp.cwl.""" - cwl_file_str = "grompp.cwl" - cwl_file = Path(__file__).resolve().parent.parent / Path(cwl_file_str) - input_to_props = parse_cwl_arguments(cwl_file) - file_path_str = "grompp.gro" - file_path = str(Path(__file__).resolve().parent / Path(file_path_str)) - input_to_props["input_crd_path"]["path"] = file_path - input_to_props["input_crd_path"]["class"] = "File" - file_path_str = "grompp.zip" - file_path = str(Path(__file__).resolve().parent / Path(file_path_str)) - input_to_props["input_top_zip_path"]["path"] = file_path - input_to_props["input_top_zip_path"]["class"] = "File" - del input_to_props["input_cpt_path"] - del input_to_props["input_ndx_path"] - del input_to_props["input_mdp_path"] - - input_yaml_path = Path("grompp.yml") - create_input_yaml(input_to_props, input_yaml_path) - - stdout, stderr = call_cwltool(cwl_file, input_yaml_path) - - assert Path("system.tpr").exists() diff --git a/utils/grompp-plugin/.bumpversion.cfg b/utils/molecular-dynamics/gromacs/grompp-tool/.bumpversion.cfg similarity index 100% rename from utils/grompp-plugin/.bumpversion.cfg rename to utils/molecular-dynamics/gromacs/grompp-tool/.bumpversion.cfg diff --git a/utils/grompp-plugin/.dockerignore b/utils/molecular-dynamics/gromacs/grompp-tool/.dockerignore similarity index 100% rename from utils/grompp-plugin/.dockerignore rename to utils/molecular-dynamics/gromacs/grompp-tool/.dockerignore diff --git a/utils/grompp-plugin/.gitignore b/utils/molecular-dynamics/gromacs/grompp-tool/.gitignore similarity index 100% rename from utils/grompp-plugin/.gitignore rename to utils/molecular-dynamics/gromacs/grompp-tool/.gitignore diff --git a/utils/grompp-plugin/CHANGELOG.md b/utils/molecular-dynamics/gromacs/grompp-tool/CHANGELOG.md similarity index 100% rename from utils/grompp-plugin/CHANGELOG.md rename to utils/molecular-dynamics/gromacs/grompp-tool/CHANGELOG.md diff --git a/utils/grompp-plugin/README.md b/utils/molecular-dynamics/gromacs/grompp-tool/README.md similarity index 100% rename from utils/grompp-plugin/README.md rename to utils/molecular-dynamics/gromacs/grompp-tool/README.md diff --git a/utils/grompp-plugin/VERSION b/utils/molecular-dynamics/gromacs/grompp-tool/VERSION similarity index 100% rename from utils/grompp-plugin/VERSION rename to utils/molecular-dynamics/gromacs/grompp-tool/VERSION diff --git a/utils/grompp-plugin/grompp.cwl b/utils/molecular-dynamics/gromacs/grompp-tool/grompp_0@1@0.cwl similarity index 100% rename from utils/grompp-plugin/grompp.cwl rename to utils/molecular-dynamics/gromacs/grompp-tool/grompp_0@1@0.cwl diff --git a/utils/grompp-plugin/ict.yml b/utils/molecular-dynamics/gromacs/grompp-tool/ict.yml similarity index 97% rename from utils/grompp-plugin/ict.yml rename to utils/molecular-dynamics/gromacs/grompp-tool/ict.yml index bb59bd33..04a8ee6f 100644 --- a/utils/grompp-plugin/ict.yml +++ b/utils/molecular-dynamics/gromacs/grompp-tool/ict.yml @@ -1,12 +1,12 @@ specVersion: "0.1.0" name: grompp version: 0.1.0 -container: grompp-plugin +container: grompp-tool entrypoint: title: grompp description: Wrapper of the GROMACS grompp module. -author: Data Scientist -contact: data.scientist@labshare.org +author: Brandon Walker, Nazanin Donyapour +contact: brandon.walker@axleinfo.com, nazanin.donyapour@axleinfo.com repository: documentation: citation: diff --git a/utils/grompp-plugin/pyproject.toml b/utils/molecular-dynamics/gromacs/grompp-tool/pyproject.toml similarity index 92% rename from utils/grompp-plugin/pyproject.toml rename to utils/molecular-dynamics/gromacs/grompp-tool/pyproject.toml index af652f45..f25220be 100644 --- a/utils/grompp-plugin/pyproject.toml +++ b/utils/molecular-dynamics/gromacs/grompp-tool/pyproject.toml @@ -8,8 +8,7 @@ readme = "README.md" [tool.poetry.dependencies] python = ">=3.9,<3.12" typer = "^0.7.0" -cwl-utils = "0.33" -cwltool = "3.1.20240404144621" +sophios = "0.1.1" [tool.poetry.group.dev.dependencies] bump2version = "^1.0.1" diff --git a/utils/grompp-plugin/tests/__init__.py b/utils/molecular-dynamics/gromacs/grompp-tool/tests/__init__.py similarity index 100% rename from utils/grompp-plugin/tests/__init__.py rename to utils/molecular-dynamics/gromacs/grompp-tool/tests/__init__.py diff --git a/utils/grompp-plugin/tests/grompp.gro b/utils/molecular-dynamics/gromacs/grompp-tool/tests/grompp.gro similarity index 100% rename from utils/grompp-plugin/tests/grompp.gro rename to utils/molecular-dynamics/gromacs/grompp-tool/tests/grompp.gro diff --git a/utils/grompp-plugin/tests/grompp.zip b/utils/molecular-dynamics/gromacs/grompp-tool/tests/grompp.zip similarity index 100% rename from utils/grompp-plugin/tests/grompp.zip rename to utils/molecular-dynamics/gromacs/grompp-tool/tests/grompp.zip diff --git a/utils/molecular-dynamics/gromacs/grompp-tool/tests/test_grompp.py b/utils/molecular-dynamics/gromacs/grompp-tool/tests/test_grompp.py new file mode 100644 index 00000000..55bdee34 --- /dev/null +++ b/utils/molecular-dynamics/gromacs/grompp-tool/tests/test_grompp.py @@ -0,0 +1,35 @@ +"""Tests for the GROMACS grompp tool.""" +from pathlib import Path + +from sophios.api.pythonapi import Step +from sophios.api.pythonapi import Workflow + + +def test_grompp_cwl() -> None: + """Tests grompp.cwl.""" + # Define paths and setup input properties + cwl_file_str = "grompp_0@1@0.cwl" + cwl_file = Path(__file__).resolve().parent.parent / Path(cwl_file_str) + + input_crd_path = Path(__file__).resolve().parent / Path("grompp.gro") + input_top_zip_path = Path(__file__).resolve().parent / Path("grompp.zip") + + # Create the CWL step + grompp_step = Step(clt_path=cwl_file) + grompp_step.input_crd_path = input_crd_path + grompp_step.input_top_zip_path = input_top_zip_path + grompp_step.output_tpr_path = "system.tpr" + + # Create the workflow and run it + steps = [grompp_step] + filename = "grompp_workflow" + workflow = Workflow(steps, filename) + workflow.run() + + # Define output directory and check for expected output + outdir = Path("outdir") + files = list(outdir.rglob("system.tpr")) + + assert ( + files + ), f"The file 'system.tpr' does not exist in any subdirectory of '{outdir}'."