-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Brandon Duane Walker <[email protected]>
- Loading branch information
1 parent
616c218
commit b3f4953
Showing
11 changed files
with
191 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/array_indices/__init__.py] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.venv | ||
out | ||
tests | ||
__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
poetry.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# CHANGELOG | ||
|
||
## 0.1.0 | ||
|
||
Initial release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# array_indices (0.1.0) | ||
|
||
return a subset from a array based on input indices | ||
|
||
## Options | ||
|
||
This plugin takes 2 input arguments and 1 output argument: | ||
|
||
| Name | Description | I/O | Type | Default | | ||
|---------------|-------------------------|--------|--------|---------| | ||
| input_indices | Indices to subset | Input | int[] | int[] | | ||
| input_array | Array to be make subset from | Input | Any | Any | | ||
| output_array | Path to the output array (subset) | Output | Any | Any | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
#!/usr/bin/env cwl-runner | ||
cwlVersion: v1.2 | ||
|
||
class: CommandLineTool | ||
|
||
label: return a subset from a array based on input indices | ||
|
||
doc: |- | ||
This class return a subset from a array based on input indices | ||
baseCommand: "true" | ||
|
||
requirements: | ||
InlineJavascriptRequirement: {} | ||
|
||
inputs: | ||
input_indices: | ||
label: input indices list | ||
type: int[] | ||
|
||
input_array: | ||
label: Path to the input array | ||
type: Any | ||
|
||
outputs: | ||
output_array: | ||
label: Path to the output array (subset) | ||
doc: |- | ||
Path to the output array (subset) | ||
type: Any | ||
outputBinding: | ||
outputEval: | | ||
${ | ||
const data = []; | ||
for (const index of inputs.input_indices) { | ||
data.push(inputs.input_array[index]); | ||
} | ||
return data; | ||
} | ||
|
||
$namespaces: | ||
edam: https://edamontology.org/ | ||
|
||
$schemas: | ||
- https://raw.githubusercontent.com/edamontology/edamontology/master/EDAM_dev.owl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
specVersion: "0.1.0" | ||
name: array_indices | ||
version: 0.1.0 | ||
container: array-indices-plugin | ||
entrypoint: | ||
title: array_indices | ||
description: return a subset from a array based on input indices | ||
author: Data Scientist | ||
contact: [email protected] | ||
repository: | ||
documentation: | ||
citation: | ||
|
||
inputs: | ||
- name: input_indices | ||
required: true | ||
description: | ||
type: int[] | ||
- name: input_array | ||
required: true | ||
description: | ||
type: Any | ||
outputs: | ||
- name: output_array | ||
required: true | ||
description: Path to the output array (subset) | ||
type: Any | ||
ui: | ||
- key: inputs.input_indices | ||
title: "input_indices: " | ||
description: "" | ||
type: int[] | ||
- key: inputs.input_array | ||
title: "input_array: " | ||
description: "" | ||
type: Any |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[tool.poetry] | ||
name = "polus-mm-utils-array-indices" | ||
version = "0.1.0" | ||
description = "return a subset from a array based on input indices" | ||
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 = [ | ||
"." | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Tests for array_indices.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
"""Tests for array_indices.""" | ||
import json | ||
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_array_indices() -> None: | ||
"""Test array_indices.""" | ||
cwl_file = Path("array_indices.cwl") | ||
input_to_props = parse_cwl_arguments(cwl_file) | ||
input_to_props["input_indices"] = [1, 3] | ||
input_to_props["input_array"] = [1, 2, 3, 4, 5] | ||
input_yaml_path = Path("array_indices.yml") | ||
create_input_yaml(input_to_props, input_yaml_path) | ||
stdout, stderr = call_cwltool(cwl_file, input_yaml_path) | ||
output_data = json.loads(stdout) | ||
output_array = output_data["output_array"] | ||
assert output_array == [2, 4] |