2021-07-01 16:13:01 +01:00
|
|
|
process KRAKEN2_KRAKEN2 {
|
2021-03-18 14:08:06 +01:00
|
|
|
tag "$meta.id"
|
|
|
|
label 'process_high'
|
|
|
|
|
2022-01-13 11:59:33 +00:00
|
|
|
conda (params.enable_conda ? 'bioconda::kraken2=2.1.2 conda-forge::pigz=2.6' : null)
|
2021-11-26 07:58:40 +00:00
|
|
|
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
|
2022-01-13 11:59:33 +00:00
|
|
|
'https://depot.galaxyproject.org/singularity/mulled-v2-5799ab18b5fc681e75923b2450abaa969907ec98:87fc08d11968d081f3e8a37131c1f1f6715b6542-0' :
|
|
|
|
'quay.io/biocontainers/mulled-v2-5799ab18b5fc681e75923b2450abaa969907ec98:87fc08d11968d081f3e8a37131c1f1f6715b6542-0' }"
|
2021-03-18 14:08:06 +01:00
|
|
|
|
|
|
|
input:
|
|
|
|
tuple val(meta), path(reads)
|
|
|
|
path db
|
2022-04-21 14:33:59 +02:00
|
|
|
val save_output_fastqs
|
|
|
|
val save_reads_assignment
|
2021-03-18 14:08:06 +01:00
|
|
|
|
|
|
|
output:
|
2022-04-21 14:33:59 +02:00
|
|
|
tuple val(meta), path('*classified*') , optional:true, emit: classified_reads_fastq
|
|
|
|
tuple val(meta), path('*unclassified*') , optional:true, emit: unclassified_reads_fastq
|
|
|
|
tuple val(meta), path('*classifiedreads*'), optional:true, emit: classified_reads_assignment
|
|
|
|
tuple val(meta), path('*report.txt') , emit: report
|
|
|
|
path "versions.yml" , emit: versions
|
2021-03-18 14:08:06 +01:00
|
|
|
|
2022-02-04 09:53:32 +01:00
|
|
|
when:
|
|
|
|
task.ext.when == null || task.ext.when
|
|
|
|
|
2021-03-18 14:08:06 +01:00
|
|
|
script:
|
2021-11-26 07:58:40 +00:00
|
|
|
def args = task.ext.args ?: ''
|
2021-12-02 12:39:55 +00:00
|
|
|
def prefix = task.ext.prefix ?: "${meta.id}"
|
2021-03-18 14:08:06 +01:00
|
|
|
def paired = meta.single_end ? "" : "--paired"
|
|
|
|
def classified = meta.single_end ? "${prefix}.classified.fastq" : "${prefix}.classified#.fastq"
|
|
|
|
def unclassified = meta.single_end ? "${prefix}.unclassified.fastq" : "${prefix}.unclassified#.fastq"
|
2022-04-21 14:33:59 +02:00
|
|
|
def classified_command = save_output_fastqs ? "--classified-out ${classified}" : ""
|
|
|
|
def unclassified_command = save_output_fastqs ? "--unclassified-out ${unclassified}" : ""
|
|
|
|
def readclassification_command = save_reads_assignment ? "--output ${prefix}.kraken2.classifiedreads.txt" : ""
|
|
|
|
def compress_reads_command = save_output_fastqs ? "pigz -p $task.cpus *.fastq" : ""
|
|
|
|
|
2021-03-18 14:08:06 +01:00
|
|
|
"""
|
|
|
|
kraken2 \\
|
|
|
|
--db $db \\
|
|
|
|
--threads $task.cpus \\
|
|
|
|
--report ${prefix}.kraken2.report.txt \\
|
|
|
|
--gzip-compressed \\
|
2022-04-21 14:33:59 +02:00
|
|
|
$unclassified_command \\
|
|
|
|
$classified_command \\
|
|
|
|
$readclassification_command \\
|
2021-03-18 14:08:06 +01:00
|
|
|
$paired \\
|
2021-11-26 07:58:40 +00:00
|
|
|
$args \\
|
2021-03-18 14:08:06 +01:00
|
|
|
$reads
|
|
|
|
|
2022-04-21 14:33:59 +02:00
|
|
|
$compress_reads_command
|
2021-04-12 17:47:34 +01:00
|
|
|
|
2021-09-27 10:41:24 +02:00
|
|
|
cat <<-END_VERSIONS > versions.yml
|
2021-11-26 07:58:40 +00:00
|
|
|
"${task.process}":
|
|
|
|
kraken2: \$(echo \$(kraken2 --version 2>&1) | sed 's/^.*Kraken version //; s/ .*\$//')
|
2021-09-28 14:37:47 +01:00
|
|
|
pigz: \$( pigz --version 2>&1 | sed 's/pigz //g' )
|
2021-09-27 10:41:24 +02:00
|
|
|
END_VERSIONS
|
2021-03-18 14:08:06 +01:00
|
|
|
"""
|
|
|
|
}
|