Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Prokka to take compressed input && tidy module script #7250

Merged
merged 9 commits into from
Jan 8, 2025
1 change: 1 addition & 0 deletions modules/nf-core/prokka/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ channels:
- bioconda
dependencies:
- bioconda::prokka=1.14.6
- conda-forge::openjdk=8.0.412
57 changes: 44 additions & 13 deletions modules/nf-core/prokka/main.nf
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
process PROKKA {
tag "$meta.id"
tag "${meta.id}"
label 'process_low'

conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/prokka:1.14.6--pl5321hdfd78af_4' :
'biocontainers/prokka:1.14.6--pl5321hdfd78af_4' }"
'https://community-cr-prod.seqera.io/docker/registry/v2/blobs/sha256/3a/3af46b047c8fe84112adeaecf300878217c629b97f111f923ecf327656ddd141/data' :
'community.wave.seqera.io/library/prokka_openjdk:10546cadeef11472' }"

input:
tuple val(meta), path(fasta)
Expand All @@ -31,18 +31,49 @@ process PROKKA {
task.ext.when == null || task.ext.when

script:
def args = task.ext.args ?: ''
prefix = task.ext.prefix ?: "${meta.id}"
def proteins_opt = proteins ? "--proteins ${proteins[0]}" : ""
def prodigal_tf = prodigal_tf ? "--prodigaltf ${prodigal_tf[0]}" : ""
def args = task.ext.args ?: ''
prefix = task.ext.prefix ?: "${meta.id}"
def input = fasta.toString() - ~/\.gz$/
def decompress = fasta.getExtension() == "gz" ? "gunzip -c ${fasta} > ${input}" : ""
def cleanup = fasta.getExtension() == "gz" ? "rm ${input}" : ""
def proteins_opt = proteins ? "--proteins ${proteins}" : ""
def prodigal_tf_in = prodigal_tf ? "--prodigaltf ${prodigal_tf}" : ""
"""
${decompress}

prokka \\
$args \\
--cpus $task.cpus \\
--prefix $prefix \\
$proteins_opt \\
$prodigal_tf \\
$fasta
${args} \\
--cpus ${task.cpus} \\
--prefix ${prefix} \\
${proteins_opt} \\
${prodigal_tf_in} \\
${input}

${cleanup}

cat <<-END_VERSIONS > versions.yml
"${task.process}":
prokka: \$(echo \$(prokka --version 2>&1) | sed 's/^.*prokka //')
END_VERSIONS
"""

stub:
prefix = task.ext.prefix ?: "${meta.id}"
"""
mkdir ${prefix}
touch ${prefix}/${prefix}.gff
touch ${prefix}/${prefix}.gbk
touch ${prefix}/${prefix}.fna
touch ${prefix}/${prefix}.faa
touch ${prefix}/${prefix}.ffn
touch ${prefix}/${prefix}.sqn
touch ${prefix}/${prefix}.fsa
touch ${prefix}/${prefix}.tbl
touch ${prefix}/${prefix}.err
touch ${prefix}/${prefix}.log
touch ${prefix}/${prefix}.txt
touch ${prefix}/${prefix}.tsv
touch ${prefix}/${prefix}.gff

cat <<-END_VERSIONS > versions.yml
"${task.process}":
Expand Down
65 changes: 65 additions & 0 deletions modules/nf-core/prokka/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,69 @@ nextflow_process {

}

test("Prokka - sarscov2 - genome.fasta.gz") {

when {
process {
"""
input[0] = Channel.fromList([
tuple([ id:'test', single_end:false ], // meta map
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta.gz', checkIfExists: true))
])
input[1] = []
input[2] = []
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert path(process.out.gbk.get(0).get(1)).exists() },
{ assert path(process.out.log.get(0).get(1)).exists() },
{ assert path(process.out.sqn.get(0).get(1)).exists() },
{ assert snapshot(
process.out.gff,
process.out.fna,
process.out.faa,
process.out.ffn,
process.out.fsa,
process.out.tbl,
process.out.err,
process.out.txt,
process.out.tsv,
process.out.versions
).match()
}
)
}

}

test("Prokka - sarscov2 - stub") {

options "-stub"

when {
process {
"""
input[0] = Channel.fromList([
tuple([ id:'test', single_end:false ], // meta map
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta.gz', checkIfExists: true))
])
input[1] = []
input[2] = []
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}

}
Loading
Loading