diff --git a/modules/nf-core/yte/environment.yml b/modules/nf-core/yte/environment.yml new file mode 100644 index 00000000000..ebacfca9d52 --- /dev/null +++ b/modules/nf-core/yte/environment.yml @@ -0,0 +1,5 @@ +channels: + - conda-forge + - bioconda +dependencies: + - conda-forge::yte=1.9.0 diff --git a/modules/nf-core/yte/main.nf b/modules/nf-core/yte/main.nf new file mode 100644 index 00000000000..dd3fbb578d3 --- /dev/null +++ b/modules/nf-core/yte/main.nf @@ -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 + """ +} diff --git a/modules/nf-core/yte/meta.yml b/modules/nf-core/yte/meta.yml new file mode 100644 index 00000000000..27de13034df --- /dev/null +++ b/modules/nf-core/yte/meta.yml @@ -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" diff --git a/modules/nf-core/yte/tests/main.nf.test b/modules/nf-core/yte/tests/main.nf.test new file mode 100644 index 00000000000..8da859fcc95 --- /dev/null +++ b/modules/nf-core/yte/tests/main.nf.test @@ -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() } + ) + } + + } + +} diff --git a/modules/nf-core/yte/tests/main.nf.test.snap b/modules/nf-core/yte/tests/main.nf.test.snap new file mode 100644 index 00000000000..a271a810d8f --- /dev/null +++ b/modules/nf-core/yte/tests/main.nf.test.snap @@ -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" + } +} \ No newline at end of file