2022-02-19 23:02:23 +00:00
|
|
|
process AMRFINDERPLUS_RUN {
|
|
|
|
tag "$meta.id"
|
|
|
|
label 'process_medium'
|
|
|
|
|
2022-07-19 07:52:36 +00:00
|
|
|
conda (params.enable_conda ? "bioconda::ncbi-amrfinderplus=3.10.30" : null)
|
2022-02-19 23:02:23 +00:00
|
|
|
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
|
2022-07-19 07:52:36 +00:00
|
|
|
'https://depot.galaxyproject.org/singularity/ncbi-amrfinderplus:3.10.30--h6e70893_0':
|
|
|
|
'quay.io/biocontainers/ncbi-amrfinderplus:3.10.30--h6e70893_0' }"
|
2022-02-19 23:02:23 +00:00
|
|
|
|
|
|
|
input:
|
|
|
|
tuple val(meta), path(fasta)
|
|
|
|
path db
|
|
|
|
|
|
|
|
output:
|
|
|
|
tuple val(meta), path("${prefix}.tsv") , emit: report
|
|
|
|
tuple val(meta), path("${prefix}-mutations.tsv"), emit: mutation_report, optional: true
|
|
|
|
path "versions.yml" , emit: versions
|
2022-07-20 09:55:44 +00:00
|
|
|
env VER , emit: tool_version
|
|
|
|
env DBVER , emit: db_version
|
2022-02-19 23:02:23 +00:00
|
|
|
|
|
|
|
when:
|
|
|
|
task.ext.when == null || task.ext.when
|
|
|
|
|
|
|
|
script:
|
|
|
|
def args = task.ext.args ?: ''
|
|
|
|
def is_compressed = fasta.getName().endsWith(".gz") ? true : false
|
|
|
|
prefix = task.ext.prefix ?: "${meta.id}"
|
|
|
|
organism_param = meta.containsKey("organism") ? "--organism ${meta.organism} --mutation_all ${prefix}-mutations.tsv" : ""
|
|
|
|
fasta_name = fasta.getName().replace(".gz", "")
|
|
|
|
fasta_param = "-n"
|
|
|
|
if (meta.containsKey("is_proteins")) {
|
|
|
|
if (meta.is_proteins) {
|
|
|
|
fasta_param = "-p"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
if [ "$is_compressed" == "true" ]; then
|
|
|
|
gzip -c -d $fasta > $fasta_name
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir amrfinderdb
|
|
|
|
tar xzvf $db -C amrfinderdb
|
|
|
|
|
|
|
|
amrfinder \\
|
|
|
|
$fasta_param $fasta_name \\
|
|
|
|
$organism_param \\
|
|
|
|
$args \\
|
|
|
|
--database amrfinderdb \\
|
|
|
|
--threads $task.cpus > ${prefix}.tsv
|
|
|
|
|
2022-07-20 09:55:44 +00:00
|
|
|
VER=\$(amrfinder --version)
|
|
|
|
DBVER=\$(echo \$(amrfinder --database amrfinderdb --database_version 2> stdout) | rev | cut -f 1 -d ' ' | rev)
|
2022-02-19 23:02:23 +00:00
|
|
|
|
|
|
|
cat <<-END_VERSIONS > versions.yml
|
|
|
|
"${task.process}":
|
|
|
|
amrfinderplus: \$(amrfinder --version)
|
2022-07-19 07:52:36 +00:00
|
|
|
amrfinderplus-database: \$(echo \$(echo \$(amrfinder --database amrfinderdb --database_version 2> stdout) | rev | cut -f 1 -d ' ' | rev))
|
2022-02-19 23:02:23 +00:00
|
|
|
END_VERSIONS
|
|
|
|
"""
|
|
|
|
}
|