From 66e5236a4a8a8c7443b7a4016ada6f5ac0cfc685 Mon Sep 17 00:00:00 2001 From: MartinPippel Date: Mon, 15 Jan 2024 10:46:39 +0100 Subject: [PATCH 1/3] update nf-core module blast/makeblastdb --- modules.json | 95 ++++++++----------- .../blast/makeblastdb/blast-makeblastdb.diff | 20 ---- .../nf-core/blast/makeblastdb/environment.yml | 7 ++ modules/nf-core/blast/makeblastdb/main.nf | 52 ++++++++-- modules/nf-core/blast/makeblastdb/meta.yml | 16 +++- .../blast/makeblastdb/tests/main.nf.test | 92 ++++++++++++++++++ .../blast/makeblastdb/tests/main.nf.test.snap | 86 +++++++++++++++++ .../blast/makeblastdb/tests/nextflow.config | 5 + .../nf-core/blast/makeblastdb/tests/tags.yml | 2 + 9 files changed, 290 insertions(+), 85 deletions(-) delete mode 100644 modules/nf-core/blast/makeblastdb/blast-makeblastdb.diff create mode 100644 modules/nf-core/blast/makeblastdb/environment.yml create mode 100644 modules/nf-core/blast/makeblastdb/tests/main.nf.test create mode 100644 modules/nf-core/blast/makeblastdb/tests/main.nf.test.snap create mode 100644 modules/nf-core/blast/makeblastdb/tests/nextflow.config create mode 100644 modules/nf-core/blast/makeblastdb/tests/tags.yml diff --git a/modules.json b/modules.json index 4db56fb3..4caf7cd7 100644 --- a/modules.json +++ b/modules.json @@ -1,58 +1,45 @@ { - "name": "NBIS Genome Annotation Workflow", - "homePage": "", - "repos": { - "https://github.com/nf-core/modules.git": { - "modules": { - "nf-core": { - "blast/makeblastdb": { - "branch": "master", - "git_sha": "911696ea0b62df80e900ef244d7867d177971f73", - "installed_by": [ - "modules" - ], - "patch": "modules/nf-core/blast/makeblastdb/blast-makeblastdb.diff" - }, - "busco": { - "branch": "master", - "git_sha": "6d6552cb582f56b6101c452e16ee7c23073f91de", - "installed_by": [ - "modules" - ] - }, - "fastp": { - "branch": "master", - "git_sha": "d497a4868ace3302016ea8ed4b395072d5e833cd", - "installed_by": [ - "modules" - ] - }, - "fastqc": { - "branch": "master", - "git_sha": "9a4517e720bc812e95b56d23d15a1653b6db4f53", - "installed_by": [ - "modules" - ] - }, - "interproscan": { - "branch": "master", - "git_sha": "3f5420aa22e00bd030a2556dfdffc9e164ec0ec5", - "installed_by": [ - "modules" - ] - }, - "multiqc": { - "branch": "master", - "git_sha": "a6e11ac655e744f7ebc724be669dd568ffdc0e80", - "installed_by": [ - "modules" - ] - } - } - }, - "subworkflows": { - "nf-core": {} - } + "name": "NBIS Genome Annotation Workflow", + "homePage": "", + "repos": { + "https://github.com/nf-core/modules.git": { + "modules": { + "nf-core": { + "blast/makeblastdb": { + "branch": "master", + "git_sha": "3f5420aa22e00bd030a2556dfdffc9e164ec0ec5", + "installed_by": ["modules"] + }, + "busco": { + "branch": "master", + "git_sha": "6d6552cb582f56b6101c452e16ee7c23073f91de", + "installed_by": ["modules"] + }, + "fastp": { + "branch": "master", + "git_sha": "d497a4868ace3302016ea8ed4b395072d5e833cd", + "installed_by": ["modules"] + }, + "fastqc": { + "branch": "master", + "git_sha": "9a4517e720bc812e95b56d23d15a1653b6db4f53", + "installed_by": ["modules"] + }, + "interproscan": { + "branch": "master", + "git_sha": "3f5420aa22e00bd030a2556dfdffc9e164ec0ec5", + "installed_by": ["modules"] + }, + "multiqc": { + "branch": "master", + "git_sha": "a6e11ac655e744f7ebc724be669dd568ffdc0e80", + "installed_by": ["modules"] + } } + }, + "subworkflows": { + "nf-core": {} + } } + } } diff --git a/modules/nf-core/blast/makeblastdb/blast-makeblastdb.diff b/modules/nf-core/blast/makeblastdb/blast-makeblastdb.diff deleted file mode 100644 index daacf209..00000000 --- a/modules/nf-core/blast/makeblastdb/blast-makeblastdb.diff +++ /dev/null @@ -1,20 +0,0 @@ -Changes in module 'nf-core/blast/makeblastdb' ---- modules/nf-core/blast/makeblastdb/main.nf -+++ modules/nf-core/blast/makeblastdb/main.nf -@@ -8,11 +8,11 @@ - 'biocontainers/blast:2.13.0--hf3cf87c_0' }" - - input: -- path fasta -+ tuple val(meta), path(fasta) - - output: -- path 'blast_db' , emit: db -- path "versions.yml" , emit: versions -+ tuple val(meta), path('blast_db'), emit: db -+ path "versions.yml" , emit: versions - - when: - task.ext.when == null || task.ext.when - -************************************************************ diff --git a/modules/nf-core/blast/makeblastdb/environment.yml b/modules/nf-core/blast/makeblastdb/environment.yml new file mode 100644 index 00000000..cf84a60e --- /dev/null +++ b/modules/nf-core/blast/makeblastdb/environment.yml @@ -0,0 +1,7 @@ +name: blast_makeblastdb +channels: + - conda-forge + - bioconda + - defaults +dependencies: + - bioconda::blast=2.14.1 diff --git a/modules/nf-core/blast/makeblastdb/main.nf b/modules/nf-core/blast/makeblastdb/main.nf index 93f88512..cd1083d0 100644 --- a/modules/nf-core/blast/makeblastdb/main.nf +++ b/modules/nf-core/blast/makeblastdb/main.nf @@ -1,30 +1,62 @@ process BLAST_MAKEBLASTDB { - tag "$fasta" + tag "$meta.id" label 'process_medium' - conda "bioconda::blast=2.13.0" + conda "${moduleDir}/environment.yml" container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? - 'https://depot.galaxyproject.org/singularity/blast:2.13.0--hf3cf87c_0' : - 'biocontainers/blast:2.13.0--hf3cf87c_0' }" + 'https://depot.galaxyproject.org/singularity/blast:2.14.1--pl5321h6f7f691_0': + 'biocontainers/blast:2.14.1--pl5321h6f7f691_0' }" input: tuple val(meta), path(fasta) output: - tuple val(meta), path('blast_db'), emit: db - path "versions.yml" , emit: versions + tuple val(meta), path("${meta.id}"), emit: db + 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}" + def is_compressed = fasta.getExtension() == "gz" ? true : false + def fasta_name = is_compressed ? fasta.getBaseName() : fasta """ + if [ "${is_compressed}" == "true" ]; then + gzip -c -d ${fasta} > ${fasta_name} + fi + makeblastdb \\ - -in $fasta \\ - $args - mkdir blast_db - mv ${fasta}* blast_db + -in ${fasta_name} \\ + ${args} + mkdir ${prefix} + mv ${fasta_name}* ${prefix} + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + blast: \$(blastn -version 2>&1 | sed 's/^.*blastn: //; s/ .*\$//') + END_VERSIONS + """ + + stub: + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + def is_compressed = fasta.getExtension() == "gz" ? true : false + def fasta_name = is_compressed ? fasta.getBaseName() : fasta + """ + touch ${fasta_name}.fasta + touch ${fasta_name}.fasta.ndb + touch ${fasta_name}.fasta.nhr + touch ${fasta_name}.fasta.nin + touch ${fasta_name}.fasta.njs + touch ${fasta_name}.fasta.not + touch ${fasta_name}.fasta.nsq + touch ${fasta_name}.fasta.ntf + touch ${fasta_name}.fasta.nto + mkdir ${prefix} + mv ${fasta_name}* ${prefix} + cat <<-END_VERSIONS > versions.yml "${task.process}": blast: \$(blastn -version 2>&1 | sed 's/^.*blastn: //; s/ .*\$//') diff --git a/modules/nf-core/blast/makeblastdb/meta.yml b/modules/nf-core/blast/makeblastdb/meta.yml index 83c4b292..9ed63901 100644 --- a/modules/nf-core/blast/makeblastdb/meta.yml +++ b/modules/nf-core/blast/makeblastdb/meta.yml @@ -13,11 +13,21 @@ tools: doi: 10.1016/S0022-2836(05)80360-2 licence: ["US-Government-Work"] input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] - fasta: type: file description: Input fasta file - pattern: "*.{fa,fasta}" + pattern: "*.{fa,fasta,fa.gz,fasta.gz}" output: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] - db: type: directory description: Output directory containing blast database files @@ -29,3 +39,7 @@ output: authors: - "@joseespinosa" - "@drpatelh" +maintainers: + - "@joseespinosa" + - "@drpatelh" + - "@vagkaratzas" diff --git a/modules/nf-core/blast/makeblastdb/tests/main.nf.test b/modules/nf-core/blast/makeblastdb/tests/main.nf.test new file mode 100644 index 00000000..983b165f --- /dev/null +++ b/modules/nf-core/blast/makeblastdb/tests/main.nf.test @@ -0,0 +1,92 @@ +nextflow_process { + + name "Test Process BLAST_MAKEBLASTDB" + script "../main.nf" + process "BLAST_MAKEBLASTDB" + config "./nextflow.config" + tag "modules" + tag "modules_nfcore" + tag "blast" + tag "blast/makeblastdb" + + test("Should build a blast db folder from a fasta file") { + + when { + params { + outdir = "$outputDir" + } + process { + """ + input[0] = [ [id:'test'], file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert process.out.db + with(process.out.db) { + assert size() == 1 + with(get(0).get(1)) { + File folder = new File(get(0).get(1)) + File[] listOfFiles = folder.listFiles() + listOfFiles = listOfFiles.sort { it.name } + assert listOfFiles.length == 9 + assert snapshot("${get(0).get(1)}/${listOfFiles[0].name}").match("genome.fasta") + assert snapshot("${get(0).get(1)}/${listOfFiles[1].name}").match("genome.fasta.ndb") + assert snapshot("${get(0).get(1)}/${listOfFiles[2].name}").match("genome.fasta.nhr") + assert snapshot("${get(0).get(1)}/${listOfFiles[5].name}").match("genome.fasta.not") + assert snapshot("${get(0).get(1)}/${listOfFiles[6].name}").match("genome.fasta.nsq") + assert snapshot("${get(0).get(1)}/${listOfFiles[7].name}").match("genome.fasta.ntf") + assert snapshot("${get(0).get(1)}/${listOfFiles[8].name}").match("genome.fasta.nto") + } + } + }, + { assert process.out.versions } + ) + } + + } + + test("Should build a blast db folder from a zipped fasta file") { + + when { + params { + outdir = "$outputDir" + } + process { + """ + input[0] = [ [id:'test'], file(params.test_data['sarscov2']['genome']['genome_fasta_gz'], checkIfExists: true) ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert process.out.db + with(process.out.db) { + assert size() == 1 + with(get(0).get(1)) { + File folder = new File(get(0).get(1)) + File[] listOfFiles = folder.listFiles() + listOfFiles = listOfFiles.sort { it.name } + assert listOfFiles.length == 10 + assert snapshot("${get(0).get(1)}/${listOfFiles[0].name}").match("gz_genome.fasta") + assert snapshot("${get(0).get(1)}/${listOfFiles[2].name}").match("gz_genome.fasta.ndb") + assert snapshot("${get(0).get(1)}/${listOfFiles[3].name}").match("gz_genome.fasta.nhr") + assert snapshot("${get(0).get(1)}/${listOfFiles[6].name}").match("gz_genome.fasta.not") + assert snapshot("${get(0).get(1)}/${listOfFiles[7].name}").match("gz_genome.fasta.nsq") + assert snapshot("${get(0).get(1)}/${listOfFiles[8].name}").match("gz_genome.fasta.ntf") + assert snapshot("${get(0).get(1)}/${listOfFiles[9].name}").match("gz_genome.fasta.nto") + } + } + }, + { assert process.out.versions } + ) + } + + } + +} diff --git a/modules/nf-core/blast/makeblastdb/tests/main.nf.test.snap b/modules/nf-core/blast/makeblastdb/tests/main.nf.test.snap new file mode 100644 index 00000000..b6f040ed --- /dev/null +++ b/modules/nf-core/blast/makeblastdb/tests/main.nf.test.snap @@ -0,0 +1,86 @@ +{ + "genome.fasta": { + "content": [ + "genome.fasta:md5,6e9fe4042a72f2345f644f239272b7e6" + ], + "timestamp": "2023-11-07T12:52:38.457245596" + }, + "gz_genome.fasta.ntf": { + "content": [ + "genome.fasta.ntf:md5,de1250813f0c7affc6d12dac9d0fb6bb" + ], + "timestamp": "2023-11-07T12:58:02.121840034" + }, + "genome.fasta.not": { + "content": [ + "genome.fasta.not:md5,1e53e9d08f1d23af0299cfa87478a7bb" + ], + "timestamp": "2023-11-07T12:55:33.862012946" + }, + "genome.fasta.nhr": { + "content": [ + "genome.fasta.nhr:md5,f4b4ddb034fd3dd7b25c89e9d50c004e" + ], + "timestamp": "2023-11-07T12:55:33.857994517" + }, + "gz_genome.fasta.nhr": { + "content": [ + "genome.fasta.nhr:md5,f4b4ddb034fd3dd7b25c89e9d50c004e" + ], + "timestamp": "2023-11-07T12:58:02.102407993" + }, + "genome.fasta.ntf": { + "content": [ + "genome.fasta.ntf:md5,de1250813f0c7affc6d12dac9d0fb6bb" + ], + "timestamp": "2023-11-07T12:55:33.877288786" + }, + "gz_genome.fasta.not": { + "content": [ + "genome.fasta.not:md5,1e53e9d08f1d23af0299cfa87478a7bb" + ], + "timestamp": "2023-11-07T12:58:02.108135313" + }, + "gz_genome.fasta.ndb": { + "content": [ + "genome.fasta.ndb:md5,0d553c830656469211de113c5022f06d" + ], + "timestamp": "2023-11-07T12:58:02.094305556" + }, + "gz_genome.fasta.nsq": { + "content": [ + "genome.fasta.nsq:md5,982cbc7d9e38743b9b1037588862b9da" + ], + "timestamp": "2023-11-07T12:58:02.115010863" + }, + "genome.fasta.nto": { + "content": [ + "genome.fasta.nto:md5,33cdeccccebe80329f1fdbee7f5874cb" + ], + "timestamp": "2023-11-07T12:55:33.890761822" + }, + "gz_genome.fasta.nto": { + "content": [ + "genome.fasta.nto:md5,33cdeccccebe80329f1fdbee7f5874cb" + ], + "timestamp": "2023-11-07T12:58:02.12931429" + }, + "genome.fasta.ndb": { + "content": [ + "genome.fasta.ndb:md5,0d553c830656469211de113c5022f06d" + ], + "timestamp": "2023-11-07T12:55:33.853303997" + }, + "genome.fasta.nsq": { + "content": [ + "genome.fasta.nsq:md5,982cbc7d9e38743b9b1037588862b9da" + ], + "timestamp": "2023-11-07T12:55:33.866667927" + }, + "gz_genome.fasta": { + "content": [ + "genome.fasta:md5,6e9fe4042a72f2345f644f239272b7e6" + ], + "timestamp": "2023-11-07T12:58:02.081764854" + } +} \ No newline at end of file diff --git a/modules/nf-core/blast/makeblastdb/tests/nextflow.config b/modules/nf-core/blast/makeblastdb/tests/nextflow.config new file mode 100644 index 00000000..0899289b --- /dev/null +++ b/modules/nf-core/blast/makeblastdb/tests/nextflow.config @@ -0,0 +1,5 @@ +process { + withName: BLAST_MAKEBLASTDB { + ext.args = '-dbtype nucl' + } +} diff --git a/modules/nf-core/blast/makeblastdb/tests/tags.yml b/modules/nf-core/blast/makeblastdb/tests/tags.yml new file mode 100644 index 00000000..ab74c02a --- /dev/null +++ b/modules/nf-core/blast/makeblastdb/tests/tags.yml @@ -0,0 +1,2 @@ +blast/makeblastdb: + - modules/nf-core/blast/makeblastdb/** From 6911fea467d6098536f6c53c4b95a7c984fa0268 Mon Sep 17 00:00:00 2001 From: MartinPippel Date: Mon, 15 Jan 2024 13:01:27 +0100 Subject: [PATCH 2/3] update local blast version --- modules/local/blast/blastp.nf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/local/blast/blastp.nf b/modules/local/blast/blastp.nf index e4bf1127..de43bb44 100644 --- a/modules/local/blast/blastp.nf +++ b/modules/local/blast/blastp.nf @@ -2,10 +2,10 @@ process BLAST_BLASTP { tag "${fasta.baseName}" label 'process_medium' - conda 'bioconda::blast=2.12.0' + conda 'bioconda::blast=2.15.0' container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? - 'https://depot.galaxyproject.org/singularity/blast:2.12.0--pl5262h3289130_0' : - 'biocontainers/blast:2.12.0--pl5262h3289130_0' }" + 'https://depot.galaxyproject.org/singularity/blast:2.15.0--pl5321h6f7f691_1' : + 'biocontainers/blast:2.15.0--pl5321h6f7f691_1' }" input: tuple val(meta), path(fasta) From 48c4d9a3f5ecf66061ac510011d7a50dda9b6fbb Mon Sep 17 00:00:00 2001 From: MartinPippel Date: Mon, 15 Jan 2024 13:03:36 +0100 Subject: [PATCH 3/3] update module nf-core/blast/makeblastdb --- modules.json | 2 +- modules/nf-core/blast/makeblastdb/environment.yml | 2 +- modules/nf-core/blast/makeblastdb/main.nf | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules.json b/modules.json index 4caf7cd7..bd029df7 100644 --- a/modules.json +++ b/modules.json @@ -7,7 +7,7 @@ "nf-core": { "blast/makeblastdb": { "branch": "master", - "git_sha": "3f5420aa22e00bd030a2556dfdffc9e164ec0ec5", + "git_sha": "a01c66c96e0bc610ad126e7adc4a94cd4acd1b48", "installed_by": ["modules"] }, "busco": { diff --git a/modules/nf-core/blast/makeblastdb/environment.yml b/modules/nf-core/blast/makeblastdb/environment.yml index cf84a60e..a20783b0 100644 --- a/modules/nf-core/blast/makeblastdb/environment.yml +++ b/modules/nf-core/blast/makeblastdb/environment.yml @@ -4,4 +4,4 @@ channels: - bioconda - defaults dependencies: - - bioconda::blast=2.14.1 + - bioconda::blast=2.15.0 diff --git a/modules/nf-core/blast/makeblastdb/main.nf b/modules/nf-core/blast/makeblastdb/main.nf index cd1083d0..a2c73189 100644 --- a/modules/nf-core/blast/makeblastdb/main.nf +++ b/modules/nf-core/blast/makeblastdb/main.nf @@ -4,8 +4,8 @@ process BLAST_MAKEBLASTDB { conda "${moduleDir}/environment.yml" container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? - 'https://depot.galaxyproject.org/singularity/blast:2.14.1--pl5321h6f7f691_0': - 'biocontainers/blast:2.14.1--pl5321h6f7f691_0' }" + 'https://depot.galaxyproject.org/singularity/blast:2.15.0--pl5321h6f7f691_1': + 'biocontainers/blast:2.15.0--pl5321h6f7f691_1' }" input: tuple val(meta), path(fasta)