diff --git a/modules/nf-core/rgi/bwt/environment.yml b/modules/nf-core/rgi/bwt/environment.yml new file mode 100644 index 00000000000..b6b2d343815 --- /dev/null +++ b/modules/nf-core/rgi/bwt/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::rgi=6.0.5 diff --git a/modules/nf-core/rgi/bwt/main.nf b/modules/nf-core/rgi/bwt/main.nf new file mode 100644 index 00000000000..a69f3a08973 --- /dev/null +++ b/modules/nf-core/rgi/bwt/main.nf @@ -0,0 +1,82 @@ +process RGI_BWT { + tag "${meta.id}" + 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.5--pyh05cac1d_0' + : 'biocontainers/rgi:6.0.5--pyh05cac1d_0'}" + + input: + tuple val(meta), path(reads, arity: '1..2') + 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 + tuple val("${task.process}"), val('rgi') , eval("rgi main --version"), emit: versions_rgi, topic: versions + tuple val("${task.process}"), val('rgi-database'), eval("echo \\$DB_VERSION"), emit: versions_db , topic: versions + + when: + task.ext.when == null || task.ext.when + + script: + // This customizes the command: rgi load + def args = task.ext.args ?: '' + // This customizes the command: rgi main + def args2 = task.ext.args2 ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + def read_one = reads[0] + def read_two = reads.size() > 1 ? reads[1] : null + 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 \\ + load \\ + ${args} \\ + --local \\ + --card_json ${card}/card.json \\ + --debug \\ + --card_annotation ${card}/card_database_v\$DB_VERSION.fasta \\ + --card_annotation_all_models ${card}/card_database_v\$DB_VERSION\\_all.fasta \\ + ${load_wildcard} + + rgi \\ + bwt \\ + ${args} \\ + --local \\ + --threads ${task.cpus} \\ + --output_file ${prefix} \\ + --read_one ${read_one} \\ + ${ read_two ? "--read_two ${read_two}" : "" } + + + mkdir temp/ + for FILE in *.xml *.fsa *.{nhr,nin,nsq} *.draft *.potentialGenes *{variant,rrna,protein,predictedGenes,overexpression,homolog}.json; do [[ -e \$FILE ]] && mv \$FILE temp/; done + + """ + + stub: + """ + mkdir -p temp + touch test.json + touch test.txt + + DB_VERSION=stub_version + """ +} diff --git a/modules/nf-core/rgi/bwt/meta.yml b/modules/nf-core/rgi/bwt/meta.yml new file mode 100644 index 00000000000..a29a5c3f838 --- /dev/null +++ b/modules/nf-core/rgi/bwt/meta.yml @@ -0,0 +1,126 @@ +name: rgi_bwt +description: Predict antibiotic resistance from protein or nucleotide data +keywords: + - bacteria + - fasta + - antibiotic resistance +tools: + - rgi: + description: This tool provides a preliminary annotation of your DNA + sequence(s) based upon the data available in The Comprehensive Antibiotic + Resistance Database (CARD). Hits to genes tagged with Antibiotic + Resistance ontology terms will be highlighted. As CARD expands to include + more pathogens, genomes, plasmids, and ontology terms this tool will grow + increasingly powerful in providing first-pass detection of antibiotic + resistance associated genes. See license at CARD website. + 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"] + identifier: "" +input: + - - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - reads: + type: file + description: Single-end or paired-end nucleotide sequences in FASTQ or FASTA format + pattern: "*.{fastq,fastq.gz,fq,fq.gz,fasta,fasta.gz,fa,fa.gz,fna,fna.gz,faa,faa.gz}" + ontologies: + - edam: http://edamontology.org/format_1930 # FASTQ + - 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: + json: + - - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - "*.json": + type: file + description: JSON formatted file with RGI results + pattern: "*.{json}" + ontologies: + - edam: http://edamontology.org/format_3464 # JSON + tsv: + - - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - "*.txt": + type: file + description: Tab-delimited file with RGI results + pattern: "*.{txt}" + ontologies: [] + tmp: + - - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - temp/: + type: directory + description: Directory containing various intermediate files + pattern: "temp/" + versions_rgi: + - - ${task.process}: + type: string + description: The process the versions were collected from + - rgi: + type: string + description: The tool name + - rgi main --version: + type: string + description: The version string returned by the command + versions_db: + - - ${task.process}: + type: string + description: The process the versions were collected from + - rgi-database: + type: string + description: The tool name + - echo \$DB_VERSION: + type: string + description: The CARD database version string + +topics: + versions: + - - ${task.process}: + type: string + description: The process the versions were collected from + - rgi: + type: string + description: The tool name + - rgi main --version: + type: string + description: Command used to collect the version + - - ${task.process}: + type: string + description: The process the versions were collected from + - rgi-database: + type: string + description: The tool name + - echo \$DB_VERSION: + type: string + description: Command used to collect the version + +authors: + - "@vinisalazar" +maintainers: + - "@nickp60" + - "@vinisalazar" diff --git a/modules/nf-core/rgi/bwt/tests/main.nf.test b/modules/nf-core/rgi/bwt/tests/main.nf.test new file mode 100644 index 00000000000..40074303c71 --- /dev/null +++ b/modules/nf-core/rgi/bwt/tests/main.nf.test @@ -0,0 +1,95 @@ +nextflow_process { + + name "Test Process RGI_BWT" + script "../main.nf" + process "RGI_BWT" + + tag "modules" + tag "modules_nfcore" + tag "rgi" + tag "rgi/bwt" + 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('card-data.tar.bz2') + + input[0] = [ + [ ], + file("card-data.tar.bz2") + ] + """ + } + } + + run("RGI_CARDANNOTATION") { + script "modules/nf-core/rgi/cardannotation" + process { + """ + input[0] = UNTAR.out.untar.map{ it[1] } + """ + } + } + } + + test("rgi/bwt - homo_sapiens - test_fastq_gz") { + + when { + process { + """ + input[0] = [ + [ id:'test', single_end:false ], // meta map + [ + file(params.test_data['homo_sapiens']['illumina']['test_1_fastq_gz'], checkIfExists: true), + file(params.test_data['homo_sapiens']['illumina']['test_2_fastq_gz'], checkIfExists: true), + ] + ] + input[1] = RGI_CARDANNOTATION.out.db + input[2] = [] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot( + process.out.findAll { key, val -> key.startsWith("versions") }, + file(process.out.tmp.get(0).get(1)).list().sort(), + ).match() } + ) + } + } + + test("rgi/bwt - homo_sapiens - test_fastq_gz - stub") { + + options "-stub" + + when { + process { + """ + input[0] = [ + [ id:'test', single_end:false ], // meta map + [ + file(params.test_data['homo_sapiens']['illumina']['test_1_fastq_gz'], checkIfExists: true), + file(params.test_data['homo_sapiens']['illumina']['test_2_fastq_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/bwt/tests/main.nf.test.snap b/modules/nf-core/rgi/bwt/tests/main.nf.test.snap new file mode 100644 index 00000000000..91124f320ec --- /dev/null +++ b/modules/nf-core/rgi/bwt/tests/main.nf.test.snap @@ -0,0 +1,127 @@ +{ + "rgi/bwt - homo_sapiens - test_fastq_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": [ + [ + "RGI_BWT", + "rgi", + "6.0.5" + ] + ], + "4": [ + [ + "RGI_BWT", + "rgi-database", + "stub_version" + ] + ], + "json": [ + [ + { + "id": "test", + "single_end": false + }, + "test.json:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "tmp": [ + [ + { + "id": "test", + "single_end": false + }, + [ + + ] + ] + ], + "tsv": [ + [ + { + "id": "test", + "single_end": false + }, + "test.txt:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions_db": [ + [ + "RGI_BWT", + "rgi-database", + "stub_version" + ] + ], + "versions_rgi": [ + [ + "RGI_BWT", + "rgi", + "6.0.5" + ] + ] + } + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "25.04.6" + }, + "timestamp": "2026-01-20T14:01:51.787935" + }, + "rgi/bwt - homo_sapiens - test_fastq_gz": { + "content": [ + { + "versions_db": [ + [ + "RGI_BWT", + "rgi-database", + "4.0.1" + ] + ], + "versions_rgi": [ + [ + "RGI_BWT", + "rgi", + "6.0.5" + ] + ] + }, + [ + "test.temp.sam.temp.fsa" + ] + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "25.04.6" + }, + "timestamp": "2026-01-20T14:01:20.471757" + } +} \ No newline at end of file