Skip to content

new module: yte #5886

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

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
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
5 changes: 5 additions & 0 deletions modules/nf-core/yte/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
channels:
- conda-forge
- bioconda
dependencies:
- conda-forge::yte=1.9.0
53 changes: 53 additions & 0 deletions modules/nf-core/yte/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
process YTE {
tag "$meta.id"
label 'process_single'

// WARN: Version information not provided by tool on CLI. Please update version string below when bumping container versions.
conda "${moduleDir}/environment.yml"

// TODO: update container to 1.9.0
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'oras://community.wave.seqera.io/library/yte:1.5.4--2466971526dcd2a8':
'community.wave.seqera.io/library/yte:1.5.4--36d16ca4bab836c1' }"

input:
tuple val(meta), path(template)
path(map_file)
val(map)

output:
tuple val(meta), path("*.yaml"), emit: rendered
path "versions.yml" , emit: versions

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

script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"

// Use map_file if provided, otherwise use map to create key=value pairs for mapping command
def mapping_cmd = map_file ? "--variable-file ${map_file}" : "--variables " + map.collect { k, v -> "${k}=${v}" }.join(' ')
VERSION = "1.5.4" // WARN: Version information not provided by tool on CLI. Please update this string when bumping
"""
yte ${mapping_cmd} < ${template} > ${prefix}.yaml

cat <<-END_VERSIONS > versions.yml
"${task.process}":
yte: $VERSION
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
VERSION = "1.5.4" // WARN: Version information not provided by tool on CLI. Please update this string when bumping
"""
touch ${prefix}.yaml

cat <<-END_VERSIONS > versions.yml
"${task.process}":
yte: $VERSION
END_VERSIONS
"""
}
62 changes: 62 additions & 0 deletions modules/nf-core/yte/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: yte
description: A YAML template engine with Python expressions
keywords:
- yaml
- template
- python
tools:
- yte:
description: "A YAML template engine with Python expressions"
homepage: "https://yte-template-engine.github.io/"
documentation: "https://yte-template-engine.github.io/"
tool_dev_url: "https://github.com/yte-template-engine/yte"
licence: ["MIT"]
identifier: ""

input:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'template1' ]`
- template:
type: file
description: YTE template
pattern: "*.{yaml}"
ontologies:
- edam: http://edamontology.org/format_3750 # YAML
- - map_file:
type: file
description: YAML file containing a map to be used in the template
pattern: "*.{yaml}"
ontologies:
- edam: http://edamontology.org/format_3750 # YAML
- - map:
type: map
description: |
Groovy Map containing mapping information to be used in the template
e.g. `[ key: value ]` with key being a wildcard in the template

output:
- rendered:
- meta:
type: map
description: Groovy Map containing sample information
- "*.yaml":
type: file
description: Rendered YAML file
pattern: "*.yaml"
ontologies:
- edam: http://edamontology.org/format_3750 # YAML
- versions:
- versions.yml:
type: file
description: File containing software versions
pattern: "versions.yml"
ontologies:
- edam: http://edamontology.org/format_3750 # YAML

authors:
- "@famosab"
maintainers:
- "@famosab"
111 changes: 111 additions & 0 deletions modules/nf-core/yte/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
nextflow_process {

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

tag "modules"
tag "modules_nfcore"
tag "yte"

test("yaml - map") {

when {
process {
"""
input[0] = [
[ id:'template' ], // meta map
file('https://raw.githubusercontent.com/nf-core/test-datasets/1d7285ed7dea21f2d4079f7daa196b9f17bc6e85/data/generic/config/config_template.yte.yaml', checkIfExists: true)
]
input[1] = []
input[2] = [ 'sex': 'female' ] // map
"""
}
}

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

}

test("yaml - map - stub") {

options "-stub"

when {
process {
"""
input[0] = [
[ id:'template' ], // meta map
file('https://raw.githubusercontent.com/nf-core/test-datasets/1d7285ed7dea21f2d4079f7daa196b9f17bc6e85/data/generic/config/config_template.yte.yaml', checkIfExists: true)
]
input[1] = []
input[2] = [ 'sex': 'female' ] // map
"""
}
}

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

}

test("yaml - map_file") {

when {
process {
"""
input[0] = [
[ id:'template' ], // meta map
file('https://raw.githubusercontent.com/nf-core/test-datasets/1d7285ed7dea21f2d4079f7daa196b9f17bc6e85/data/generic/config/config_template.yte.yaml', checkIfExists: true)
]
input[1] = [file ('https://raw.githubusercontent.com/nf-core/test-datasets/811dd3fa80dbac64b14f07413ad78bb2bebe0323/data/generic/config/yte_map_file.yaml', checkIfExists: true)]
input[2] = [] // map
"""
}
}

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

}

test("yaml - map_file - stub") {

options "-stub"

when {
process {
"""
input[0] = [
[ id:'template' ], // meta map
file('https://raw.githubusercontent.com/nf-core/test-datasets/1d7285ed7dea21f2d4079f7daa196b9f17bc6e85/data/generic/config/config_template.yte.yaml', checkIfExists: true)
]
input[1] = [file ('https://raw.githubusercontent.com/nf-core/test-datasets/811dd3fa80dbac64b14f07413ad78bb2bebe0323/data/generic/config/yte_map_file.yaml', checkIfExists: true)]
input[2] = [] // map
"""
}
}

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

}

}
68 changes: 68 additions & 0 deletions modules/nf-core/yte/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"yaml - no_template": {
"content": [
{
"0": [
[
{
"id": "no_template"
},
"no_template.yaml:md5,a22cd4fd5af79c7c1f17f5decbfc1a8e"
]
],
"1": [
"versions.yml:md5,efd610134e8fc0892fddb2c50121e097"
],
"rendered": [
[
{
"id": "no_template"
},
"no_template.yaml:md5,a22cd4fd5af79c7c1f17f5decbfc1a8e"
]
],
"versions": [
"versions.yml:md5,efd610134e8fc0892fddb2c50121e097"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.2"
},
"timestamp": "2024-06-26T15:39:14.259911"
},
"yaml - no_template - stub": {
"content": [
{
"0": [
[
{
"id": "no_template"
},
"no_template.yaml:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"1": [
"versions.yml:md5,efd610134e8fc0892fddb2c50121e097"
],
"rendered": [
[
{
"id": "no_template"
},
"no_template.yaml:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"versions": [
"versions.yml:md5,efd610134e8fc0892fddb2c50121e097"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.2"
},
"timestamp": "2024-06-26T15:39:18.386795"
}
}
Loading