annotate 0.4.0/modules/kraken2/classify/main.nf @ 104:17890124001d

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