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