kkonganti@92: process CENTRIFUGE_EXTRACT { kkonganti@92: tag "$meta.id" kkonganti@92: label 'process_low' kkonganti@92: kkonganti@92: //seqkit container contains required bash and other utilities kkonganti@92: module (params.enable_module ? "${params.swmodulepath}${params.fs}python${params.fs}3.8.1" : null) kkonganti@92: conda (params.enable_conda ? "conda-forge::sed=4.7 conda-forge::coreutils" : null) kkonganti@92: container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? kkonganti@92: 'https://depot.galaxyproject.org/singularity/mulled-v2-039542721b6b463b663872ba8b7e9fbc05f01925:1de88053ebf8fb9884758395c4871f642c57750c-0': kkonganti@92: 'quay.io/biocontainers/mulled-v2-039542721b6b463b663872ba8b7e9fbc05f01925:1de88053ebf8fb9884758395c4871f642c57750c-0' }" kkonganti@92: kkonganti@92: input: kkonganti@92: tuple val(meta), path(centrifuge_report) kkonganti@92: tuple val(meta), path(centrifuge_output) kkonganti@92: kkonganti@92: output: kkonganti@92: tuple val(meta), path('*.extract-centrifuge-bug-ids.txt'), emit: extracted kkonganti@92: path "versions.yml" , emit: versions kkonganti@92: kkonganti@92: when: kkonganti@92: task.ext.when == null || task.ext.when kkonganti@92: kkonganti@92: script: kkonganti@92: def args = task.ext.args ?: '' kkonganti@92: def prefix = task.ext.prefix ?: "${meta.id}" kkonganti@92: """ kkonganti@92: grep -F '${params.centrifuge_extract_bug}' $centrifuge_report \ kkonganti@92: | cut -f2 \ kkonganti@92: | sort -u \ kkonganti@92: | while read -r taxId; do kkonganti@92: echo -e "\t\$taxId"'\$' kkonganti@92: done > gotcha.txt kkonganti@92: kkonganti@92: cut -f1-3 $centrifuge_output | grep -E -f gotcha.txt | cut -f1 | sort -u > ${prefix}.extract-centrifuge-bug-ids.txt || true kkonganti@92: kkonganti@92: cat <<-END_VERSIONS > versions.yml kkonganti@92: "${task.process}": kkonganti@92: bash: \$( bash --version 2>&1 | sed '1!d; s/^.*version //; s/ (.*\$//' ) kkonganti@92: END_VERSIONS kkonganti@92: kkonganti@92: ver="" kkonganti@92: sedver="" kkonganti@92: kkonganti@92: if [ "${workflow.containerEngine}" != "null" ]; then kkonganti@92: ver=\$( cut --help 2>&1 | sed -e '1!d; s/ (.*\$//' ) kkonganti@92: sedver="\$ver" kkonganti@92: else kkonganti@92: ver=\$( cut --version 2>&1 | sed '1!d; s/^.*(GNU coreutils//; s/) //;' ) kkonganti@92: sedver=\$( echo \$(sed --version 2>&1) | sed 's/^.*(GNU sed) //; s/ Copyright.*\$//' ) kkonganti@92: fi kkonganti@92: kkonganti@92: cat <<-END_VERSIONS >> versions.yml kkonganti@92: cut: \$ver kkonganti@92: tail: \$ver kkonganti@92: sort: \$ver kkonganti@92: sed: \$sedver kkonganti@92: END_VERSIONS kkonganti@92: """ kkonganti@92: }