annotate 0.4.0/modules/abricate/summary/main.nf @ 101:ce6d9548fe89

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