From 1cbb5551b917aa423e414dcd69898d01520a309d Mon Sep 17 00:00:00 2001 From: Usman Rashid Date: Thu, 25 Apr 2024 19:23:51 +1200 Subject: [PATCH] Added repeatmodeler/builddatabase (#5416) * Added repeatmodeler/builddatabase * Fixed version extraction * Now doing md5 check on stable db files --- .../builddatabase/environment.yml | 9 ++ .../repeatmodeler/builddatabase/main.nf | 50 ++++++++++ .../repeatmodeler/builddatabase/meta.yml | 44 +++++++++ .../builddatabase/tests/main.nf.test | 60 ++++++++++++ .../builddatabase/tests/main.nf.test.snap | 92 +++++++++++++++++++ .../builddatabase/tests/tags.yml | 2 + 6 files changed, 257 insertions(+) create mode 100644 modules/nf-core/repeatmodeler/builddatabase/environment.yml create mode 100644 modules/nf-core/repeatmodeler/builddatabase/main.nf create mode 100644 modules/nf-core/repeatmodeler/builddatabase/meta.yml create mode 100644 modules/nf-core/repeatmodeler/builddatabase/tests/main.nf.test create mode 100644 modules/nf-core/repeatmodeler/builddatabase/tests/main.nf.test.snap create mode 100644 modules/nf-core/repeatmodeler/builddatabase/tests/tags.yml diff --git a/modules/nf-core/repeatmodeler/builddatabase/environment.yml b/modules/nf-core/repeatmodeler/builddatabase/environment.yml new file mode 100644 index 00000000000..ecc282e6854 --- /dev/null +++ b/modules/nf-core/repeatmodeler/builddatabase/environment.yml @@ -0,0 +1,9 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json +name: "repeatmodeler_builddatabase" +channels: + - conda-forge + - bioconda + - defaults +dependencies: + - "bioconda::repeatmodeler=2.0.5" diff --git a/modules/nf-core/repeatmodeler/builddatabase/main.nf b/modules/nf-core/repeatmodeler/builddatabase/main.nf new file mode 100644 index 00000000000..6fe244b2448 --- /dev/null +++ b/modules/nf-core/repeatmodeler/builddatabase/main.nf @@ -0,0 +1,50 @@ +process REPEATMODELER_BUILDDATABASE { + 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/repeatmodeler:2.0.5--pl5321hdfd78af_0': + 'biocontainers/repeatmodeler:2.0.5--pl5321hdfd78af_0' }" + + input: + tuple val(meta), path(fasta) + + output: + tuple val(meta), path("${prefix}.*") , emit: db + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + prefix = task.ext.prefix ?: "${meta.id}" + """ + BuildDatabase \\ + -name $prefix \\ + $fasta + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + repeatmodeler: \$(RepeatModeler --version | sed 's/RepeatModeler version //') + END_VERSIONS + """ + + stub: + prefix = task.ext.prefix ?: "${meta.id}" + """ + touch ${prefix}.nhr + touch ${prefix}.nin + touch ${prefix}.njs + touch ${prefix}.nnd + touch ${prefix}.nni + touch ${prefix}.nog + touch ${prefix}.nsq + touch ${prefix}.translation + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + repeatmodeler: \$(RepeatModeler --version | sed 's/RepeatModeler version //') + END_VERSIONS + """ +} diff --git a/modules/nf-core/repeatmodeler/builddatabase/meta.yml b/modules/nf-core/repeatmodeler/builddatabase/meta.yml new file mode 100644 index 00000000000..d3aa9310fb5 --- /dev/null +++ b/modules/nf-core/repeatmodeler/builddatabase/meta.yml @@ -0,0 +1,44 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json +name: "repeatmodeler_builddatabase" +description: Create a database for RepeatModeler +keywords: + - genomics + - fasta + - repeat +tools: + - "repeatmodeler": + description: "RepeatModeler is a de-novo repeat family identification and modeling package." + homepage: "https://github.com/Dfam-consortium/RepeatModeler" + documentation: "https://github.com/Dfam-consortium/RepeatModeler" + tool_dev_url: "https://github.com/Dfam-consortium/RepeatModeler" + licence: ["Open Software License v2.1"] + +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1' ]` + - fasta: + type: file + description: Fasta file + pattern: "*.{fasta,fsa,fa}" +output: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1' ]` + - db: + type: file + description: Database files for repeatmodeler + pattern: "`${prefix}.*`" + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" +authors: + - "@GallVp" +maintainers: + - "@GallVp" diff --git a/modules/nf-core/repeatmodeler/builddatabase/tests/main.nf.test b/modules/nf-core/repeatmodeler/builddatabase/tests/main.nf.test new file mode 100644 index 00000000000..bfe5d78c2d7 --- /dev/null +++ b/modules/nf-core/repeatmodeler/builddatabase/tests/main.nf.test @@ -0,0 +1,60 @@ +nextflow_process { + + name "Test Process REPEATMODELER_BUILDDATABASE" + script "../main.nf" + process "REPEATMODELER_BUILDDATABASE" + + tag "modules" + tag "modules_nfcore" + tag "repeatmodeler" + tag "repeatmodeler/builddatabase" + + test("sarscov2-genome_fasta") { + + when { + process { + """ + input[0] = [ + [ id:'test' ], // meta map + file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out.versions).match("versions") }, + { assert snapshot(process.out.db[0][1].collect { file(it).name }.sort().toString()).match("db") }, + { assert snapshot(process.out.db[0][1].findAll { ! ( "$it"[-3..-1] in [ 'nin', 'njs' ] ) } ).match("stable_md5") } + ) + } + + } + + test("sarscov2-genome_fasta-stub") { + + options "-stub" + + when { + process { + """ + input[0] = [ + [ id:'test' ], // meta map + file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + + } + +} diff --git a/modules/nf-core/repeatmodeler/builddatabase/tests/main.nf.test.snap b/modules/nf-core/repeatmodeler/builddatabase/tests/main.nf.test.snap new file mode 100644 index 00000000000..1f1a5518717 --- /dev/null +++ b/modules/nf-core/repeatmodeler/builddatabase/tests/main.nf.test.snap @@ -0,0 +1,92 @@ +{ + "sarscov2-genome_fasta-stub": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + [ + "test.nhr:md5,d41d8cd98f00b204e9800998ecf8427e", + "test.nin:md5,d41d8cd98f00b204e9800998ecf8427e", + "test.njs:md5,d41d8cd98f00b204e9800998ecf8427e", + "test.nnd:md5,d41d8cd98f00b204e9800998ecf8427e", + "test.nni:md5,d41d8cd98f00b204e9800998ecf8427e", + "test.nog:md5,d41d8cd98f00b204e9800998ecf8427e", + "test.nsq:md5,d41d8cd98f00b204e9800998ecf8427e", + "test.translation:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ] + ], + "1": [ + "versions.yml:md5,7944637266bc3e2726899eaad5e46c87" + ], + "db": [ + [ + { + "id": "test" + }, + [ + "test.nhr:md5,d41d8cd98f00b204e9800998ecf8427e", + "test.nin:md5,d41d8cd98f00b204e9800998ecf8427e", + "test.njs:md5,d41d8cd98f00b204e9800998ecf8427e", + "test.nnd:md5,d41d8cd98f00b204e9800998ecf8427e", + "test.nni:md5,d41d8cd98f00b204e9800998ecf8427e", + "test.nog:md5,d41d8cd98f00b204e9800998ecf8427e", + "test.nsq:md5,d41d8cd98f00b204e9800998ecf8427e", + "test.translation:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ] + ], + "versions": [ + "versions.yml:md5,7944637266bc3e2726899eaad5e46c87" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-04-02T12:06:44.261566" + }, + "versions": { + "content": [ + [ + "versions.yml:md5,7944637266bc3e2726899eaad5e46c87" + ] + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-01-09T15:14:48.807063" + }, + "stable_md5": { + "content": [ + [ + "test.nhr:md5,1a41cb6d0b00c28f62ad60e75ae2f6fc", + "test.nnd:md5,2002e13acf59079a1a5782c918894579", + "test.nni:md5,26a954ba0fd80983b550d8f6b8b35ff8", + "test.nog:md5,30896f123998e926ea2237b89091e7fe", + "test.nsq:md5,982cbc7d9e38743b9b1037588862b9da", + "test.translation:md5,ccbb119522c09daa976a9015ba999329" + ] + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-04-23T10:03:41.669433" + }, + "db": { + "content": [ + "[test.nhr, test.nin, test.njs, test.nnd, test.nni, test.nog, test.nsq, test.translation]" + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-04-02T12:08:36.94713" + } +} \ No newline at end of file diff --git a/modules/nf-core/repeatmodeler/builddatabase/tests/tags.yml b/modules/nf-core/repeatmodeler/builddatabase/tests/tags.yml new file mode 100644 index 00000000000..c524294ce95 --- /dev/null +++ b/modules/nf-core/repeatmodeler/builddatabase/tests/tags.yml @@ -0,0 +1,2 @@ +repeatmodeler/builddatabase: + - "modules/nf-core/repeatmodeler/builddatabase/**"