annotate 0.3.0/modules/kraken2/classify/main.nf @ 92:295c2597a475

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