Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stimulus transform #6886

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions modules/nf-core/stimulus/transform/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
channels:
- conda-forge
- bioconda

dependencies:
- conda-forge::matplotlib=3.9.2
- conda-forge::pandas=2.2.3
- conda-forge::polars=1.9.0
- conda-forge::python=3.12
- conda-forge::pytorch=2.4.1
- conda-forge::ray-core=2.37.0
- conda-forge::safetensors=0.4.5
- conda-forge::scikit-learn=1.5.2
44 changes: 44 additions & 0 deletions modules/nf-core/stimulus/transform/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
process STIMULUS_TRANSFORM {
tag "$meta.id"
label 'process_medium'
container "docker.io/luisas/stimulus-py:0.0.10"

input:
tuple val(meta), path(transform_json)
path(csv)

output:
tuple val(meta), path("${prefix}.csv"), emit: csv
path "versions.yml" , emit: versions

when:
task.ext.when == null || task.ext.when

script:
def args = task.ext.args ?: ''
prefix = task.ext.prefix ?: "${meta.id}"
def STIMULUS_VER = '0.0.9'
"""
stimulus-transform-csv -c ${csv} -j ${transform_json} -o ${prefix}.csv

cat <<-END_VERSIONS > versions.yml
"${task.process}":
Python: \$(python --version | cut -d ' ' -f 2)
Stimulus-py: \$( pip show stimulus-py | grep Version | sed 's/Version: //')
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
prefix = task.ext.prefix ?: "${meta.id}"
def STIMULUS_VER = '0.0.9' // container not used in stub, change manually
"""
touch ${meta.id}.csv

cat <<-END_VERSIONS > versions.yml
"${task.process}":
Python: \$(python --version | cut -d ' ' -f 2)
Stimulus-py: ${STIMULUS_VER}
END_VERSIONS
"""
}
51 changes: 51 additions & 0 deletions modules/nf-core/stimulus/transform/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: "stimulus_transform"
description: Use stimulus-py package to transform the data.
keywords:
- machine learning
- neural network
- unit test
tools:
- "stimulus":
description: "Stochastic Testing and Input Manipulation for Unbiased Learning Systems"
homepage: "https://github.com/mathysgrapotte/stimulus-py"
documentation: "https://github.com/mathysgrapotte/stimulus-py"
tool_dev_url: "https://github.com/mathysgrapotte/stimulus-py"
licence: ["MIT"]
input:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1' ]`
- transform_json:
type: file
description: |
Json file with the transformation instructions
pattern: ".json"
- - csv:
type: file
description: |
Csv file to be transformed
pattern: ".csv"
output:
- csv:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1' ]`
- "${prefix}.csv":
type: file
description: |
Transformed CSV file
pattern: ".csv"
- versions:
- versions.yml:
type: file
description: |
File containing software versions
pattern: "versions.yml"
authors:
- "@luisas"
maintainers:
- "@luisas"
60 changes: 60 additions & 0 deletions modules/nf-core/stimulus/transform/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
nextflow_process {

name "Test Process STIMULUS_TRANSFORM"
script "../main.nf"
process "STIMULUS_TRANSFORM"

tag "modules"
tag "modules_nfcore"
tag "stimulus"
tag "stimulus/transform"

test("test") {

when {
process {
"""
input[0] = [
[ id:'test'], // meta map
file(params.modules_testdata_base_path + "../../deepmodeloptim/testdata/dna_experiment/experiment_config.json", checkIfExists: true)
]
input[1] = file(params.modules_testdata_base_path + "../../deepmodeloptim/testdata/dna_experiment/input_data_with_split.csv", checkIfExists: true)
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}

test("test - stub") {

options "-stub"

when {
process {
"""
input[0] = [
[ id:'test'], // meta map
file(params.modules_testdata_base_path + "../../deepmodeloptim/testdata/dna_experiment/experiment_config.json", checkIfExists: true)
]
input[1] = file(params.modules_testdata_base_path + "../../deepmodeloptim/testdata/dna_experiment/input_data_with_split.csv", checkIfExists: true)
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}

}
68 changes: 68 additions & 0 deletions modules/nf-core/stimulus/transform/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"test": {
"content": [
{
"0": [
[
{
"id": "test"
},
"test.csv:md5,854ec944dfaa7e6b10ad4f080aee3125"
]
],
"1": [
"versions.yml:md5,1531e9ca7e4e3b3489aa1932a9e14003"
],
"csv": [
[
{
"id": "test"
},
"test.csv:md5,854ec944dfaa7e6b10ad4f080aee3125"
]
],
"versions": [
"versions.yml:md5,1531e9ca7e4e3b3489aa1932a9e14003"
]
}
],
"meta": {
"nf-test": "0.9.1",
"nextflow": "24.04.4"
},
"timestamp": "2024-10-29T13:24:04.435440394"
},
"test - stub": {
"content": [
{
"0": [
[
{
"id": "test"
},
"test.csv:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"1": [
"versions.yml:md5,1531e9ca7e4e3b3489aa1932a9e14003"
],
"csv": [
[
{
"id": "test"
},
"test.csv:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"versions": [
"versions.yml:md5,1531e9ca7e4e3b3489aa1932a9e14003"
]
}
],
"meta": {
"nf-test": "0.9.1",
"nextflow": "24.04.4"
},
"timestamp": "2024-10-29T13:24:17.732637128"
}
}
2 changes: 2 additions & 0 deletions modules/nf-core/stimulus/transform/tests/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
stimulus/transform:
- "modules/nf-core/stimulus/transform/**"
Loading