comparison 0.4.2/modules/kraken2/classify/main.nf @ 105:52045ea4679d

"planemo upload"
author kkonganti
date Thu, 27 Jun 2024 14:17:26 -0400
parents
children
comparison
equal deleted inserted replaced
104:17890124001d 105:52045ea4679d
1 process KRAKEN2_CLASSIFY {
2 tag "$meta.id"
3 label 'process_low'
4
5 module (params.enable_module ? "${params.swmodulepath}${params.fs}kraken2${params.fs}2.1.2" : null)
6 conda (params.enable_conda ? 'bioconda::kraken2=2.1.2 conda-forge::pigz=2.6' : null)
7 container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
8 'https://depot.galaxyproject.org/singularity/mulled-v2-5799ab18b5fc681e75923b2450abaa969907ec98:87fc08d11968d081f3e8a37131c1f1f6715b6542-0' :
9 'quay.io/biocontainers/mulled-v2-5799ab18b5fc681e75923b2450abaa969907ec98:87fc08d11968d081f3e8a37131c1f1f6715b6542-0' }"
10
11 input:
12 tuple val(meta), path(reads)
13
14 output:
15 tuple val(meta), path('*classified*') , emit: classified
16 tuple val(meta), path('*unclassified*'), emit: unclassified
17 tuple val(meta), path('*.report.txt') , emit: kraken_report
18 tuple val(meta), path('*.output.txt') , emit: kraken_output
19 path "versions.yml" , emit: versions
20
21 when:
22 (task.ext.when == null || task.ext.when) && (meta.is_assembly ? reads.size() : 1)
23
24 script:
25 def args = task.ext.args ?: ''
26 def db = meta.kraken2_db ?: ''
27 def prefix = task.ext.prefix ?: "${meta.id}"
28 def readList = reads.collect{ it.toString() }
29 def is_single_end = (meta.single_end || meta.is_assembly) ? true : false
30 def paired = is_single_end ? "" : "--paired"
31 def classified = is_single_end ? "--classified-out ${prefix}.classified.fastq" : "--classified-out ${prefix}.classified#.fastq"
32 def unclassified = is_single_end ? "--unclassified-out ${prefix}.unclassified.fastq" : "--unclassified-out ${prefix}.unclassified#.fastq"
33 args += (reads.getName().endsWith(".gz") ? ' --gzip-compressed ' : '')
34 """
35 kraken2 \\
36 --db $db \\
37 --threads $task.cpus \\
38 $unclassified \\
39 $classified \\
40 --report ${prefix}.kraken2.report.txt \\
41 --output ${prefix}.kraken2.output.txt \\
42 $paired \\
43 $args \\
44 $reads
45
46 cat <<-END_VERSIONS > versions.yml
47 "${task.process}":
48 kraken2: \$(echo \$(kraken2 --version 2>&1) | sed 's/^.*Kraken version //; s/ .*\$//')
49 END_VERSIONS
50
51 zcmd=""
52 zver=""
53
54 if type pigz > /dev/null 2>&1; then
55 pigz -p $task.cpus *.fastq
56 zcmd="pigz"
57 zver=\$( echo \$( \$zcmd --version 2>&1 ) | sed -e '1!d' | sed "s/\$zcmd //" )
58 elif type gzip > /dev/null 2>&1; then
59 gzip *.fastq
60 zcmd="gzip"
61
62 if [ "${workflow.containerEngine}" != "null" ]; then
63 zver=\$( echo \$( \$zcmd --help 2>&1 ) | sed -e '1!d; s/ (.*\$//' )
64 else
65 zver=\$( echo \$( \$zcmd --version 2>&1 ) | sed "s/^.*(\$zcmd) //; s/\$zcmd //; s/ Copyright.*\$//" )
66 fi
67 fi
68
69 cat <<-END_VERSIONS >> versions.yml
70 \$zcmd: \$zver
71 END_VERSIONS
72 """
73 }