From 50a50b8253aaa7a988251c8e4cce6179c287408a Mon Sep 17 00:00:00 2001 From: Usman Rashid Date: Wed, 15 Jan 2025 13:35:33 +1300 Subject: [PATCH 1/2] Added agat/agatconvertbed2gff --- .../agat/agatconvertbed2gff/environment.yml | 7 ++ .../nf-core/agat/agatconvertbed2gff/main.nf | 45 ++++++++++++ .../nf-core/agat/agatconvertbed2gff/meta.yml | 49 +++++++++++++ .../agatconvertbed2gff/tests/main.nf.test | 58 +++++++++++++++ .../tests/main.nf.test.snap | 70 +++++++++++++++++++ 5 files changed, 229 insertions(+) create mode 100644 modules/nf-core/agat/agatconvertbed2gff/environment.yml create mode 100644 modules/nf-core/agat/agatconvertbed2gff/main.nf create mode 100644 modules/nf-core/agat/agatconvertbed2gff/meta.yml create mode 100644 modules/nf-core/agat/agatconvertbed2gff/tests/main.nf.test create mode 100644 modules/nf-core/agat/agatconvertbed2gff/tests/main.nf.test.snap diff --git a/modules/nf-core/agat/agatconvertbed2gff/environment.yml b/modules/nf-core/agat/agatconvertbed2gff/environment.yml new file mode 100644 index 00000000000..2c3daab3437 --- /dev/null +++ b/modules/nf-core/agat/agatconvertbed2gff/environment.yml @@ -0,0 +1,7 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json +channels: + - conda-forge + - bioconda +dependencies: + - "bioconda::agat=1.4.2" diff --git a/modules/nf-core/agat/agatconvertbed2gff/main.nf b/modules/nf-core/agat/agatconvertbed2gff/main.nf new file mode 100644 index 00000000000..cc351875d3f --- /dev/null +++ b/modules/nf-core/agat/agatconvertbed2gff/main.nf @@ -0,0 +1,45 @@ +process AGAT_AGATCONVERTBED2GFF { + tag "$meta.id" + label 'process_single' + + conda "${moduleDir}/environment.yml" + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/agat:1.4.0--pl5321hdfd78af_0' : + 'biocontainers/agat:1.4.0--pl5321hdfd78af_0' }" + + input: + tuple val(meta), path(bed) + + output: + tuple val(meta), path("*.gff") , emit: gff + 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}" + """ + agat_convert_bed2gff.pl \\ + --bed $bed \\ + --output ${prefix}.gff \\ + $args + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + agat: \$(agat_convert_bed2gff.pl --help | sed -n 's/.*(AGAT) - Version: \\(.*\\) .*/\\1/p') + END_VERSIONS + """ + + stub: + def prefix = task.ext.prefix ?: "${meta.id}" + """ + touch ${prefix}.gff + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + agat: \$(agat_convert_bed2gff.pl --help | sed -n 's/.*(AGAT) - Version: \\(.*\\) .*/\\1/p') + END_VERSIONS + """ +} diff --git a/modules/nf-core/agat/agatconvertbed2gff/meta.yml b/modules/nf-core/agat/agatconvertbed2gff/meta.yml new file mode 100644 index 00000000000..29c84739c5b --- /dev/null +++ b/modules/nf-core/agat/agatconvertbed2gff/meta.yml @@ -0,0 +1,49 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json +name: agat_agatconvertbed2gff +description: | + Takes a bed12 file and converts to a GFF3 file +keywords: + - genome + - bed + - gff + - conversion +tools: + - agat: + description: "AGAT is a toolkit for manipulation and getting information from + GFF/GTF files" + homepage: "https://github.com/NBISweden/AGAT" + documentation: "https://agat.readthedocs.io/" + tool_dev_url: "https://github.com/NBISweden/AGAT" + doi: "10.5281/zenodo.3552717" + licence: ["GPL v3"] + identifier: biotools:AGAT +input: + - - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - bed: + type: file + description: Input bed12 file + pattern: "*.bed" +output: + - gff: + - meta: + type: map + description: Groovy Map containing sample information + - "*.gff": + type: file + description: Output GFF3 file + pattern: "*.{gff}" + - versions: + - versions.yml: + type: file + description: File containing software versions + pattern: "versions.yml" + +authors: + - "@GallVp" +maintainers: + - "@GallVp" diff --git a/modules/nf-core/agat/agatconvertbed2gff/tests/main.nf.test b/modules/nf-core/agat/agatconvertbed2gff/tests/main.nf.test new file mode 100644 index 00000000000..3453a412339 --- /dev/null +++ b/modules/nf-core/agat/agatconvertbed2gff/tests/main.nf.test @@ -0,0 +1,58 @@ +nextflow_process { + + name "Test Process AGAT_AGATCONVERTBED2GFF" + script "../main.nf" + process "AGAT_AGATCONVERTBED2GFF" + + tag "modules" + tag "modules_nfcore" + tag "agat" + tag "agat/agatconvertbed2gff" + + test("sarscov2 - bed12") { + + when { + process { + """ + input[0] = [ + [ id:'test' ], // meta map + file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/bed/test.bed12', checkIfExists: true) + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + + } + + test("sarscov2 - bam - stub") { + + options "-stub" + + when { + process { + """ + input[0] = [ + [ id:'test', single_end:false ], // meta map + file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/bed/test.bed12', checkIfExists: true) + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + + } + +} \ No newline at end of file diff --git a/modules/nf-core/agat/agatconvertbed2gff/tests/main.nf.test.snap b/modules/nf-core/agat/agatconvertbed2gff/tests/main.nf.test.snap new file mode 100644 index 00000000000..d5c7da3eecb --- /dev/null +++ b/modules/nf-core/agat/agatconvertbed2gff/tests/main.nf.test.snap @@ -0,0 +1,70 @@ +{ + "sarscov2 - bam - stub": { + "content": [ + { + "0": [ + [ + { + "id": "test", + "single_end": false + }, + "test.gff:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + "versions.yml:md5,c43855fa732ead39246ba2aa2b044e1c" + ], + "gff": [ + [ + { + "id": "test", + "single_end": false + }, + "test.gff:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions": [ + "versions.yml:md5,c43855fa732ead39246ba2aa2b044e1c" + ] + } + ], + "meta": { + "nf-test": "0.9.0", + "nextflow": "24.10.3" + }, + "timestamp": "2025-01-15T13:31:55.362837" + }, + "sarscov2 - bed12": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test.gff:md5,4e5a23a6babac6d5b1bcfa06c5b12518" + ] + ], + "1": [ + "versions.yml:md5,c43855fa732ead39246ba2aa2b044e1c" + ], + "gff": [ + [ + { + "id": "test" + }, + "test.gff:md5,4e5a23a6babac6d5b1bcfa06c5b12518" + ] + ], + "versions": [ + "versions.yml:md5,c43855fa732ead39246ba2aa2b044e1c" + ] + } + ], + "meta": { + "nf-test": "0.9.0", + "nextflow": "24.10.3" + }, + "timestamp": "2025-01-15T13:31:49.570205" + } +} \ No newline at end of file From 9b7a89bf04a34d4df1e78ae1c862a67a978439dc Mon Sep 17 00:00:00 2001 From: Usman Rashid Date: Sat, 25 Jan 2025 20:02:01 +1300 Subject: [PATCH 2/2] Added nf-test for krona/ktimporttaxonomy --- .../nf-core/krona/ktimporttaxonomy/main.nf | 1 - .../krona/ktimporttaxonomy/tests/main.nf.test | 100 ++++++++++++++---- .../ktimporttaxonomy/tests/main.nf.test.snap | 73 +++++++++++-- .../ktimporttaxonomy/tests/nextflow.config | 5 + .../krona/ktimporttaxonomy/tests/tags.yml | 2 - tests/config/pytest_modules.yml | 3 - .../nf-core/krona/ktimporttaxonomy/main.nf | 28 ----- .../krona/ktimporttaxonomy/nextflow.config | 13 --- .../nf-core/krona/ktimporttaxonomy/test.yml | 17 --- 9 files changed, 147 insertions(+), 95 deletions(-) create mode 100644 modules/nf-core/krona/ktimporttaxonomy/tests/nextflow.config delete mode 100644 modules/nf-core/krona/ktimporttaxonomy/tests/tags.yml delete mode 100644 tests/modules/nf-core/krona/ktimporttaxonomy/main.nf delete mode 100644 tests/modules/nf-core/krona/ktimporttaxonomy/nextflow.config delete mode 100644 tests/modules/nf-core/krona/ktimporttaxonomy/test.yml diff --git a/modules/nf-core/krona/ktimporttaxonomy/main.nf b/modules/nf-core/krona/ktimporttaxonomy/main.nf index 16f3cd981d5..62b3afb2191 100644 --- a/modules/nf-core/krona/ktimporttaxonomy/main.nf +++ b/modules/nf-core/krona/ktimporttaxonomy/main.nf @@ -40,7 +40,6 @@ process KRONA_KTIMPORTTAXONOMY { """ stub: - def args = task.ext.args ?: '' def prefix = task.ext.prefix ?: "${meta.id}" def VERSION = '2.8.1' // WARN: Version information not provided by tool on CLI. Please update this string when bumping container versions. """ diff --git a/modules/nf-core/krona/ktimporttaxonomy/tests/main.nf.test b/modules/nf-core/krona/ktimporttaxonomy/tests/main.nf.test index 1068f305e3e..e61bd0e0fc6 100644 --- a/modules/nf-core/krona/ktimporttaxonomy/tests/main.nf.test +++ b/modules/nf-core/krona/ktimporttaxonomy/tests/main.nf.test @@ -1,6 +1,7 @@ nextflow_process { name "Test Process KRONA_KTIMPORTTAXONOMY" + config "./nextflow.config" script "../main.nf" process "KRONA_KTIMPORTTAXONOMY" @@ -9,53 +10,112 @@ nextflow_process { tag "krona" tag "krona/ktimporttaxonomy" - test ("sarscov2 - metagenome - kraken report") { + + + test("test_krona_ktimporttaxonomy_reads") { when { + params { + module_args = '-t 3' + } process { """ - input[0] = Channel.of([ - [id: 'test'], - file(params.modules_testdata_base_path + 'genomics/sarscov2/metagenome/test_1.kraken2.report.txt', checkIfExists: true) - ]) - input[1] = Channel.of([ - file(params.modules_testdata_base_path + 'genomics/sarscov2/metagenome/krona_taxonomy.tab', checkIfExists: true) - ]) + input[0] = [ + [id:'test',single_end:false],// meta map + file(params.modules_testdata_base_path + 'genomics/sarscov2/metagenome/test_1.kraken2.reads.txt', checkIfExists: true) + ] + input[1] = file(params.modules_testdata_base_path + 'genomics/sarscov2/metagenome/krona_taxonomy.tab', checkIfExists: true) """ } } + then { + assertAll( + { assert process.success }, + { assert snapshot( + file(process.out.html[0][1]).text.contains('Severe acute respiratory syndrome-related coronavirus'), + process.out.versions + ).match() + } + ) + } + } + + test("test_krona_ktimporttaxonomy_report") { + + when { + params { + module_args = '-m 3 -t 5' + } + process { + """ + input[0] = [ + [id:'test',single_end:false],// meta map + file(params.modules_testdata_base_path + 'genomics/sarscov2/metagenome/test_1.kraken2.report.txt', checkIfExists: true) + ] + input[1] = file(params.modules_testdata_base_path + 'genomics/sarscov2/metagenome/krona_taxonomy.tab', checkIfExists: true) + """ + } + } then { assertAll( { assert process.success }, - { assert snapshot ( process.out.versions ).match() }, - { assert file(process.out.html.get(0).get(1)).exists() } + { assert snapshot( + file(process.out.html[0][1]).text.contains('Severe acute respiratory syndrome-related coronavirus'), + process.out.versions + ).match() + } ) } } - test ("sarscov2 - metagenome - kraken report - stub") { + test("test_krona_ktimporttaxonomy_reads -- stub") { options '-stub' when { + params { + module_args = '-t 3' + } process { """ - input[0] = Channel.of([ - [id: 'test'], - file(params.modules_testdata_base_path + 'genomics/sarscov2/metagenome/test_1.kraken2.report.txt', checkIfExists: true) - ]) - input[1] = Channel.of([ - file(params.modules_testdata_base_path + 'genomics/sarscov2/metagenome/krona_taxonomy.tab', checkIfExists: true) - ]) + input[0] = [ + [id:'test',single_end:false],// meta map + file(params.modules_testdata_base_path + 'genomics/sarscov2/metagenome/test_1.kraken2.reads.txt', checkIfExists: true) + ] + input[1] = file(params.modules_testdata_base_path + 'genomics/sarscov2/metagenome/krona_taxonomy.tab', checkIfExists: true) """ } } + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } + + test("test_krona_ktimporttaxonomy_report -- stub") { + options '-stub' + when { + params { + module_args = '-m 3 -t 5' + } + process { + """ + input[0] = [ + [id:'test',single_end:false],// meta map + file(params.modules_testdata_base_path + 'genomics/sarscov2/metagenome/test_1.kraken2.report.txt', checkIfExists: true) + ] + input[1] = file(params.modules_testdata_base_path + 'genomics/sarscov2/metagenome/krona_taxonomy.tab', checkIfExists: true) + """ + } + } then { assertAll( { assert process.success }, - { assert snapshot(process.out).match() }, + { assert snapshot(process.out).match() } ) } } -} +} \ No newline at end of file diff --git a/modules/nf-core/krona/ktimporttaxonomy/tests/main.nf.test.snap b/modules/nf-core/krona/ktimporttaxonomy/tests/main.nf.test.snap index 61fba86809d..9e9c279e3f1 100644 --- a/modules/nf-core/krona/ktimporttaxonomy/tests/main.nf.test.snap +++ b/modules/nf-core/krona/ktimporttaxonomy/tests/main.nf.test.snap @@ -1,23 +1,25 @@ { - "sarscov2 - metagenome - kraken report": { + "test_krona_ktimporttaxonomy_report": { "content": [ + true, [ "versions.yml:md5,59fc89b6db8fad0aa9aa06f7437a18a7" ] ], "meta": { - "nf-test": "0.8.4", - "nextflow": "23.04.1" + "nf-test": "0.9.0", + "nextflow": "24.10.3" }, - "timestamp": "2024-08-08T10:34:23.760055" + "timestamp": "2025-01-25T19:59:51.434122" }, - "sarscov2 - metagenome - kraken report - stub": { + "test_krona_ktimporttaxonomy_report -- stub": { "content": [ { "0": [ [ { - "id": "test" + "id": "test", + "single_end": false }, "test.html:md5,d41d8cd98f00b204e9800998ecf8427e" ] @@ -28,7 +30,8 @@ "html": [ [ { - "id": "test" + "id": "test", + "single_end": false }, "test.html:md5,d41d8cd98f00b204e9800998ecf8427e" ] @@ -39,9 +42,57 @@ } ], "meta": { - "nf-test": "0.8.4", - "nextflow": "23.04.1" + "nf-test": "0.9.0", + "nextflow": "24.10.3" }, - "timestamp": "2024-08-08T10:34:29.695251" + "timestamp": "2025-01-25T19:54:28.461618" + }, + "test_krona_ktimporttaxonomy_reads": { + "content": [ + true, + [ + "versions.yml:md5,59fc89b6db8fad0aa9aa06f7437a18a7" + ] + ], + "meta": { + "nf-test": "0.9.0", + "nextflow": "24.10.3" + }, + "timestamp": "2025-01-25T19:59:46.33943" + }, + "test_krona_ktimporttaxonomy_reads -- stub": { + "content": [ + { + "0": [ + [ + { + "id": "test", + "single_end": false + }, + "test.html:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + "versions.yml:md5,59fc89b6db8fad0aa9aa06f7437a18a7" + ], + "html": [ + [ + { + "id": "test", + "single_end": false + }, + "test.html:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions": [ + "versions.yml:md5,59fc89b6db8fad0aa9aa06f7437a18a7" + ] + } + ], + "meta": { + "nf-test": "0.9.0", + "nextflow": "24.10.3" + }, + "timestamp": "2025-01-25T19:54:23.95162" } -} +} \ No newline at end of file diff --git a/modules/nf-core/krona/ktimporttaxonomy/tests/nextflow.config b/modules/nf-core/krona/ktimporttaxonomy/tests/nextflow.config new file mode 100644 index 00000000000..875f9410e33 --- /dev/null +++ b/modules/nf-core/krona/ktimporttaxonomy/tests/nextflow.config @@ -0,0 +1,5 @@ +process { + withName: "KRONA_KTIMPORTTAXONOMY" { + ext.args = params.module_args + } +} diff --git a/modules/nf-core/krona/ktimporttaxonomy/tests/tags.yml b/modules/nf-core/krona/ktimporttaxonomy/tests/tags.yml deleted file mode 100644 index 1112970eee9..00000000000 --- a/modules/nf-core/krona/ktimporttaxonomy/tests/tags.yml +++ /dev/null @@ -1,2 +0,0 @@ -krona/ktimporttaxonomy: - - "modules/nf-core/krona/ktimporttaxonomy/**" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index 70d378efe2d..7f74c5c325a 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -254,9 +254,6 @@ krakentools/combinekreports: krona/kronadb: - modules/nf-core/krona/kronadb/** - tests/modules/nf-core/krona/kronadb/** -krona/ktimporttaxonomy: - - modules/nf-core/krona/ktimporttaxonomy/** - - tests/modules/nf-core/krona/ktimporttaxonomy/** krona/ktimporttext: - modules/nf-core/krona/ktimporttext/** - tests/modules/nf-core/krona/ktimporttext/** diff --git a/tests/modules/nf-core/krona/ktimporttaxonomy/main.nf b/tests/modules/nf-core/krona/ktimporttaxonomy/main.nf deleted file mode 100644 index a267df50b2a..00000000000 --- a/tests/modules/nf-core/krona/ktimporttaxonomy/main.nf +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env nextflow - -nextflow.enable.dsl = 2 - -include { KRONA_KTIMPORTTAXONOMY as KRONA_KTIMPORTTAXONOMY_READS } from '../../../../../modules/nf-core/krona/ktimporttaxonomy/main.nf' -include { KRONA_KTIMPORTTAXONOMY as KRONA_KTIMPORTTAXONOMY_REPORT } from '../../../../../modules/nf-core/krona/ktimporttaxonomy/main.nf' - -workflow test_krona_ktimporttaxonomy_reads { - - input = [ - [ id:'test', single_end:false ], // meta map - file(params.test_data['sarscov2']['metagenome']['classified_reads_assignment'], checkIfExists: true) - ] - taxonomy = file(params.test_data['sarscov2']['metagenome']['krona_taxonomy'], checkIfExists: true) - - KRONA_KTIMPORTTAXONOMY_READS ( input, taxonomy ) -} - -workflow test_krona_ktimporttaxonomy_report { - - input = [ - [ id:'test', single_end:false ], // meta map - file(params.test_data['sarscov2']['metagenome']['kraken_report'], checkIfExists: true) - ] - taxonomy = file(params.test_data['sarscov2']['metagenome']['krona_taxonomy'], checkIfExists: true) - - KRONA_KTIMPORTTAXONOMY_REPORT ( input, taxonomy ) -} diff --git a/tests/modules/nf-core/krona/ktimporttaxonomy/nextflow.config b/tests/modules/nf-core/krona/ktimporttaxonomy/nextflow.config deleted file mode 100644 index fb4d86f5e2e..00000000000 --- a/tests/modules/nf-core/krona/ktimporttaxonomy/nextflow.config +++ /dev/null @@ -1,13 +0,0 @@ -process { - - publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } - - withName: KRONA_KTIMPORTTAXONOMY_READS { - ext.args = '-t 3' - } - - withName: KRONA_KTIMPORTTAXONOMY_REPORT { - ext.args = '-m 3 -t 5' - } - -} diff --git a/tests/modules/nf-core/krona/ktimporttaxonomy/test.yml b/tests/modules/nf-core/krona/ktimporttaxonomy/test.yml deleted file mode 100644 index d61a68fbb82..00000000000 --- a/tests/modules/nf-core/krona/ktimporttaxonomy/test.yml +++ /dev/null @@ -1,17 +0,0 @@ -- name: krona ktimporttaxonomy test_krona_ktimporttaxonomy_reads - command: nextflow run ./tests/modules/nf-core/krona/ktimporttaxonomy -entry test_krona_ktimporttaxonomy_reads -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/krona/ktimporttaxonomy/nextflow.config - tags: - - krona/ktimporttaxonomy - - krona - files: - - path: output/krona/test.html - contains: ["Krona is a flexible tool for exploring the relative proportions of"] - -- name: krona ktimporttaxonomy test_krona_ktimporttaxonomy_report - command: nextflow run ./tests/modules/nf-core/krona/ktimporttaxonomy -entry test_krona_ktimporttaxonomy_report -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/krona/ktimporttaxonomy/nextflow.config - tags: - - krona/ktimporttaxonomy - - krona - files: - - path: output/krona/test.html - contains: ["Krona is a flexible tool for exploring the relative proportions of"]