kkonganti@11
|
1 process MASHTREE {
|
kkonganti@11
|
2 tag "$meta.id"
|
kkonganti@11
|
3 label 'process_medium'
|
kkonganti@11
|
4
|
kkonganti@11
|
5 module (params.enable_module ? "${params.swmodulepath}${params.fs}mashtree${params.fs}1.4.3" : null)
|
kkonganti@11
|
6 conda (params.enable_conda ? "bioconda::mashtree=1.4.3 conda-forge::perl 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/mashtree:1.4.3--pl5321h031d066_0' :
|
kkonganti@11
|
9 'quay.io/biocontainers/mashtree:1.4.3--pl5321h031d066_0' }"
|
kkonganti@11
|
10
|
kkonganti@11
|
11 input:
|
kkonganti@11
|
12 tuple val(meta), path(seqs)
|
kkonganti@11
|
13 path reference
|
kkonganti@11
|
14
|
kkonganti@11
|
15 output:
|
kkonganti@11
|
16 tuple val(meta), path("*.dnd"), emit: tree
|
kkonganti@11
|
17 tuple val(meta), path("*.tsv"), emit: matrix
|
kkonganti@11
|
18 tuple val(meta), path("*.nwk"), emit: nwk, optional: true
|
kkonganti@11
|
19 path "versions.yml" , emit: versions
|
kkonganti@11
|
20
|
kkonganti@11
|
21 when:
|
kkonganti@11
|
22 task.ext.when == null || task.ext.when
|
kkonganti@11
|
23
|
kkonganti@11
|
24 script:
|
kkonganti@11
|
25 def args = task.ext.args ?: ''
|
kkonganti@11
|
26 def prefix = task.ext.prefix ?: "${meta.id}"
|
kkonganti@11
|
27 def fofn = (args.toString().matches(/.*file\-of\-files/) ? 'true' : 'false')
|
kkonganti@11
|
28 def fas = reference.collect().join('\\n')
|
kkonganti@11
|
29 def ref_fasta = (fas ?: '')
|
kkonganti@11
|
30 """
|
kkonganti@11
|
31
|
kkonganti@11
|
32 echo -e "$ref_fasta" | while read -r fa; do
|
kkonganti@11
|
33 if ! grep -F "\${fa}" $seqs && [ "$fofn" = "true" ]; then
|
kkonganti@11
|
34 echo "\${fa}" >> $seqs
|
kkonganti@11
|
35 fi
|
kkonganti@11
|
36 done
|
kkonganti@11
|
37
|
kkonganti@11
|
38 mashtree \\
|
kkonganti@11
|
39 $args \\
|
kkonganti@11
|
40 --tempdir "." \\
|
kkonganti@11
|
41 --numcpus $task.cpus \\
|
kkonganti@11
|
42 --outmatrix ${prefix}.tsv \\
|
kkonganti@11
|
43 --outtree ${prefix}.dnd \\
|
kkonganti@11
|
44 $seqs
|
kkonganti@11
|
45
|
kkonganti@11
|
46 sed -ie 's/_scaffolded_genomic//g' ${prefix}.dnd
|
kkonganti@11
|
47 cp ${prefix}.dnd ${prefix}.nwk
|
kkonganti@11
|
48
|
kkonganti@11
|
49 cat <<-END_VERSIONS > versions.yml
|
kkonganti@11
|
50 "${task.process}":
|
kkonganti@11
|
51 mashtree: \$( echo \$( mashtree --version 2>&1 ) | sed 's/^.*Mashtree //' )
|
kkonganti@11
|
52 END_VERSIONS
|
kkonganti@11
|
53
|
kkonganti@11
|
54 sedver=""
|
kkonganti@11
|
55 grepver=""
|
kkonganti@11
|
56
|
kkonganti@11
|
57 if [ "${workflow.containerEngine}" != "null" ]; then
|
kkonganti@11
|
58 sedver=\$( sed --help 2>&1 | sed -e '1!d; s/ (.*\$//' )
|
kkonganti@11
|
59 grepver="\$sedver"
|
kkonganti@11
|
60 else
|
kkonganti@11
|
61 sedver=\$( echo \$(sed --version 2>&1) | sed 's/^.*(GNU sed) //; s/ Copyright.*\$//' )
|
kkonganti@11
|
62 grepver=\$( echo \$(grep --version 2>&1) | sed 's/^.*(GNU grep) //; s/ Copyright.*\$//' )
|
kkonganti@11
|
63 fi
|
kkonganti@11
|
64
|
kkonganti@11
|
65 cat <<-END_VERSIONS >> versions.yml
|
kkonganti@11
|
66 grep: \$grepver
|
kkonganti@11
|
67 sed: \$sedver
|
kkonganti@11
|
68 END_VERSIONS
|
kkonganti@11
|
69 """
|
kkonganti@11
|
70 } |