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