annotate 0.4.2/modules/centrifuge/classify/main.nf @ 130:04f6ac8ca13c

planemo upload
author kkonganti
date Wed, 03 Jul 2024 15:16:39 -0400
parents 52045ea4679d
children
rev   line source
kkonganti@105 1 process CENTRIFUGE_CLASSIFY {
kkonganti@105 2 tag "$meta.id"
kkonganti@105 3 label 'process_medium'
kkonganti@105 4
kkonganti@105 5 module (params.enable_module ? 'centrifuge' : null)
kkonganti@105 6 conda (params.enable_conda ? "bioconda::centrifuge=1.0.4_beta" : null)
kkonganti@105 7 container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
kkonganti@105 8 'https://depot.galaxyproject.org/singularity/centrifuge:1.0.4_beta--h9a82719_6' :
kkonganti@105 9 'quay.io/biocontainers/centrifuge:1.0.4_beta--h9a82719_6' }"
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('*.report.txt') , emit: report
kkonganti@105 16 tuple val(meta), path('*.output.txt') , emit: output
kkonganti@105 17 tuple val(meta), path('*.kreport.txt') , emit: kreport
kkonganti@105 18 tuple val(meta), path('*.sam') , optional: true, emit: sam
kkonganti@105 19 tuple val(meta), path('*.mapped.fastq{,.1,.2}.gz') , optional: true, emit: fastq_mapped
kkonganti@105 20 tuple val(meta), path('*.unmapped.fastq{,.1,.2}.gz') , optional: true, emit: fastq_unmapped
kkonganti@105 21 path "versions.yml" , emit: versions
kkonganti@105 22
kkonganti@105 23 when:
kkonganti@105 24 task.ext.when == null || task.ext.when
kkonganti@105 25
kkonganti@105 26 script:
kkonganti@105 27 def args = task.ext.args ?: ''
kkonganti@105 28 def prefix = task.ext.prefix ?: "${meta.id}"
kkonganti@105 29 def paired = meta.single_end ? "-U ${reads}" : "-1 ${reads[0]} -2 ${reads[1]}"
kkonganti@105 30 def db = meta.centrifuge_x ?: ''
kkonganti@105 31 def db_name = db.toString().replace(".tar.gz","")
kkonganti@105 32 def unaligned = ''
kkonganti@105 33 def aligned = ''
kkonganti@105 34 if (meta.single_end) {
kkonganti@105 35 unaligned = params.centrifuge_save_unaligned ? "--un-gz ${prefix}.unmapped.fastq.gz" : ''
kkonganti@105 36 aligned = params.centrifuge_save_aligned ? "--al-gz ${prefix}.mapped.fastq.gz" : ''
kkonganti@105 37 } else {
kkonganti@105 38 unaligned = params.centrifuge_save_unaligned ? "--un-conc-gz ${prefix}.unmapped.fastq.gz" : ''
kkonganti@105 39 aligned = params.centrifuge_save_aligned ? "--al-conc-gz ${prefix}.mapped.fastq.gz" : ''
kkonganti@105 40 }
kkonganti@105 41 def sam_output = params.centrifuge_out_fmt_sam ? "--out-fmt 'sam'" : ''
kkonganti@105 42 """
kkonganti@105 43 centrifuge \\
kkonganti@105 44 -x $db \\
kkonganti@105 45 -p $task.cpus \\
kkonganti@105 46 $paired \\
kkonganti@105 47 --report-file ${prefix}.centrifuge.report.txt \\
kkonganti@105 48 -S ${prefix}.centrifuge.output.txt \\
kkonganti@105 49 $unaligned \\
kkonganti@105 50 $aligned \\
kkonganti@105 51 $sam_output \\
kkonganti@105 52 $args
kkonganti@105 53
kkonganti@105 54 centrifuge-kreport -x $db_name ${prefix}.centrifuge.output.txt > ${prefix}.centrifuge.kreport.txt
kkonganti@105 55
kkonganti@105 56 cat <<-END_VERSIONS > versions.yml
kkonganti@105 57 "${task.process}":
kkonganti@105 58 centrifuge: \$( centrifuge --version | sed -n 1p | sed 's/^.*centrifuge-class version //')
kkonganti@105 59 END_VERSIONS
kkonganti@105 60 """
kkonganti@105 61 }