annotate 0.7.0/modules/abricate/summary/main.nf @ 19:4b304d77bbfb

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