annotate 0.4.2/modules/centrifuge/extract/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 CENTRIFUGE_EXTRACT {
kkonganti@105 2 tag "$meta.id"
kkonganti@105 3 label 'process_low'
kkonganti@105 4
kkonganti@105 5 //seqkit container contains required bash and other utilities
kkonganti@105 6 module (params.enable_module ? "${params.swmodulepath}${params.fs}python${params.fs}3.8.1" : null)
kkonganti@105 7 conda (params.enable_conda ? "conda-forge::sed=4.7 conda-forge::coreutils" : null)
kkonganti@105 8 container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
kkonganti@105 9 'https://depot.galaxyproject.org/singularity/mulled-v2-039542721b6b463b663872ba8b7e9fbc05f01925:1de88053ebf8fb9884758395c4871f642c57750c-0':
kkonganti@105 10 'quay.io/biocontainers/mulled-v2-039542721b6b463b663872ba8b7e9fbc05f01925:1de88053ebf8fb9884758395c4871f642c57750c-0' }"
kkonganti@105 11
kkonganti@105 12 input:
kkonganti@105 13 tuple val(meta), path(centrifuge_report)
kkonganti@105 14 tuple val(meta), path(centrifuge_output)
kkonganti@105 15
kkonganti@105 16 output:
kkonganti@105 17 tuple val(meta), path('*.extract-centrifuge-bug-ids.txt'), emit: extracted
kkonganti@105 18 path "versions.yml" , emit: versions
kkonganti@105 19
kkonganti@105 20 when:
kkonganti@105 21 task.ext.when == null || task.ext.when
kkonganti@105 22
kkonganti@105 23 script:
kkonganti@105 24 def args = task.ext.args ?: ''
kkonganti@105 25 def prefix = task.ext.prefix ?: "${meta.id}"
kkonganti@105 26 """
kkonganti@105 27 grep -F '${params.centrifuge_extract_bug}' $centrifuge_report \
kkonganti@105 28 | cut -f2 \
kkonganti@105 29 | sort -u \
kkonganti@105 30 | while read -r taxId; do
kkonganti@105 31 echo -e "\t\$taxId"'\$'
kkonganti@105 32 done > gotcha.txt
kkonganti@105 33
kkonganti@105 34 cut -f1-3 $centrifuge_output | grep -E -f gotcha.txt | cut -f1 | sort -u > ${prefix}.extract-centrifuge-bug-ids.txt || true
kkonganti@105 35
kkonganti@105 36 cat <<-END_VERSIONS > versions.yml
kkonganti@105 37 "${task.process}":
kkonganti@105 38 bash: \$( bash --version 2>&1 | sed '1!d; s/^.*version //; s/ (.*\$//' )
kkonganti@105 39 END_VERSIONS
kkonganti@105 40
kkonganti@105 41 ver=""
kkonganti@105 42 sedver=""
kkonganti@105 43
kkonganti@105 44 if [ "${workflow.containerEngine}" != "null" ]; then
kkonganti@105 45 ver=\$( cut --help 2>&1 | sed -e '1!d; s/ (.*\$//' )
kkonganti@105 46 sedver="\$ver"
kkonganti@105 47 else
kkonganti@105 48 ver=\$( cut --version 2>&1 | sed '1!d; s/^.*(GNU coreutils//; s/) //;' )
kkonganti@105 49 sedver=\$( echo \$(sed --version 2>&1) | sed 's/^.*(GNU sed) //; s/ Copyright.*\$//' )
kkonganti@105 50 fi
kkonganti@105 51
kkonganti@105 52 cat <<-END_VERSIONS >> versions.yml
kkonganti@105 53 cut: \$ver
kkonganti@105 54 tail: \$ver
kkonganti@105 55 sort: \$ver
kkonganti@105 56 sed: \$sedver
kkonganti@105 57 END_VERSIONS
kkonganti@105 58 """
kkonganti@105 59 }