annotate 0.4.2/modules/kraken2/classify/main.nf @ 143:620bffa66bbb tip

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