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