diff --git a/utils/bash-xvg-plugin/.bumpversion.cfg b/utils/bash-xvg-plugin/.bumpversion.cfg new file mode 100644 index 00000000..36c5aa83 --- /dev/null +++ b/utils/bash-xvg-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/bash_xvg/__init__.py] diff --git a/utils/bash-xvg-plugin/.dockerignore b/utils/bash-xvg-plugin/.dockerignore new file mode 100644 index 00000000..7c603f81 --- /dev/null +++ b/utils/bash-xvg-plugin/.dockerignore @@ -0,0 +1,4 @@ +.venv +out +tests +__pycache__ diff --git a/utils/bash-xvg-plugin/.gitignore b/utils/bash-xvg-plugin/.gitignore new file mode 100644 index 00000000..c04bc49f --- /dev/null +++ b/utils/bash-xvg-plugin/.gitignore @@ -0,0 +1 @@ +poetry.lock diff --git a/utils/bash-xvg-plugin/CHANGELOG.md b/utils/bash-xvg-plugin/CHANGELOG.md new file mode 100644 index 00000000..b67793f7 --- /dev/null +++ b/utils/bash-xvg-plugin/CHANGELOG.md @@ -0,0 +1,5 @@ +# CHANGELOG + +## 0.1.0 + +Initial release. diff --git a/utils/bash-xvg-plugin/Dockerfile b/utils/bash-xvg-plugin/Dockerfile new file mode 100644 index 00000000..2800198f --- /dev/null +++ b/utils/bash-xvg-plugin/Dockerfile @@ -0,0 +1,4 @@ +FROM bash + +ADD replace_first_column.sh . +ADD Dockerfile . diff --git a/utils/bash-xvg-plugin/README.md b/utils/bash-xvg-plugin/README.md new file mode 100644 index 00000000..22a78e15 --- /dev/null +++ b/utils/bash-xvg-plugin/README.md @@ -0,0 +1,14 @@ +# bash_xvg (0.1.0) + +Replace a column in one file with a column from another using AWK + +## Options + +This plugin takes 3 input arguments and 1 output argument: + +| Name | Description | I/O | Type | Default | +|---------------|-------------------------|--------|--------|---------| +| input_xvg1_path | Path to the first XVG file | Input | File | File | +| input_xvg2_path | Path to the second XVG file | Input | File | File | +| output_xvg_path | Path to the output XVG file | Input | string | string | +| output_xvg_path | Path to the output XVG file | Output | File | File | diff --git a/utils/bash-xvg-plugin/VERSION b/utils/bash-xvg-plugin/VERSION new file mode 100644 index 00000000..6e8bf73a --- /dev/null +++ b/utils/bash-xvg-plugin/VERSION @@ -0,0 +1 @@ +0.1.0 diff --git a/utils/bash-xvg-plugin/bash_xvg.cwl b/utils/bash-xvg-plugin/bash_xvg.cwl new file mode 100644 index 00000000..b298a75e --- /dev/null +++ b/utils/bash-xvg-plugin/bash_xvg.cwl @@ -0,0 +1,61 @@ +#!/usr/bin/env cwl-runner +cwlVersion: v1.0 + +class: CommandLineTool + +label: Replace a column in one file with a column from another using AWKK + +doc: | + Replace a column in one file with a column from another using AWK + +baseCommand: ["bash", "/replace_first_column.sh"] + +hints: + DockerRequirement: + dockerPull: ndonyapour/replace_first_column + +inputs: + input_xvg1_path: + label: Path to the first XVG file + doc: |- + Path to the first XVG file + type: File + format: edam:format_2030 + inputBinding: + position: 1 + + input_xvg2_path: + label: Path to the second XVG file + doc: |- + Path to the second XVG file + type: File + format: edam:format_2030 + inputBinding: + position: 2 + + output_xvg_path: + label: Path to the output XVG file + doc: |- + Path to the output XVG file + type: string + format: edam:format_2030 + default: system.xvg + +outputs: + output_xvg_path: + label: Path to the output XVG file + doc: |- + Path to the output XVG file + type: File + format: edam:format_2030 + streamable: true + outputBinding: + glob: $(inputs.output_xvg_path) + +stdout: $(inputs.output_xvg_path) + +$namespaces: + edam: https://edamontology.org/ + +$schemas: +- https://raw.githubusercontent.com/edamontology/edamontology/master/EDAM_dev.owl diff --git a/utils/bash-xvg-plugin/ict.yml b/utils/bash-xvg-plugin/ict.yml new file mode 100644 index 00000000..a55a7a17 --- /dev/null +++ b/utils/bash-xvg-plugin/ict.yml @@ -0,0 +1,53 @@ +specVersion: "0.1.0" +name: bash_xvg +version: 0.1.0 +container: bash-xvg-plugin +entrypoint: +title: bash_xvg +description: Replace a column in one file with a column from another using AWK +author: Data Scientist +contact: data.scientist@labshare.org +repository: +documentation: +citation: + +inputs: + - name: input_xvg1_path + required: true + description: Path to the first XVG file + type: File + format: + uri: edam:format_2030 + - name: input_xvg2_path + required: true + description: Path to the second XVG file + type: File + format: + uri: edam:format_2030 + - name: output_xvg_path + required: true + description: Path to the output XVG file + type: string + defaultValue: system.xvg + format: + uri: edam:format_2030 +outputs: + - name: output_xvg_path + required: true + description: Path to the output XVG file + type: File + format: + uri: edam:format_2030 +ui: + - key: inputs.input_xvg1_path + title: "input_xvg1_path: " + description: "Path to the first XVG file" + type: File + - key: inputs.input_xvg2_path + title: "input_xvg2_path: " + description: "Path to the second XVG file" + type: File + - key: inputs.output_xvg_path + title: "output_xvg_path: " + description: "Path to the output XVG file" + type: string diff --git a/utils/bash-xvg-plugin/pyproject.toml b/utils/bash-xvg-plugin/pyproject.toml new file mode 100644 index 00000000..b9d7bb36 --- /dev/null +++ b/utils/bash-xvg-plugin/pyproject.toml @@ -0,0 +1,30 @@ +[tool.poetry] +name = "polus-mm-utils-bash-xvg" +version = "0.1.0" +description = "Replace a column in one file with a column from another using AWK" +authors = ["Data Scientist "] +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 = [ + "." +] diff --git a/utils/bash-xvg-plugin/replace_first_column.sh b/utils/bash-xvg-plugin/replace_first_column.sh new file mode 100644 index 00000000..b408733d --- /dev/null +++ b/utils/bash-xvg-plugin/replace_first_column.sh @@ -0,0 +1,6 @@ +#!/bin/bash -e +# See https://stackoverflow.com/questions/7846476/replace-column-in-one-file-with-column-from-another-using-awk + +grep -v "#" "$1" | grep -v "@" > tempone.txt +grep -v "#" "$2" | grep -v "@" > temptwo.txt +awk 'FNR==NR{a[NR]=$1;next}{$1=a[FNR]}1' temptwo.txt tempone.txt diff --git a/utils/bash-xvg-plugin/tests/__init__.py b/utils/bash-xvg-plugin/tests/__init__.py new file mode 100644 index 00000000..a4733d9d --- /dev/null +++ b/utils/bash-xvg-plugin/tests/__init__.py @@ -0,0 +1 @@ +"""Tests for bash_xvg.""" diff --git a/utils/bash-xvg-plugin/tests/rmsd1.xvg b/utils/bash-xvg-plugin/tests/rmsd1.xvg new file mode 100644 index 00000000..5b507468 --- /dev/null +++ b/utils/bash-xvg-plugin/tests/rmsd1.xvg @@ -0,0 +1,28 @@ +# This file was created Wed May 15 18:52:40 2024 +# Created by: +# :-) GROMACS - gmx rms, 2022.2-conda_forge (-: +# +# Executable: /usr/local/bin.AVX2_256/gmx +# Data prefix: /usr/local +# Working dir: /jAiJpn +# Command line: +# gmx rms -fit none -n /var/lib/cwl/stg854534b4-dcba-4641-a8e0-289ad164dad7/MOL.ndx -s /var/lib/cwl/stg2e049b7d-2261-481a-8b2e-f87a749a2820/complex.gro -f /var/lib/cwl/stg728ca10c-9429-421c-87f5-a5da2d92df29/prod_align_protein_ca.pdb -o rmsd_equil_ligand_notime.xvg +# gmx rms is part of G R O M A C S: +# +# GROningen MAchine for Chemical Simulation +# +@ title "RMSD" +@ xaxis label "Time (ps)" +@ yaxis label "RMSD (nm)" +@TYPE xy +@ subtitle "resname_MOL after no fit" + 0.0000000 0.0005156 + 0.0000000 0.0296825 + 0.0000000 0.0469071 + 0.0000000 0.0253868 + 0.0000000 0.0279059 + 0.0000000 0.0438598 + 0.0000000 0.0250407 + 0.0000000 0.0494208 + 0.0000000 0.0510193 + 0.0000000 0.0347102 diff --git a/utils/bash-xvg-plugin/tests/rmsd2.xvg b/utils/bash-xvg-plugin/tests/rmsd2.xvg new file mode 100644 index 00000000..e4d73a6d --- /dev/null +++ b/utils/bash-xvg-plugin/tests/rmsd2.xvg @@ -0,0 +1,28 @@ +# This file was created Wed May 15 18:52:40 2024 +# Created by: +# :-) GROMACS - gmx rms, 2022.2-conda_forge (-: +# +# Executable: /usr/local/bin.AVX2_256/gmx +# Data prefix: /usr/local +# Working dir: /jAiJpn +# Command line: +# gmx rms -fit none -n /var/lib/cwl/stg854534b4-dcba-4641-a8e0-289ad164dad7/MOL.ndx -s /var/lib/cwl/stg2e049b7d-2261-481a-8b2e-f87a749a2820/complex.gro -f /var/lib/cwl/stg728ca10c-9429-421c-87f5-a5da2d92df29/prod_align_protein_ca.pdb -o rmsd_equil_ligand_notime.xvg +# gmx rms is part of G R O M A C S: +# +# GROningen MAchine for Chemical Simulation +# +@ title "RMSD" +@ xaxis label "Time (ps)" +@ yaxis label "RMSD (nm)" +@TYPE xy +@ subtitle "resname_MOL after no fit" + 0.0000000 0.0006156 + 0.0000000 0.0396825 + 0.0000000 0.0469065 + 0.0000000 0.0353868 + 0.0000000 0.0479059 + 0.0000000 0.0488598 + 0.0000000 0.0550407 + 0.0000000 0.0694208 + 0.0000000 0.0210193 + 0.0000000 0.0247102 diff --git a/utils/bash-xvg-plugin/tests/test_bash_xvg.py b/utils/bash-xvg-plugin/tests/test_bash_xvg.py new file mode 100644 index 00000000..2e6ad732 --- /dev/null +++ b/utils/bash-xvg-plugin/tests/test_bash_xvg.py @@ -0,0 +1,31 @@ +"""Tests for bash_xvg.""" +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_bash_xvg() -> None: + """Test bash_xvg.""" + cwl_file = Path("bash_xvg.cwl") + input_to_props = parse_cwl_arguments(cwl_file) + + input_xvg1_path = "rmsd1.xvg" + input_xvg1_path = str(Path(__file__).resolve().parent / Path(input_xvg1_path)) + input_to_props["input_xvg1_path"]["path"] = input_xvg1_path + + input_xvg2_path = "rmsd2.xvg" + input_xvg2_path = str(Path(__file__).resolve().parent / Path(input_xvg2_path)) + input_to_props["input_xvg2_path"]["path"] = input_xvg2_path + + input_to_props["output_xvg_path"] = "output.xvg" + input_yaml_path = Path("bash_xvg.yml") + create_input_yaml(input_to_props, input_yaml_path) + call_cwltool(cwl_file, input_yaml_path) + assert Path("output.xvg").exists()