annotate 0.1.0/modules/mashtree/main.nf @ 0:c8597e9e1a97

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