kkonganti@105: process KRAKEN2_CLASSIFY { kkonganti@105: tag "$meta.id" kkonganti@105: label 'process_low' kkonganti@105: kkonganti@105: module (params.enable_module ? "${params.swmodulepath}${params.fs}kraken2${params.fs}2.1.2" : null) kkonganti@105: conda (params.enable_conda ? 'bioconda::kraken2=2.1.2 conda-forge::pigz=2.6' : null) kkonganti@105: container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? kkonganti@105: 'https://depot.galaxyproject.org/singularity/mulled-v2-5799ab18b5fc681e75923b2450abaa969907ec98:87fc08d11968d081f3e8a37131c1f1f6715b6542-0' : kkonganti@105: 'quay.io/biocontainers/mulled-v2-5799ab18b5fc681e75923b2450abaa969907ec98:87fc08d11968d081f3e8a37131c1f1f6715b6542-0' }" kkonganti@105: kkonganti@105: input: kkonganti@105: tuple val(meta), path(reads) kkonganti@105: kkonganti@105: output: kkonganti@105: tuple val(meta), path('*classified*') , emit: classified kkonganti@105: tuple val(meta), path('*unclassified*'), emit: unclassified kkonganti@105: tuple val(meta), path('*.report.txt') , emit: kraken_report kkonganti@105: tuple val(meta), path('*.output.txt') , emit: kraken_output kkonganti@105: path "versions.yml" , emit: versions kkonganti@105: kkonganti@105: when: kkonganti@105: (task.ext.when == null || task.ext.when) && (meta.is_assembly ? reads.size() : 1) kkonganti@105: kkonganti@105: script: kkonganti@105: def args = task.ext.args ?: '' kkonganti@105: def db = meta.kraken2_db ?: '' kkonganti@105: def prefix = task.ext.prefix ?: "${meta.id}" kkonganti@105: def readList = reads.collect{ it.toString() } kkonganti@105: def is_single_end = (meta.single_end || meta.is_assembly) ? true : false kkonganti@105: def paired = is_single_end ? "" : "--paired" kkonganti@105: def classified = is_single_end ? "--classified-out ${prefix}.classified.fastq" : "--classified-out ${prefix}.classified#.fastq" kkonganti@105: def unclassified = is_single_end ? "--unclassified-out ${prefix}.unclassified.fastq" : "--unclassified-out ${prefix}.unclassified#.fastq" kkonganti@105: args += (reads.getName().endsWith(".gz") ? ' --gzip-compressed ' : '') kkonganti@105: """ kkonganti@105: kraken2 \\ kkonganti@105: --db $db \\ kkonganti@105: --threads $task.cpus \\ kkonganti@105: $unclassified \\ kkonganti@105: $classified \\ kkonganti@105: --report ${prefix}.kraken2.report.txt \\ kkonganti@105: --output ${prefix}.kraken2.output.txt \\ kkonganti@105: $paired \\ kkonganti@105: $args \\ kkonganti@105: $reads kkonganti@105: kkonganti@105: cat <<-END_VERSIONS > versions.yml kkonganti@105: "${task.process}": kkonganti@105: kraken2: \$(echo \$(kraken2 --version 2>&1) | sed 's/^.*Kraken version //; s/ .*\$//') kkonganti@105: END_VERSIONS kkonganti@105: kkonganti@105: zcmd="" kkonganti@105: zver="" kkonganti@105: kkonganti@105: if type pigz > /dev/null 2>&1; then kkonganti@105: pigz -p $task.cpus *.fastq kkonganti@105: zcmd="pigz" kkonganti@105: zver=\$( echo \$( \$zcmd --version 2>&1 ) | sed -e '1!d' | sed "s/\$zcmd //" ) kkonganti@105: elif type gzip > /dev/null 2>&1; then kkonganti@105: gzip *.fastq kkonganti@105: zcmd="gzip" kkonganti@105: kkonganti@105: if [ "${workflow.containerEngine}" != "null" ]; then kkonganti@105: zver=\$( echo \$( \$zcmd --help 2>&1 ) | sed -e '1!d; s/ (.*\$//' ) kkonganti@105: else kkonganti@105: zver=\$( echo \$( \$zcmd --version 2>&1 ) | sed "s/^.*(\$zcmd) //; s/\$zcmd //; s/ Copyright.*\$//" ) kkonganti@105: fi kkonganti@105: fi kkonganti@105: kkonganti@105: cat <<-END_VERSIONS >> versions.yml kkonganti@105: \$zcmd: \$zver kkonganti@105: END_VERSIONS kkonganti@105: """ kkonganti@105: }