diff --git a/modules/nf-core/datavzrd/environment.yml b/modules/nf-core/datavzrd/environment.yml new file mode 100644 index 00000000000..879e964efaf --- /dev/null +++ b/modules/nf-core/datavzrd/environment.yml @@ -0,0 +1,7 @@ +name: datavzrd +channels: + - conda-forge + - bioconda + - defaults +dependencies: + - conda-forge::datavzrd==2.36.12 diff --git a/modules/nf-core/datavzrd/main.nf b/modules/nf-core/datavzrd/main.nf new file mode 100644 index 00000000000..a8a62612b51 --- /dev/null +++ b/modules/nf-core/datavzrd/main.nf @@ -0,0 +1,63 @@ +process DATAVZRD { + tag "$meta.id" + label 'process_single' + + conda "${moduleDir}/environment.yml" + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'oras://community.wave.seqera.io/library/datavzrd:2.36.12--bb93c8c988b7a9af': + 'community.wave.seqera.io/library/datavzrd:2.36.12--593eb75e566b7f2a' }" + + input: + tuple val(meta), file(config_file), file(table) + + output: + tuple val(meta), path("${prefix}"), emit: report + 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}" + """ + mkdir ${prefix} + datavzrd \\ + ${args} \\ + ${config_file} \\ + --output ${prefix} \\ + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + datavzrd: \$(echo \$( datavzrd --version | sed -e 's/[^0-9.]//g' )) + END_VERSIONS + """ + + stub: + prefix = task.ext.prefix ?: "${meta.id}" + """ + mkdir ${prefix} + mkdir ${prefix}/static + mkdir ${prefix}/network + mkdir ${prefix}/network/data + mkdir ${prefix}/network/plots + touch ./${prefix}/index.html + touch ./${prefix}/static/bootstrap.min.css + touch ./${prefix}/static/bootstrap-select.min.css + touch ./${prefix}/static/bootstrap-table.min.css + touch ./${prefix}/static/bootstrap-table-fixed-columns.min.css + touch ./${prefix}/static/bundle.js + touch ./${prefix}/static/datavzrd.css + touch ./${prefix}/network/index_1.html + touch ./${prefix}/network/config.js + touch ./${prefix}/network/functions.js + touch ./${prefix}/network/heatmap.js + touch ./${prefix}/network/data/data_1.js + touch ./${prefix}/network/plots/plot_0.js + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + datavzrd: \$(echo \$( datavzrd --version | sed -e 's/[^0-9.]//g' )) + END_VERSIONS + """ +} diff --git a/modules/nf-core/datavzrd/meta.yml b/modules/nf-core/datavzrd/meta.yml new file mode 100644 index 00000000000..8ac5f55d0d5 --- /dev/null +++ b/modules/nf-core/datavzrd/meta.yml @@ -0,0 +1,46 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json +name: "datavzrd" +description: Datavzrd is a tool to create visual HTML reports from collections of CSV/TSV tables. +keywords: + - visualisation + - tsv + - csv +tools: + - datavzrd: + description: Datavzrd is a tool to create visual HTML reports from collections of CSV/TSV tables. + homepage: https://datavzrd.github.io/ + documentation: https://datavzrd.github.io/docs/index.html + tool_dev_url: https://github.com/datavzrd/datavzrd + licence: ["MIT"] + +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - config_file: + type: file + description: configuration file used for visualisation + pattern: "*.{yml,yaml}" + - table: + type: file + description: file used for visualisation + pattern: "*.{tsv,csv}" + +output: + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + - report: + type: directory + description: directory with HTML report of provided CSV/TSV files + pattern: "/output/" + +authors: + - "@vickylaram" + - "@famosab" +maintainers: + - "@famosab" diff --git a/modules/nf-core/datavzrd/tests/main.nf.test b/modules/nf-core/datavzrd/tests/main.nf.test new file mode 100644 index 00000000000..86bd849a0cf --- /dev/null +++ b/modules/nf-core/datavzrd/tests/main.nf.test @@ -0,0 +1,112 @@ +nextflow_process { + name "Test Process DATAVZRD" + script "../main.nf" + process "DATAVZRD" + tag "modules" + tag "modules_nfcore" + tag "datavzrd" + + test("csv") { + + when { + process { + """ + input[0] = [ [id: "csv_config"], + file(params.modules_testdata_base_path + 'generic/config/config_test.datavzrd.yaml', checkIfExists: true), + file(params.modules_testdata_base_path + 'generic/csv/test.csv', checkIfExists: true) + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot( + process.out.versions, + path(process.out.report[0][1]) + .list() + .collect { getRecursiveFileNames(it, process.out.report[0][1]) } + .flatten() + ).match("csv") + } + ) + } + } + + test("tsv") { + + when { + process { + """ + input[0] = [ [id: "tsv_config"], + file(params.modules_testdata_base_path + 'generic/config/config_network.datavzrd.yaml', checkIfExists: true), + file(params.modules_testdata_base_path + 'generic/tsv/network.tsv', checkIfExists: true) + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot( + process.out.versions, + path(process.out.report[0][1]) + .list() + .collect { getRecursiveFileNames(it, process.out.report[0][1]) } + .flatten() + ).match("tsv") + } + ) + } + } + + test("csv - stub") { + + options "-stub" + + when { + process { + """ + input[0] = [ [id: "csv_config"], + file(params.modules_testdata_base_path + 'generic/config/config_test.datavzrd.yaml', checkIfExists: true), + file(params.modules_testdata_base_path + 'generic/csv/test.csv', checkIfExists: true) + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } + + test("no_config_file") { + when { + process { + """ + input[0] = [] + """ + } + } + + then { + assertAll( + { assert process.failed }, + { assert process.out['report'].isEmpty() }, + { assert snapshot(process.out).match() } + ) + } + } +} + +def getRecursiveFileNames(fileOrDir, outputDir) { + if(file(fileOrDir.toString()).isDirectory()) { + return fileOrDir.list().collect { getRecursiveFileNames(it, outputDir) } + } + return fileOrDir.toString().replace("${outputDir}/", "") +} diff --git a/modules/nf-core/datavzrd/tests/main.nf.test.snap b/modules/nf-core/datavzrd/tests/main.nf.test.snap new file mode 100644 index 00000000000..d57df8a44e4 --- /dev/null +++ b/modules/nf-core/datavzrd/tests/main.nf.test.snap @@ -0,0 +1,162 @@ +{ + "csv - stub": { + "content": [ + { + "0": [ + [ + { + "id": "csv_config" + }, + [ + "index.html:md5,d41d8cd98f00b204e9800998ecf8427e", + [ + "config.js:md5,d41d8cd98f00b204e9800998ecf8427e", + [ + "data_1.js:md5,d41d8cd98f00b204e9800998ecf8427e" + ], + "functions.js:md5,d41d8cd98f00b204e9800998ecf8427e", + "heatmap.js:md5,d41d8cd98f00b204e9800998ecf8427e", + "index_1.html:md5,d41d8cd98f00b204e9800998ecf8427e", + [ + "plot_0.js:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + [ + "bootstrap-select.min.css:md5,d41d8cd98f00b204e9800998ecf8427e", + "bootstrap-table-fixed-columns.min.css:md5,d41d8cd98f00b204e9800998ecf8427e", + "bootstrap-table.min.css:md5,d41d8cd98f00b204e9800998ecf8427e", + "bootstrap.min.css:md5,d41d8cd98f00b204e9800998ecf8427e", + "bundle.js:md5,d41d8cd98f00b204e9800998ecf8427e", + "datavzrd.css:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ] + ] + ], + "1": [ + "versions.yml:md5,4c539593d78c0a07ede5759e0ce5ade8" + ], + "report": [ + [ + { + "id": "csv_config" + }, + [ + "index.html:md5,d41d8cd98f00b204e9800998ecf8427e", + [ + "config.js:md5,d41d8cd98f00b204e9800998ecf8427e", + [ + "data_1.js:md5,d41d8cd98f00b204e9800998ecf8427e" + ], + "functions.js:md5,d41d8cd98f00b204e9800998ecf8427e", + "heatmap.js:md5,d41d8cd98f00b204e9800998ecf8427e", + "index_1.html:md5,d41d8cd98f00b204e9800998ecf8427e", + [ + "plot_0.js:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + [ + "bootstrap-select.min.css:md5,d41d8cd98f00b204e9800998ecf8427e", + "bootstrap-table-fixed-columns.min.css:md5,d41d8cd98f00b204e9800998ecf8427e", + "bootstrap-table.min.css:md5,d41d8cd98f00b204e9800998ecf8427e", + "bootstrap.min.css:md5,d41d8cd98f00b204e9800998ecf8427e", + "bundle.js:md5,d41d8cd98f00b204e9800998ecf8427e", + "datavzrd.css:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ] + ] + ], + "versions": [ + "versions.yml:md5,4c539593d78c0a07ede5759e0ce5ade8" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-06-26T10:16:55.267548327" + }, + "tsv": { + "content": [ + [ + "versions.yml:md5,4c539593d78c0a07ede5759e0ce5ade8" + ], + [ + "index.html", + "network/config.js", + "network/data/data_1.js", + "network/functions.js", + "network/heatmap.js", + "network/index_1.html", + "network/plots/plot_0.js", + "network/plots/plot_1.js", + "network/plots/plot_2.js", + "network/plots/plot_3.js", + "static/bootstrap-select.min.css", + "static/bootstrap-table-fixed-columns.min.css", + "static/bootstrap-table.min.css", + "static/bootstrap.min.css", + "static/bundle.js", + "static/datavzrd.css" + ] + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-06-26T10:15:02.495557702" + }, + "no_config_file": { + "content": [ + { + "0": [ + + ], + "1": [ + + ], + "report": [ + + ], + "versions": [ + + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-06-26T10:15:09.362847938" + }, + "csv": { + "content": [ + [ + "versions.yml:md5,4c539593d78c0a07ede5759e0ce5ade8" + ], + [ + "index.html", + "static/bootstrap-select.min.css", + "static/bootstrap-table-fixed-columns.min.css", + "static/bootstrap-table.min.css", + "static/bootstrap.min.css", + "static/bundle.js", + "static/datavzrd.css", + "test/config.js", + "test/data/data_1.js", + "test/functions.js", + "test/heatmap.js", + "test/index_1.html", + "test/plots/plot_0.js", + "test/plots/plot_1.js", + "test/plots/plot_2.js", + "test/plots/plot_3.js" + ] + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-06-26T10:14:58.495338891" + } +} \ No newline at end of file diff --git a/modules/nf-core/datavzrd/tests/tags.yml b/modules/nf-core/datavzrd/tests/tags.yml new file mode 100644 index 00000000000..e6eeb99d7ce --- /dev/null +++ b/modules/nf-core/datavzrd/tests/tags.yml @@ -0,0 +1,2 @@ +datavzrd: + - "modules/nf-core/datavzrd/**" diff --git a/tests/config/test_data.config b/tests/config/test_data.config index a65a8dd245a..25b2af15db4 100644 --- a/tests/config/test_data.config +++ b/tests/config/test_data.config @@ -745,6 +745,8 @@ params { } 'config' { ncbi_user_settings = "${params.test_data_base}/data/generic/config/ncbi_user_settings.mkfg" + config_test_datavzrd = "${params.test_data_base}/data/generic/config/config_test.datavzrd.yaml" + config_network_datavzrd = "${params.test_data_base}/data/generic/config/config_network.datavzrd.yaml" } 'unsorted_data' { 'unsorted_text' {