Skip to content

Commit

Permalink
Update GTDBTK/CLASSIFYWF: Fix bash failing if nothing to move in outp…
Browse files Browse the repository at this point in the history
…ut directory (#6618)

* Fix bash failing if nothing to move in output directory (which is a valid behaviour)

* HarshilAlignmentTM
  • Loading branch information
jfy133 authored Sep 10, 2024
1 parent 3a267da commit c44b5e9
Showing 1 changed file with 26 additions and 29 deletions.
55 changes: 26 additions & 29 deletions modules/nf-core/gtdbtk/classifywf/main.nf
Original file line number Diff line number Diff line change
@@ -1,37 +1,33 @@
process GTDBTK_CLASSIFYWF {
tag "${prefix}"
label 'process_medium'

// WARN: Version information not provided by tool on CLI. Please update version string below when bumping container versions.
conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/gtdbtk:2.4.0--pyhdfd78af_1' :
'biocontainers/gtdbtk:2.4.0--pyhdfd78af_1' }"
container "${workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? 'https://depot.galaxyproject.org/singularity/gtdbtk:2.4.0--pyhdfd78af_1' : 'biocontainers/gtdbtk:2.4.0--pyhdfd78af_1'}"

input:
tuple val(meta), path("bins/*")
tuple val(meta) , path("bins/*")
tuple val(db_name), path("database/*")
path(mash_db)
path mash_db

output:
tuple val(meta), path("gtdbtk.${prefix}.*.summary.tsv") , emit: summary
tuple val(meta), path("gtdbtk.${prefix}.*.classify.tree.gz") , emit: tree, optional: true
tuple val(meta), path("gtdbtk.${prefix}.*.markers_summary.tsv") , emit: markers, optional: true
tuple val(meta), path("gtdbtk.${prefix}.*.msa.fasta.gz") , emit: msa, optional: true
tuple val(meta), path("gtdbtk.${prefix}.*.user_msa.fasta.gz") , emit: user_msa, optional: true
tuple val(meta), path("gtdbtk.${prefix}.*.filtered.tsv") , emit: filtered, optional: true
tuple val(meta), path("gtdbtk.${prefix}.failed_genomes.tsv") , emit: failed, optional: true
tuple val(meta), path("gtdbtk.${prefix}.log") , emit: log
tuple val(meta), path("gtdbtk.${prefix}.warnings.log") , emit: warnings
path("versions.yml") , emit: versions
tuple val(meta), path("gtdbtk.${prefix}.*.summary.tsv") , emit: summary
tuple val(meta), path("gtdbtk.${prefix}.*.classify.tree.gz") , emit: tree , optional: true
tuple val(meta), path("gtdbtk.${prefix}.*.markers_summary.tsv"), emit: markers , optional: true
tuple val(meta), path("gtdbtk.${prefix}.*.msa.fasta.gz") , emit: msa , optional: true
tuple val(meta), path("gtdbtk.${prefix}.*.user_msa.fasta.gz") , emit: user_msa, optional: true
tuple val(meta), path("gtdbtk.${prefix}.*.filtered.tsv") , emit: filtered, optional: true
tuple val(meta), path("gtdbtk.${prefix}.failed_genomes.tsv") , emit: failed , optional: true
tuple val(meta), path("gtdbtk.${prefix}.log") , emit: log
tuple val(meta), path("gtdbtk.${prefix}.warnings.log") , emit: warnings
path ("versions.yml"), emit: versions

when:
task.ext.when == null || task.ext.when

script:
def args = task.ext.args ?: ''
def pplacer_scratch = params.gtdbtk_pplacer_scratch ? "--scratch_dir pplacer_tmp" : ""
def mash_mode = mash_db ? "--mash_db ${mash_db}" : "--skip_ani_screen"
def mash_mode = mash_db ? "--mash_db ${mash_db}" : "--skip_ani_screen"
prefix = task.ext.prefix ?: "${meta.id}"

"""
Expand All @@ -41,27 +37,27 @@ process GTDBTK_CLASSIFYWF {
fi
gtdbtk classify_wf \\
$args \\
${args} \\
--genome_dir bins \\
--prefix "gtdbtk.${prefix}" \\
--out_dir "\${PWD}" \\
--cpus $task.cpus \\
$mash_mode \\
$pplacer_scratch \\
--min_perc_aa $params.gtdbtk_min_perc_aa \\
--min_af $params.gtdbtk_min_af
--cpus ${task.cpus} \\
${mash_mode} \\
${pplacer_scratch} \\
--min_perc_aa ${params.gtdbtk_min_perc_aa} \\
--min_af ${params.gtdbtk_min_af}
## If mash db given, classify/ and identify/ directories won't be created
if [[ -d classify/ ]]; then
if [[ -d classify/ && \$(ls -A classify/) ]]; then
mv classify/* .
fi
if [[ -d identify/ ]]; then
if [[ -d identify/ && \$(ls -A identify/) ]]; then
mv identify/* .
fi
## If nothing aligns, no output, so only run
if [[ -d align/ ]]; then
if [[ -d align/ && \$(ls -A align/) ]]; then
mv align/* .
fi
Expand All @@ -78,7 +74,8 @@ process GTDBTK_CLASSIFYWF {
"""

stub:
def VERSION = '2.3.2' // WARN: Version information not provided by tool on CLI. Please update this string when bumping container versions.
def VERSION = '2.3.2'
// WARN: Version information not provided by tool on CLI. Please update this string when bumping container versions.
prefix = task.ext.prefix ?: "${meta.id}"
"""
touch gtdbtk.${prefix}.stub.summary.tsv
Expand All @@ -93,7 +90,7 @@ process GTDBTK_CLASSIFYWF {
cat <<-END_VERSIONS > versions.yml
"${task.process}":
gtdbtk: \$(echo "$VERSION")
gtdbtk: \$(echo "${VERSION}")
END_VERSIONS
"""
}

0 comments on commit c44b5e9

Please sign in to comment.