annotate 0.2.1/modules/abricate/summary/main.nf @ 0:77494b0fa3c7

"planemo upload"
author kkonganti
date Mon, 27 Jun 2022 15:55:37 -0400
parents
children
rev   line source
kkonganti@0 1 process ABRICATE_SUMMARY {
kkonganti@0 2 tag "${abdbs.join(',')}"
kkonganti@0 3 label 'process_low'
kkonganti@0 4
kkonganti@0 5 module (params.enable_module ? "${params.swmodulepath}${params.fs}abricate${params.fs}1.0.1" : null)
kkonganti@0 6 conda (params.enable_conda ? "bioconda::abricate=1.0.1 conda-forge::coreutils" : null)
kkonganti@0 7 container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
kkonganti@0 8 'https://depot.galaxyproject.org/singularity/abricate%3A1.0.1--ha8f3691_1':
kkonganti@0 9 'quay.io/biocontainers/abricate:1.0.1--ha8f3691_1' }"
kkonganti@0 10
kkonganti@0 11 input:
kkonganti@0 12 tuple val(abdbs), path(abfiles)
kkonganti@0 13
kkonganti@0 14 output:
kkonganti@0 15 tuple val('abricate_ncbi'), path("*.ncbi.absum.txt") , emit: ncbi, optional: true
kkonganti@0 16 tuple val('abricate_ncbiamrplus'), path("*.ncbiamrplus.absum.txt"), emit: ncbiamrplus, optional: true
kkonganti@0 17 tuple val('abricate_resfinder'), path("*resfinder.absum.txt") , emit: resfinder, optional: true
kkonganti@0 18 tuple val('abricate_megares'), path("*.megares.absum.txt") , emit: megares, optional: true
kkonganti@0 19 tuple val('abricate_argannot'), path("*.argannot.absum.txt") , emit: argannot, optional: true
kkonganti@0 20 tuple val('abricate_ecoli_vf'), path("*.ecoli_vf.absum.txt") , emit: ecoli_vf, optional: true
kkonganti@0 21 path "versions.yml" , emit: versions
kkonganti@0 22
kkonganti@0 23 when:
kkonganti@0 24 task.ext.when == null || task.ext.when
kkonganti@0 25
kkonganti@0 26 script:
kkonganti@0 27 def args = task.ext.args ?: ''
kkonganti@0 28 def onthese = abdbs.collect{ db ->
kkonganti@0 29 abfiles.findAll { files ->
kkonganti@0 30 files =~ /\.${db}/
kkonganti@0 31 }.join(' ')
kkonganti@0 32 }.join('\\n')
kkonganti@0 33 """
kkonganti@0 34 filenum="1"
kkonganti@0 35
kkonganti@0 36 echo -e "$onthese" | while read -r files; do
kkonganti@0 37 db=\$( echo -e "\${files}" | grep -E -o '\\w+\\.ab\\.txt' | sort -u | sed -e 's/.ab.txt//' )
kkonganti@0 38
kkonganti@0 39 if [ -z "\$db" ]; then
kkonganti@0 40 db="\$filenum"
kkonganti@0 41 fi
kkonganti@0 42
kkonganti@0 43 abricate \\
kkonganti@0 44 $args \\
kkonganti@0 45 --summary \${files} \\
kkonganti@0 46 1> "abricate.\${db}.absum.txt"
kkonganti@0 47
kkonganti@0 48 filenum=\$((filenum+1))
kkonganti@0 49 done
kkonganti@0 50
kkonganti@0 51 cat <<-END_VERSIONS > versions.yml
kkonganti@0 52 "${task.process}":
kkonganti@0 53 abricate: \$(echo \$(abricate --version 2>&1) | sed 's/^.*abricate //' )
kkonganti@0 54 bash: \$( bash --version 2>&1 | sed '1!d; s/^.*version //; s/ (.*\$//' )
kkonganti@0 55 END_VERSIONS
kkonganti@0 56
kkonganti@0 57 sedver=""
kkonganti@0 58 sortver=""
kkonganti@0 59 grepver=""
kkonganti@0 60
kkonganti@0 61 if [ "${workflow.containerEngine}" != "null" ]; then
kkonganti@0 62 sortver=\$( sort --help 2>&1 | sed -e '1!d; s/ (.*\$//' )
kkonganti@0 63 sedver="\$sortver"
kkonganti@0 64 grepver="\$sortver"
kkonganti@0 65 else
kkonganti@0 66 sortver=\$( sort --version 2>&1 | sed '1!d; s/^.*(GNU coreutils//; s/) //;' )
kkonganti@0 67 sedver=\$( echo \$(sed --version 2>&1) | sed 's/^.*(GNU sed) //; s/ Copyright.*\$//' )
kkonganti@0 68 grepver=\$( echo \$(grep --version 2>&1) | sed 's/^.*(GNU grep) //; s/ Copyright.*\$//' )
kkonganti@0 69 fi
kkonganti@0 70
kkonganti@0 71 cat <<-END_VERSIONS >> versions.yml
kkonganti@0 72 sort: \$sortver
kkonganti@0 73 grep: \$grepver
kkonganti@0 74 sed: \$sedver
kkonganti@0 75 END_VERSIONS
kkonganti@0 76 """
kkonganti@0 77 }