annotate 0.4.2/modules/abricate/summary/main.nf @ 143:620bffa66bbb tip

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