From 483e4838a2a009e826ea14da0dfc6bcaccef5ad1 Mon Sep 17 00:00:00 2001 From: Jasmin Frangenberg <73216762+jasmezz@users.noreply.github.com> Date: Sat, 24 Feb 2024 08:58:17 +0000 Subject: [PATCH] Update `rgi/main` to 6.0.3 (#4933) * First attempt to include download of databases * Update module files + add nf-test (almost working) * Added stub + snapshot file + many fixes * Make rgi/main work with CARD download * Fix linting * Update depency `hamronization/rgi` * Fix command in `main.nf` * Fix `hamronization/rgi` accordingly * Removed DB download functionality * Removed hamronization/rgi non-stub test * Update meta.yml * Add module rgi/cardannotation (not working yet) * Make rgi/main tests work incl. dependency rgi/cardannotation * Fix hamronization/rgi tests * Update rgi/cardannotation snapfile * Apply suggestions from code review --- .../hamronization/rgi/tests/main.nf.test | 34 ++++- .../hamronization/rgi/tests/main.nf.test.snap | 16 +- .../rgi/cardannotation/environment.yml | 7 + modules/nf-core/rgi/cardannotation/main.nf | 61 ++++++++ modules/nf-core/rgi/cardannotation/meta.yml | 42 +++++ .../rgi/cardannotation/tests/main.nf.test | 66 ++++++++ .../cardannotation/tests/main.nf.test.snap | 118 +++++++++++++++ .../nf-core/rgi/cardannotation/tests/tags.yml | 2 + modules/nf-core/rgi/main/environment.yml | 2 +- modules/nf-core/rgi/main/main.nf | 64 ++++++-- modules/nf-core/rgi/main/meta.yml | 13 +- modules/nf-core/rgi/main/tests/main.nf.test | 94 ++++++++++++ .../nf-core/rgi/main/tests/main.nf.test.snap | 143 ++++++++++++++++++ modules/nf-core/rgi/main/tests/tags.yml | 2 + tests/config/pytest_modules.yml | 3 - tests/modules/nf-core/rgi/main/main.nf | 15 -- .../modules/nf-core/rgi/main/nextflow.config | 5 - tests/modules/nf-core/rgi/main/test.yml | 40 ----- 18 files changed, 640 insertions(+), 87 deletions(-) create mode 100644 modules/nf-core/rgi/cardannotation/environment.yml create mode 100644 modules/nf-core/rgi/cardannotation/main.nf create mode 100644 modules/nf-core/rgi/cardannotation/meta.yml create mode 100644 modules/nf-core/rgi/cardannotation/tests/main.nf.test create mode 100644 modules/nf-core/rgi/cardannotation/tests/main.nf.test.snap create mode 100644 modules/nf-core/rgi/cardannotation/tests/tags.yml create mode 100644 modules/nf-core/rgi/main/tests/main.nf.test create mode 100644 modules/nf-core/rgi/main/tests/main.nf.test.snap create mode 100644 modules/nf-core/rgi/main/tests/tags.yml delete mode 100644 tests/modules/nf-core/rgi/main/main.nf delete mode 100644 tests/modules/nf-core/rgi/main/nextflow.config delete mode 100644 tests/modules/nf-core/rgi/main/test.yml diff --git a/modules/nf-core/hamronization/rgi/tests/main.nf.test b/modules/nf-core/hamronization/rgi/tests/main.nf.test index 3d1246c14be..52945ebe8e0 100644 --- a/modules/nf-core/hamronization/rgi/tests/main.nf.test +++ b/modules/nf-core/hamronization/rgi/tests/main.nf.test @@ -9,22 +9,50 @@ nextflow_process { tag "hamronization" tag "hamronization/rgi" tag "rgi/main" + tag "rgi/cardannotation" + tag "untar" setup { + + run("UNTAR") { + script "modules/nf-core/untar/main.nf" + process { + """ + file('https://card.mcmaster.ca/latest/data', checkIfExists: true).copyTo('data.tar.gz') + + input[0] = [ + [ ], + file("data.tar.gz") + ] + """ + } + } + + run("RGI_CARDANNOTATION") { + script "modules/nf-core/rgi/cardannotation/main.nf" + process { + """ + input[0] = UNTAR.out.untar.map{ it[1] } + """ + } + } + run("RGI_MAIN") { - script "../../../rgi/main/main.nf" + script "modules/nf-core/rgi/main/main.nf" process { """ input[0] = [ [ id:'test', single_end:false ], // meta map file(params.test_data['haemophilus_influenzae']['genome']['genome_fna_gz'], checkIfExists: true) ] + input[1] = RGI_CARDANNOTATION.out.db + input[2] = [] """ } } } - test("hamronization/amrfinderplus - haemophilus_influenzae - genome - fna.gz") { + test("hamronization/rgi - haemophilus_influenzae - genome - fna.gz") { when { process { @@ -45,7 +73,7 @@ nextflow_process { } } - test("hamronization/amrfinderplus - haemophilus_influenzae - genome - fna.gz - stub") { + test("hamronization/rgi - haemophilus_influenzae - genome - fna.gz - stub") { options "-stub" diff --git a/modules/nf-core/hamronization/rgi/tests/main.nf.test.snap b/modules/nf-core/hamronization/rgi/tests/main.nf.test.snap index 919da9a4a76..07a41eae48a 100644 --- a/modules/nf-core/hamronization/rgi/tests/main.nf.test.snap +++ b/modules/nf-core/hamronization/rgi/tests/main.nf.test.snap @@ -1,5 +1,5 @@ { - "hamronization/amrfinderplus - haemophilus_influenzae - genome - fna.gz": { + "hamronization/rgi - haemophilus_influenzae - genome - fna.gz - stub": { "content": [ { "0": [ @@ -11,7 +11,7 @@ "id": "test", "single_end": false }, - "test.tsv:md5,573e4aae777fc00485a033acb7dcc8fb" + "test.tsv:md5,d41d8cd98f00b204e9800998ecf8427e" ] ], "2": [ @@ -26,7 +26,7 @@ "id": "test", "single_end": false }, - "test.tsv:md5,573e4aae777fc00485a033acb7dcc8fb" + "test.tsv:md5,d41d8cd98f00b204e9800998ecf8427e" ] ], "versions": [ @@ -38,9 +38,9 @@ "nf-test": "0.8.4", "nextflow": "23.10.1" }, - "timestamp": "2024-02-08T00:14:38.91140175" + "timestamp": "2024-02-19T23:16:18.164635116" }, - "hamronization/amrfinderplus - haemophilus_influenzae - genome - fna.gz - stub": { + "hamronization/rgi - haemophilus_influenzae - genome - fna.gz": { "content": [ { "0": [ @@ -52,7 +52,7 @@ "id": "test", "single_end": false }, - "test.tsv:md5,d41d8cd98f00b204e9800998ecf8427e" + "test.tsv:md5,98b98bc42db5569db041d1819bbf1d89" ] ], "2": [ @@ -67,7 +67,7 @@ "id": "test", "single_end": false }, - "test.tsv:md5,d41d8cd98f00b204e9800998ecf8427e" + "test.tsv:md5,98b98bc42db5569db041d1819bbf1d89" ] ], "versions": [ @@ -79,6 +79,6 @@ "nf-test": "0.8.4", "nextflow": "23.10.1" }, - "timestamp": "2024-02-08T00:24:48.757808054" + "timestamp": "2024-02-19T23:15:49.081218466" } } \ No newline at end of file diff --git a/modules/nf-core/rgi/cardannotation/environment.yml b/modules/nf-core/rgi/cardannotation/environment.yml new file mode 100644 index 00000000000..f1c5872aa72 --- /dev/null +++ b/modules/nf-core/rgi/cardannotation/environment.yml @@ -0,0 +1,7 @@ +name: rgi_cardannotation +channels: + - conda-forge + - bioconda + - defaults +dependencies: + - bioconda::rgi=6.0.3 diff --git a/modules/nf-core/rgi/cardannotation/main.nf b/modules/nf-core/rgi/cardannotation/main.nf new file mode 100644 index 00000000000..9be57c856c6 --- /dev/null +++ b/modules/nf-core/rgi/cardannotation/main.nf @@ -0,0 +1,61 @@ +process RGI_CARDANNOTATION { + label 'process_medium' + + conda "${moduleDir}/environment.yml" + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/rgi:6.0.3--pyha8f3691_0': + 'biocontainers/rgi:6.0.3--pyha8f3691_0' }" + + input: + path(card) + + output: + path("card_database_processed") , emit: db + env RGI_VERSION , emit: tool_version + env DB_VERSION , emit: db_version + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def args = task.ext.args ?: '' + + """ + rgi card_annotation \\ + -i ${card}/card.json \\ + $args + + DB_VERSION=\$(ls card_database_*_all.fasta | sed "s/card_database_v\\([0-9].*[0-9]\\).*/\\1/") + + mkdir card_database_processed + mv card*.fasta card_database_processed + cp ${card}/* card_database_processed + + RGI_VERSION=\$(rgi main --version) + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + rgi: \$(echo \$RGI_VERSION) + rgi-database: \$(echo \$DB_VERSION) + END_VERSIONS + """ + + stub: + """ + touch card.fasta + touch card_all.fasta + + mkdir card_database_processed + mv card*.fasta card_database_processed + + RGI_VERSION=\$(rgi main --version) + DB_VERSION=stub_version + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + rgi: \$(echo \$RGI_VERSION) + rgi-database: \$(echo \$DB_VERSION) + END_VERSIONS + """ +} diff --git a/modules/nf-core/rgi/cardannotation/meta.yml b/modules/nf-core/rgi/cardannotation/meta.yml new file mode 100644 index 00000000000..97e6911da6a --- /dev/null +++ b/modules/nf-core/rgi/cardannotation/meta.yml @@ -0,0 +1,42 @@ +name: rgi_cardannotation +description: Preprocess the CARD database for RGI to predict antibiotic resistance from protein or nucleotide data +keywords: + - bacteria + - fasta + - antibiotic resistance +tools: + - rgi: + description: This module preprocesses the downloaded Comprehensive Antibiotic Resistance Database (CARD) which can then be used as input for RGI. + homepage: https://card.mcmaster.ca + documentation: https://github.com/arpcard/rgi + tool_dev_url: https://github.com/arpcard/rgi + doi: "10.1093/nar/gkz935" + licence: ["https://card.mcmaster.ca/about"] +input: + - card: + type: directory + description: Directory containing the CARD database + pattern: "*/" +output: + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + - db: + type: directory + description: Directory containing the processed CARD database files + pattern: "*/" + - tool_version: + type: string + description: The version of the tool in string format (useful for downstream tools such as hAMRronization) + - db_version: + type: string + description: The version of the used database in string format (useful for downstream tools such as hAMRronization) +authors: + - "@rpetit3" + - "@jfy133" + - "@jasmezz" +maintainers: + - "@rpetit3" + - "@jfy133" + - "@jasmezz" diff --git a/modules/nf-core/rgi/cardannotation/tests/main.nf.test b/modules/nf-core/rgi/cardannotation/tests/main.nf.test new file mode 100644 index 00000000000..fa51142aa75 --- /dev/null +++ b/modules/nf-core/rgi/cardannotation/tests/main.nf.test @@ -0,0 +1,66 @@ +nextflow_process { + + name "Test Process RGI_CARDANNOTATION" + script "../main.nf" + process "RGI_CARDANNOTATION" + + tag "modules" + tag "modules_nfcore" + tag "rgi" + tag "rgi/cardannotation" + tag "untar" + + setup { + run("UNTAR") { + script "modules/nf-core/untar/main.nf" + process { + """ + file('https://card.mcmaster.ca/latest/data', checkIfExists: true).copyTo('data.tar.gz') + + input[0] = [ + [ ], + file("data.tar.gz") + ] + """ + } + } + } + + test("rgi/cardannotation") { + + when { + process { + """ + input[0] = UNTAR.out.untar.map{ it[1] } + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } + + test("rgi/cardannotation - stub") { + + options "-stub" + + when { + process { + """ + input[0] = UNTAR.out.untar.map{ it[1] } + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } +} diff --git a/modules/nf-core/rgi/cardannotation/tests/main.nf.test.snap b/modules/nf-core/rgi/cardannotation/tests/main.nf.test.snap new file mode 100644 index 00000000000..5d58124d739 --- /dev/null +++ b/modules/nf-core/rgi/cardannotation/tests/main.nf.test.snap @@ -0,0 +1,118 @@ +{ + "rgi/cardannotation - stub": { + "content": [ + { + "0": [ + [ + "card.fasta:md5,d41d8cd98f00b204e9800998ecf8427e", + "card_all.fasta:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + "6.0.3" + ], + "2": [ + "stub_version" + ], + "3": [ + "versions.yml:md5,ff6d0eeef874d3a3cb6e823cd4610e2d" + ], + "db": [ + [ + "card.fasta:md5,d41d8cd98f00b204e9800998ecf8427e", + "card_all.fasta:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "db_version": [ + "stub_version" + ], + "tool_version": [ + "6.0.3" + ], + "versions": [ + "versions.yml:md5,ff6d0eeef874d3a3cb6e823cd4610e2d" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-02-19T23:33:34.376943812" + }, + "rgi/cardannotation": { + "content": [ + { + "0": [ + [ + "CARD-Download-README.txt:md5,ca330e1d89e3a97ac6f50c86a8ca5c34", + "aro_categories.tsv:md5,ba2f33c43b199cd62ae5663125ce316e", + "aro_categories_index.tsv:md5,39f995f2356b6a0cb5fd34e3c6ffc8e1", + "aro_index.tsv:md5,b7250ed3208c8497ec2371527a689eeb", + "card.json:md5,e2cb53b1706a602d5265d2284a1fcdd5", + "card_database_v3.2.9.fasta:md5,0839d4447860694782a5db5cd6eae085", + "card_database_v3.2.9_all.fasta:md5,5295875faf06bef62ea954fef40958c3", + "nucleotide_fasta_protein_homolog_model.fasta:md5,ebcd48a6c9e14f339ffd9d2673eed803", + "nucleotide_fasta_protein_knockout_model.fasta:md5,ff476b358ef70da53acf4602568a9b9b", + "nucleotide_fasta_protein_overexpression_model.fasta:md5,68937e587c880153400fa8203f6a90d5", + "nucleotide_fasta_protein_variant_model.fasta:md5,1ff9cbaf0d640e2084f13751309f8176", + "nucleotide_fasta_rRNA_gene_variant_model.fasta:md5,b88fbe1d6de44b2ff2819ee63d001d75", + "protein_fasta_protein_homolog_model.fasta:md5,130a0947c60d18ef2e7d0ab886f80af3", + "protein_fasta_protein_knockout_model.fasta:md5,6b259399e3eae3f23eaa421bbba6ba25", + "protein_fasta_protein_overexpression_model.fasta:md5,758b753b821789147cdd795c654940ad", + "protein_fasta_protein_variant_model.fasta:md5,ec46ea3d9dc7ab01ec22cf265e410c88", + "shortname_antibiotics.tsv:md5,9d20abb9f6d37ed0cecc1573867ca49a", + "shortname_pathogens.tsv:md5,ae267113de686bc8f58eab5845cc343b", + "snps.txt:md5,ee6dfbe7a65f3ffdb6968822c47e4550" + ] + ], + "1": [ + "6.0.3" + ], + "2": [ + "3.2.9" + ], + "3": [ + "versions.yml:md5,43f331ec71ec01a1bae10e30f4ce4f26" + ], + "db": [ + [ + "CARD-Download-README.txt:md5,ca330e1d89e3a97ac6f50c86a8ca5c34", + "aro_categories.tsv:md5,ba2f33c43b199cd62ae5663125ce316e", + "aro_categories_index.tsv:md5,39f995f2356b6a0cb5fd34e3c6ffc8e1", + "aro_index.tsv:md5,b7250ed3208c8497ec2371527a689eeb", + "card.json:md5,e2cb53b1706a602d5265d2284a1fcdd5", + "card_database_v3.2.9.fasta:md5,0839d4447860694782a5db5cd6eae085", + "card_database_v3.2.9_all.fasta:md5,5295875faf06bef62ea954fef40958c3", + "nucleotide_fasta_protein_homolog_model.fasta:md5,ebcd48a6c9e14f339ffd9d2673eed803", + "nucleotide_fasta_protein_knockout_model.fasta:md5,ff476b358ef70da53acf4602568a9b9b", + "nucleotide_fasta_protein_overexpression_model.fasta:md5,68937e587c880153400fa8203f6a90d5", + "nucleotide_fasta_protein_variant_model.fasta:md5,1ff9cbaf0d640e2084f13751309f8176", + "nucleotide_fasta_rRNA_gene_variant_model.fasta:md5,b88fbe1d6de44b2ff2819ee63d001d75", + "protein_fasta_protein_homolog_model.fasta:md5,130a0947c60d18ef2e7d0ab886f80af3", + "protein_fasta_protein_knockout_model.fasta:md5,6b259399e3eae3f23eaa421bbba6ba25", + "protein_fasta_protein_overexpression_model.fasta:md5,758b753b821789147cdd795c654940ad", + "protein_fasta_protein_variant_model.fasta:md5,ec46ea3d9dc7ab01ec22cf265e410c88", + "shortname_antibiotics.tsv:md5,9d20abb9f6d37ed0cecc1573867ca49a", + "shortname_pathogens.tsv:md5,ae267113de686bc8f58eab5845cc343b", + "snps.txt:md5,ee6dfbe7a65f3ffdb6968822c47e4550" + ] + ], + "db_version": [ + "3.2.9" + ], + "tool_version": [ + "6.0.3" + ], + "versions": [ + "versions.yml:md5,43f331ec71ec01a1bae10e30f4ce4f26" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-02-19T23:33:06.962413561" + } +} \ No newline at end of file diff --git a/modules/nf-core/rgi/cardannotation/tests/tags.yml b/modules/nf-core/rgi/cardannotation/tests/tags.yml new file mode 100644 index 00000000000..02c2de0b09c --- /dev/null +++ b/modules/nf-core/rgi/cardannotation/tests/tags.yml @@ -0,0 +1,2 @@ +rgi/cardannotation: + - "modules/nf-core/rgi/cardannotation/**" diff --git a/modules/nf-core/rgi/main/environment.yml b/modules/nf-core/rgi/main/environment.yml index f4eeef9510e..f229cc213fd 100644 --- a/modules/nf-core/rgi/main/environment.yml +++ b/modules/nf-core/rgi/main/environment.yml @@ -4,4 +4,4 @@ channels: - bioconda - defaults dependencies: - - bioconda::rgi=5.2.1 + - bioconda::rgi=6.0.3 diff --git a/modules/nf-core/rgi/main/main.nf b/modules/nf-core/rgi/main/main.nf index 58874e717a4..174714807da 100644 --- a/modules/nf-core/rgi/main/main.nf +++ b/modules/nf-core/rgi/main/main.nf @@ -4,30 +4,57 @@ process RGI_MAIN { conda "${moduleDir}/environment.yml" container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? - 'https://depot.galaxyproject.org/singularity/rgi:5.2.1--pyha8f3691_2': - 'biocontainers/rgi:5.2.1--pyha8f3691_2' }" + 'https://depot.galaxyproject.org/singularity/rgi:6.0.3--pyha8f3691_0': + 'biocontainers/rgi:6.0.3--pyha8f3691_0' }" input: tuple val(meta), path(fasta) + path(card) + path(wildcard) output: tuple val(meta), path("*.json"), emit: json tuple val(meta), path("*.txt") , emit: tsv - tuple val(meta), path("temp/") , emit: tmp - env VER , emit: tool_version - env DBVER , emit: db_version + tuple val(meta), path("temp/") , emit: tmp + env RGI_VERSION , emit: tool_version + env DB_VERSION , emit: db_version path "versions.yml" , emit: versions when: task.ext.when == null || task.ext.when script: - def args = task.ext.args ?: '' + def args = task.ext.args ?: '' // This customizes the command: rgi load + def args2 = task.ext.args ?: '' // This customizes the command: rgi main def prefix = task.ext.prefix ?: "${meta.id}" + def load_wildcard = "" + + if (wildcard) { + load_wildcard = """ \\ + --wildcard_annotation ${wildcard}/wildcard_database_v\$DB_VERSION.fasta \\ + --wildcard_annotation_all_models ${wildcard}/wildcard_database_v\$DB_VERSION\\_all.fasta \\ + --wildcard_index ${wildcard}/wildcard/index-for-model-sequences.txt \\ + --amr_kmers ${wildcard}/wildcard/all_amr_61mers.txt \\ + --kmer_database ${wildcard}/wildcard/61_kmer_db.json \\ + --kmer_size 61 + """ + } + """ + DB_VERSION=\$(ls ${card}/card_database_*_all.fasta | sed "s/${card}\\/card_database_v\\([0-9].*[0-9]\\).*/\\1/") + rgi \\ - main \\ + load \\ $args \\ + --card_json ${card}/card.json \\ + --debug --local \\ + --card_annotation ${card}/card_database_v\$DB_VERSION.fasta \\ + --card_annotation_all_models ${card}/card_database_v\$DB_VERSION\\_all.fasta \\ + $load_wildcard + + rgi \\ + main \\ + $args2 \\ --num_threads $task.cpus \\ --output_file $prefix \\ --input_sequence $fasta @@ -35,13 +62,28 @@ process RGI_MAIN { mkdir temp/ mv *.xml *.fsa *.{nhr,nin,nsq} *.draft *.potentialGenes *{variant,rrna,protein,predictedGenes,overexpression,homolog}.json temp/ - VER=\$(rgi main --version) - DBVER=\$(rgi database --version) + RGI_VERSION=\$(rgi main --version) + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + rgi: \$(echo \$RGI_VERSION) + rgi-database: \$(echo \$DB_VERSION) + END_VERSIONS + """ + + stub: + """ + mkdir -p temp + touch test.json + touch test.txt + + RGI_VERSION=\$(rgi main --version) + DB_VERSION=stub_version cat <<-END_VERSIONS > versions.yml "${task.process}": - rgi: \$(echo \$VER) - rgi-database: \$(echo \$DBVER) + rgi: \$(echo \$RGI_VERSION) + rgi-database: \$(echo \$DB_VERSION) END_VERSIONS """ } diff --git a/modules/nf-core/rgi/main/meta.yml b/modules/nf-core/rgi/main/meta.yml index e03bd1dcd28..7e444c8bbfe 100644 --- a/modules/nf-core/rgi/main/meta.yml +++ b/modules/nf-core/rgi/main/meta.yml @@ -22,6 +22,15 @@ input: type: file description: Nucleotide or protein sequences in FASTA format pattern: "*.{fasta,fasta.gz,fa,fa.gz,fna,fna.gz,faa,faa.gz}" + - card: + type: directory + description: Directory containing the CARD database. This is expected to be the unarchived but otherwise unaltered download folder (see RGI documentation for download instructions). + pattern: "*/" + - wildcard: + type: directory + description: Directory containing the WildCARD database (optional). This is expected to be the unarchived but otherwise unaltered download folder (see RGI documentation for download instructions). + pattern: "*/" + output: - meta: type: map @@ -40,7 +49,7 @@ output: type: file description: Tab-delimited file with RGI results pattern: "*.{txt}" - - temp: + - tmp: type: directory description: Directory containing various intermediate files pattern: "temp/" @@ -53,6 +62,8 @@ output: authors: - "@rpetit3" - "@jfy133" + - "@jasmezz" maintainers: - "@rpetit3" - "@jfy133" + - "@jasmezz" diff --git a/modules/nf-core/rgi/main/tests/main.nf.test b/modules/nf-core/rgi/main/tests/main.nf.test new file mode 100644 index 00000000000..fce16564539 --- /dev/null +++ b/modules/nf-core/rgi/main/tests/main.nf.test @@ -0,0 +1,94 @@ +nextflow_process { + + name "Test Process RGI_MAIN" + script "../main.nf" + process "RGI_MAIN" + + tag "modules" + tag "modules_nfcore" + tag "rgi" + tag "rgi/main" + tag "rgi/cardannotation" + tag "untar" + + setup { + run("UNTAR") { + script "modules/nf-core/untar/main.nf" + process { + """ + file('https://card.mcmaster.ca/latest/data', checkIfExists: true).copyTo('data.tar.gz') + + input[0] = [ + [ ], + file("data.tar.gz") + ] + """ + } + } + + run("RGI_CARDANNOTATION") { + script "modules/nf-core/rgi/cardannotation" + process { + """ + input[0] = UNTAR.out.untar.map{ it[1] } + """ + } + } + } + + + test("rgi/main - haemophilus_influenzae - genome_fna_gz") { + + when { + process { + """ + input[0] = [ + [ id:'test', single_end:false ], // meta map + file(params.test_data['haemophilus_influenzae']['genome']['genome_fna_gz'], checkIfExists: true) + ] + input[1] = RGI_CARDANNOTATION.out.db + input[2] = [] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot( + process.out.versions, + process.out.tsv, + process.out.json, + file(process.out.tmp.get(0).get(1)).list().sort(), + process.out.tool_version, + process.out.db_version, + ).match() } + ) + } + } + + test("rgi/main - haemophilus_influenzae - genome_fna_gz - stub") { + + options "-stub" + + when { + process { + """ + input[0] = [ + [ id:'test', single_end:false ], // meta map + file(params.test_data['haemophilus_influenzae']['genome']['genome_fna_gz'], checkIfExists: true) + ] + input[1] = RGI_CARDANNOTATION.out.db + input[2] = [] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } +} diff --git a/modules/nf-core/rgi/main/tests/main.nf.test.snap b/modules/nf-core/rgi/main/tests/main.nf.test.snap new file mode 100644 index 00000000000..a8dc1d61ead --- /dev/null +++ b/modules/nf-core/rgi/main/tests/main.nf.test.snap @@ -0,0 +1,143 @@ +{ + "rgi/main - haemophilus_influenzae - genome_fna_gz - stub": { + "content": [ + { + "0": [ + [ + { + "id": "test", + "single_end": false + }, + "test.json:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + [ + { + "id": "test", + "single_end": false + }, + "test.txt:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "2": [ + [ + { + "id": "test", + "single_end": false + }, + [ + + ] + ] + ], + "3": [ + "6.0.3" + ], + "4": [ + "stub_version" + ], + "5": [ + "versions.yml:md5,f77ce9bdc8d309c9d6f7ec63bd53f5cf" + ], + "db_version": [ + "stub_version" + ], + "json": [ + [ + { + "id": "test", + "single_end": false + }, + "test.json:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "tmp": [ + [ + { + "id": "test", + "single_end": false + }, + [ + + ] + ] + ], + "tool_version": [ + "6.0.3" + ], + "tsv": [ + [ + { + "id": "test", + "single_end": false + }, + "test.txt:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions": [ + "versions.yml:md5,f77ce9bdc8d309c9d6f7ec63bd53f5cf" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-02-19T22:51:36.047807514" + }, + "rgi/main - haemophilus_influenzae - genome_fna_gz": { + "content": [ + [ + "versions.yml:md5,a9f89e3bebd538efa07bcbe9fe1ba37a" + ], + [ + [ + { + "id": "test", + "single_end": false + }, + "test.txt:md5,5854d6bef754d91da80980e96b6a054b" + ] + ], + [ + [ + { + "id": "test", + "single_end": false + }, + "test.json:md5,f9ca00ea1ff6e733c7c25bb2dfd65128" + ] + ], + [ + "genome.fna.gz.temp.uncompressed.fsa", + "genome.fna.gz.temp.uncompressed.fsa.temp.blastRes.rrna.xml", + "genome.fna.gz.temp.uncompressed.fsa.temp.contig.fsa", + "genome.fna.gz.temp.uncompressed.fsa.temp.contig.fsa.blastRes.xml", + "genome.fna.gz.temp.uncompressed.fsa.temp.contigToORF.fsa", + "genome.fna.gz.temp.uncompressed.fsa.temp.db.nhr", + "genome.fna.gz.temp.uncompressed.fsa.temp.db.nin", + "genome.fna.gz.temp.uncompressed.fsa.temp.db.nsq", + "genome.fna.gz.temp.uncompressed.fsa.temp.draft", + "genome.fna.gz.temp.uncompressed.fsa.temp.homolog.json", + "genome.fna.gz.temp.uncompressed.fsa.temp.overexpression.json", + "genome.fna.gz.temp.uncompressed.fsa.temp.potentialGenes", + "genome.fna.gz.temp.uncompressed.fsa.temp.predictedGenes.json", + "genome.fna.gz.temp.uncompressed.fsa.temp.predictedGenes.protein.json", + "genome.fna.gz.temp.uncompressed.fsa.temp.rrna.json", + "genome.fna.gz.temp.uncompressed.fsa.temp.variant.json" + ], + [ + "6.0.3" + ], + [ + "3.2.9" + ] + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-02-19T22:51:14.372178941" + } +} \ No newline at end of file diff --git a/modules/nf-core/rgi/main/tests/tags.yml b/modules/nf-core/rgi/main/tests/tags.yml new file mode 100644 index 00000000000..e68ad8a27ab --- /dev/null +++ b/modules/nf-core/rgi/main/tests/tags.yml @@ -0,0 +1,2 @@ +rgi/main: + - "modules/nf-core/rgi/main/**" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index 55559da7204..c814d9206e7 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -1842,9 +1842,6 @@ raven: raxmlng: - modules/nf-core/raxmlng/** - tests/modules/nf-core/raxmlng/** -rgi/main: - - modules/nf-core/rgi/main/** - - tests/modules/nf-core/rgi/main/** rhocall/annotate: - modules/nf-core/rhocall/annotate/** - tests/modules/nf-core/rhocall/annotate/** diff --git a/tests/modules/nf-core/rgi/main/main.nf b/tests/modules/nf-core/rgi/main/main.nf deleted file mode 100644 index f1cd67fe5cc..00000000000 --- a/tests/modules/nf-core/rgi/main/main.nf +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env nextflow - -nextflow.enable.dsl = 2 - -include { RGI_MAIN } from '../../../../../modules/nf-core/rgi/main/main.nf' - -workflow test_rgi_main { - - input = [ - [ id:'test', single_end:false ], // meta map - file(params.test_data['haemophilus_influenzae']['genome']['genome_fna_gz'], checkIfExists: true) - ] - - RGI_MAIN ( input ) -} diff --git a/tests/modules/nf-core/rgi/main/nextflow.config b/tests/modules/nf-core/rgi/main/nextflow.config deleted file mode 100644 index 50f50a7a357..00000000000 --- a/tests/modules/nf-core/rgi/main/nextflow.config +++ /dev/null @@ -1,5 +0,0 @@ -process { - - publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } - -} \ No newline at end of file diff --git a/tests/modules/nf-core/rgi/main/test.yml b/tests/modules/nf-core/rgi/main/test.yml deleted file mode 100644 index 837d84c7e17..00000000000 --- a/tests/modules/nf-core/rgi/main/test.yml +++ /dev/null @@ -1,40 +0,0 @@ -- name: rgi main test_rgi_main - command: nextflow run ./tests/modules/nf-core/rgi/main -entry test_rgi_main -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/rgi/main/nextflow.config - tags: - - rgi/main - - rgi - files: - - path: output/rgi/temp/genome.fna.gz.temp.uncompressed.fsa - md5sum: f9f0fbb922adaf3968f8edbfbafe0bd8 - - path: output/rgi/temp/genome.fna.gz.temp.uncompressed.fsa.temp.blastRes.rrna.xml - - path: output/rgi/temp/genome.fna.gz.temp.uncompressed.fsa.temp.contig.fsa - md5sum: f1397f3b38e3e6c92bd1cc9109f77418 - - path: output/rgi/temp/genome.fna.gz.temp.uncompressed.fsa.temp.contig.fsa.blastRes.xml - md5sum: 6c89f2c1038c81c0e8d54a4054ed4619 - - path: output/rgi/temp/genome.fna.gz.temp.uncompressed.fsa.temp.contigToORF.fsa - md5sum: 29f63c68bc6921af726a004d308bba9c - - path: output/rgi/temp/genome.fna.gz.temp.uncompressed.fsa.temp.db.nhr - md5sum: fe609718f417ed4fd6fe7c0133e11ee6 - - path: output/rgi/temp/genome.fna.gz.temp.uncompressed.fsa.temp.db.nin - - path: output/rgi/temp/genome.fna.gz.temp.uncompressed.fsa.temp.db.nsq - md5sum: 4d2cb41788a29ed976b61f33648ca865 - - path: output/rgi/temp/genome.fna.gz.temp.uncompressed.fsa.temp.draft - md5sum: 489c853eb2f5378bb601e2d2633f2ca8 - - path: output/rgi/temp/genome.fna.gz.temp.uncompressed.fsa.temp.homolog.json - md5sum: 9afc2bbd09d09355d9af60444a142c9e - - path: output/rgi/temp/genome.fna.gz.temp.uncompressed.fsa.temp.overexpression.json - md5sum: 99914b932bd37a50b983c5e7c90ae93b - - path: output/rgi/temp/genome.fna.gz.temp.uncompressed.fsa.temp.potentialGenes - md5sum: c0036a6de024663abb227b1c9d270433 - - path: output/rgi/temp/genome.fna.gz.temp.uncompressed.fsa.temp.predictedGenes.json - md5sum: 34a72a154d89ff463f86e6e353b602a6 - - path: output/rgi/temp/genome.fna.gz.temp.uncompressed.fsa.temp.predictedGenes.protein.json - md5sum: 1bc75d8e5f5e63e28589bc001c082459 - - path: output/rgi/temp/genome.fna.gz.temp.uncompressed.fsa.temp.rrna.json - md5sum: 99914b932bd37a50b983c5e7c90ae93b - - path: output/rgi/temp/genome.fna.gz.temp.uncompressed.fsa.temp.variant.json - md5sum: d6cf35350328bd51b67d52cdddcba177 - - path: output/rgi/test.json - md5sum: 5a65dd8d206883010e8a5834e7a8121a - - path: output/rgi/test.txt - md5sum: ecee265ab7fcb352890d147dbb2700dc