kkonganti@0: process MASHTREE { kkonganti@0: tag "$meta.id" kkonganti@0: label 'process_medium' kkonganti@0: kkonganti@0: module (params.enable_module ? "${params.swmodulepath}${params.fs}mashtree${params.fs}1.4.3" : null) kkonganti@0: conda (params.enable_conda ? "bioconda::mashtree=1.4.3 conda-forge::perl conda-forge::coreutils" : null) kkonganti@0: container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? kkonganti@0: 'https://depot.galaxyproject.org/singularity/mashtree:1.4.3--pl5321h031d066_0' : kkonganti@0: 'quay.io/biocontainers/mashtree:1.4.3--pl5321h031d066_0' }" kkonganti@0: kkonganti@0: input: kkonganti@0: tuple val(meta), path(seqs) kkonganti@0: path reference kkonganti@0: kkonganti@0: output: kkonganti@0: tuple val(meta), path("*.dnd"), emit: tree kkonganti@0: tuple val(meta), path("*.tsv"), emit: matrix kkonganti@0: path "versions.yml" , emit: versions kkonganti@0: kkonganti@0: when: kkonganti@0: task.ext.when == null || task.ext.when kkonganti@0: kkonganti@0: script: kkonganti@0: def args = task.ext.args ?: '' kkonganti@0: def prefix = task.ext.prefix ?: "${meta.id}" kkonganti@0: def fofn = (args.toString().matches(/.*file\-of\-files/) ? 'true' : 'false') kkonganti@0: def fas = reference.collect().join('\\n') kkonganti@0: def ref_fasta = (fas ?: '') kkonganti@0: """ kkonganti@0: kkonganti@0: echo -e "$ref_fasta" | while read -r fa; do kkonganti@0: if ! grep -F "\${fa}" $seqs && [ "$fofn" = "true" ]; then kkonganti@0: echo "\${fa}" >> $seqs kkonganti@0: fi kkonganti@0: done kkonganti@0: kkonganti@0: mashtree \\ kkonganti@0: $args \\ kkonganti@0: --tempdir "." \\ kkonganti@0: --numcpus $task.cpus \\ kkonganti@0: --outmatrix ${prefix}.tsv \\ kkonganti@0: --outtree ${prefix}.dnd \\ kkonganti@0: $seqs kkonganti@0: kkonganti@0: sed -ie 's/_scaffolded_genomic//g' ${prefix}.dnd kkonganti@0: kkonganti@0: cat <<-END_VERSIONS > versions.yml kkonganti@0: "${task.process}": kkonganti@0: mashtree: \$( echo \$( mashtree --version 2>&1 ) | sed 's/^.*Mashtree //' ) kkonganti@0: END_VERSIONS kkonganti@0: kkonganti@0: sedver="" kkonganti@0: grepver="" kkonganti@0: kkonganti@0: if [ "${workflow.containerEngine}" != "null" ]; then kkonganti@0: sedver=\$( sed --help 2>&1 | sed -e '1!d; s/ (.*\$//' ) kkonganti@0: grepver="\$sedver" kkonganti@0: else kkonganti@0: sedver=\$( echo \$(sed --version 2>&1) | sed 's/^.*(GNU sed) //; s/ Copyright.*\$//' ) kkonganti@0: grepver=\$( echo \$(grep --version 2>&1) | sed 's/^.*(GNU grep) //; s/ Copyright.*\$//' ) kkonganti@0: fi kkonganti@0: kkonganti@0: cat <<-END_VERSIONS >> versions.yml kkonganti@0: grep: \$grepver kkonganti@0: sed: \$sedver kkonganti@0: END_VERSIONS kkonganti@0: """ kkonganti@0: }