annotate 0.6.1/modules/abricate/summary/main.nf @ 11:749faef1caa9

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