From f1903494a34a90d38c328fa82ead36d1265b552c Mon Sep 17 00:00:00 2001 From: Andrea Telatin <15690844+telatin@users.noreply.github.com> Date: Wed, 20 May 2026 11:42:39 +0200 Subject: [PATCH] add anvi-gen-contigs-database module --- .../anvi-gen-contigs-database/environment.yml | 7 ++ .../anvio/anvi-gen-contigs-database/main.nf | 39 ++++++++++ .../anvio/anvi-gen-contigs-database/meta.yml | 77 +++++++++++++++++++ .../tests/main.nf.test | 67 ++++++++++++++++ .../tests/main.nf.test.snap | 59 ++++++++++++++ .../tests/nextflow.config | 5 ++ 6 files changed, 254 insertions(+) create mode 100644 modules/nf-core/anvio/anvi-gen-contigs-database/environment.yml create mode 100644 modules/nf-core/anvio/anvi-gen-contigs-database/main.nf create mode 100644 modules/nf-core/anvio/anvi-gen-contigs-database/meta.yml create mode 100644 modules/nf-core/anvio/anvi-gen-contigs-database/tests/main.nf.test create mode 100644 modules/nf-core/anvio/anvi-gen-contigs-database/tests/main.nf.test.snap create mode 100644 modules/nf-core/anvio/anvi-gen-contigs-database/tests/nextflow.config diff --git a/modules/nf-core/anvio/anvi-gen-contigs-database/environment.yml b/modules/nf-core/anvio/anvi-gen-contigs-database/environment.yml new file mode 100644 index 000000000000..6cc7db3e69a4 --- /dev/null +++ b/modules/nf-core/anvio/anvi-gen-contigs-database/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::anvio-minimal=9 diff --git a/modules/nf-core/anvio/anvi-gen-contigs-database/main.nf b/modules/nf-core/anvio/anvi-gen-contigs-database/main.nf new file mode 100644 index 000000000000..b26ce5ecbe41 --- /dev/null +++ b/modules/nf-core/anvio/anvi-gen-contigs-database/main.nf @@ -0,0 +1,39 @@ +process ANVIO_ANVI_GEN_CONTIGS_DATABASE { + 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/anvio-minimal:9--pyhdfd78af_0': + 'quay.io/biocontainers/anvio-minimal:9--pyhdfd78af_0' }" + + input: + tuple val(meta), path(fasta), path(external_gene_calls) + + output: + tuple val(meta), path("*.CONTIGS.db"), emit: contigs_db + tuple val("${task.process}"), val('anvio'), eval("anvi-gen-contigs-database --version 2>&1 | head -n 1 | cut -f 2 -d : | cut -c 2- | sed 's/.*(v//; s/).*//'"), emit: versions_anvio, topic: versions + + when: + task.ext.when == null || task.ext.when + + script: + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + def external_gene_calls_arg = external_gene_calls ? "--external-gene-calls ${external_gene_calls}" : '' + """ + anvi-gen-contigs-database \\ + $args \\ + --num-threads $task.cpus \\ + --contigs-fasta $fasta \\ + --project-name "$prefix" \\ + --output-db-path ${prefix}.CONTIGS.db \\ + $external_gene_calls_arg + """ + + stub: + def prefix = task.ext.prefix ?: "${meta.id}" + """ + touch ${prefix}.CONTIGS.db + """ +} diff --git a/modules/nf-core/anvio/anvi-gen-contigs-database/meta.yml b/modules/nf-core/anvio/anvi-gen-contigs-database/meta.yml new file mode 100644 index 000000000000..77229ba164c2 --- /dev/null +++ b/modules/nf-core/anvio/anvi-gen-contigs-database/meta.yml @@ -0,0 +1,77 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json +name: "anvio_anvi_gen_contigs_database" +description: Generate an anvi'o contigs database from FASTA sequences. +keywords: + - anvio + - contigs + - database + - metagenomics + - fasta +tools: + - "anvio": + description: "Anvi'o is an analysis and visualization platform for 'omics data." + homepage: "https://merenlab.org/software/anvio/" + documentation: "https://anvio.org/help/9/programs/anvi-gen-contigs-database/" + tool_dev_url: "https://github.com/merenlab/anvio" + doi: "10.1038/s41564-020-00834-3" + licence: + - "GPL-3.0-or-later" + identifier: biotools:anvio +input: + - - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1', single_end:false ]` + - fasta: + type: file + description: FASTA file containing contigs or genome sequences. + pattern: "*.{fa,fasta,fna,fa.gz,fasta.gz,fna.gz}" + ontologies: + - edam: http://edamontology.org/format_1929 # FASTA + - external_gene_calls: + type: file + optional: true + description: Optional TAB-delimited external gene calls file for anvi'o. + pattern: "*.{txt,tsv}" + ontologies: + - edam: http://edamontology.org/format_3475 # TSV +output: + contigs_db: + - - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1', single_end:false ]` + - "*.CONTIGS.db": + type: file + description: Anvi'o contigs database. + pattern: "*.CONTIGS.db" + ontologies: + - edam: http://edamontology.org/format_3621 # SQLite format + versions_anvio: + - - "${task.process}": + type: string + description: The name of the process + - anvio: + type: string + description: The name of the tool + - "anvi-gen-contigs-database --version 2>&1 | head -n 1 | cut -f 2 -d : | cut -c 2- | sed 's/.*(v//; s/).*//'": + type: eval + description: The expression to obtain the version of the tool +topics: + versions: + - - "${task.process}": + type: string + description: The name of the process + - anvio: + type: string + description: The name of the tool + - "anvi-gen-contigs-database --version 2>&1 | head -n 1 | cut -f 2 -d : | cut -c 2- | sed 's/.*(v//; s/).*//'": + type: eval + description: The expression to obtain the version of the tool +authors: + - "@telatin" +maintainers: + - "@telatin" diff --git a/modules/nf-core/anvio/anvi-gen-contigs-database/tests/main.nf.test b/modules/nf-core/anvio/anvi-gen-contigs-database/tests/main.nf.test new file mode 100644 index 000000000000..dbad036ff1b2 --- /dev/null +++ b/modules/nf-core/anvio/anvi-gen-contigs-database/tests/main.nf.test @@ -0,0 +1,67 @@ +nextflow_process { + + name "Test Process ANVIO_ANVI_GEN_CONTIGS_DATABASE" + script "../main.nf" + process "ANVIO_ANVI_GEN_CONTIGS_DATABASE" + config "./nextflow.config" + + tag "modules" + tag "modules_nfcore" + tag "anvio" + tag "anvio/anvi-gen-contigs-database" + + test("anvi-gen-contigs-database - synthetic fasta") { + + when { + process { + """ + input[0] = Channel.of( + ">contig_1", + "ACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGT", + "ACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGT", + ">contig_2", + "TTGCAAGCTTGCAAGCTTGCAAGCTTGCAAGCTTGCAAGCTTGCAAGCTTGCAAGC", + "TTGCAAGCTTGCAAGCTTGCAAGCTTGCAAGCTTGCAAGCTTGCAAGCTTGCAAGC" + ) + .collectFile(name: "contigs.fa", newLine: true, sort: false) + .map { fasta -> [ [ id:'test' ], fasta, [] ] } + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert process.out.contigs_db.size() == 1 }, + { assert file(process.out.contigs_db[0][1]).name == "test.CONTIGS.db" }, + { assert file(process.out.contigs_db[0][1]).length() > 0 }, + { assert snapshot(process.out.versions_anvio).match("versions") } + ) + } + } + + test("anvi-gen-contigs-database - stub") { + + options "-stub" + + when { + process { + """ + input[0] = Channel.of( + ">contig_1", + "ACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGT" + ) + .collectFile(name: "contigs.fa", newLine: true, sort: false) + .map { fasta -> [ [ id:'test' ], fasta, [] ] } + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } +} diff --git a/modules/nf-core/anvio/anvi-gen-contigs-database/tests/main.nf.test.snap b/modules/nf-core/anvio/anvi-gen-contigs-database/tests/main.nf.test.snap new file mode 100644 index 000000000000..7b07adfeaab0 --- /dev/null +++ b/modules/nf-core/anvio/anvi-gen-contigs-database/tests/main.nf.test.snap @@ -0,0 +1,59 @@ +{ + "versions": { + "content": [ + [ + [ + "ANVIO_ANVI_GEN_CONTIGS_DATABASE", + "anvio", + "9" + ] + ] + ], + "timestamp": "2026-05-20T10:37:17.429792", + "meta": { + "nf-test": "0.9.4", + "nextflow": "25.10.4" + } + }, + "anvi-gen-contigs-database - stub": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test.CONTIGS.db:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + [ + "ANVIO_ANVI_GEN_CONTIGS_DATABASE", + "anvio", + "9" + ] + ], + "contigs_db": [ + [ + { + "id": "test" + }, + "test.CONTIGS.db:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions_anvio": [ + [ + "ANVIO_ANVI_GEN_CONTIGS_DATABASE", + "anvio", + "9" + ] + ] + } + ], + "timestamp": "2026-05-20T10:37:28.314211", + "meta": { + "nf-test": "0.9.4", + "nextflow": "25.10.4" + } + } +} diff --git a/modules/nf-core/anvio/anvi-gen-contigs-database/tests/nextflow.config b/modules/nf-core/anvio/anvi-gen-contigs-database/tests/nextflow.config new file mode 100644 index 000000000000..e2dda1afeb73 --- /dev/null +++ b/modules/nf-core/anvio/anvi-gen-contigs-database/tests/nextflow.config @@ -0,0 +1,5 @@ +process { + withName: 'ANVIO_ANVI_GEN_CONTIGS_DATABASE' { + ext.args = '--skip-gene-calling' + } +}