annotate 0.2.0/modules/cat/unique/main.nf @ 15:7c0407ebbdf3

planemo upload
author kkonganti
date Mon, 15 Jul 2024 17:55:16 -0400
parents a5f31c44f8c9
children
rev   line source
kkonganti@11 1 process CAT_UNIQUE {
kkonganti@11 2 tag "${meta.id}"
kkonganti@11 3 label "process_pico"
kkonganti@11 4
kkonganti@11 5 module (params.enable_module ? "${params.swmodulepath}${params.fs}perl${params.fs}5.30.0" : null)
kkonganti@11 6 conda (params.enable_conda ? "conda-forge::perl conda-forge::coreutils bioconda::perl-bioperl=1.7.8" : null)
kkonganti@11 7 container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
kkonganti@11 8 'https://depot.galaxyproject.org/singularity/perl-bioperl:1.7.8--hdfd78af_1' :
kkonganti@11 9 'quay.io/biocontainers/perl-bioperl:1.7.8--hdfd78af_1' }"
kkonganti@11 10
kkonganti@11 11 input:
kkonganti@11 12 tuple val(meta), path(file)
kkonganti@11 13
kkonganti@11 14 output:
kkonganti@11 15 path '*_uniq.txt' , emit: txt
kkonganti@11 16 path '*metadata.csv', emit: csv, optional: true
kkonganti@11 17 path 'versions.yml' , emit: versions
kkonganti@11 18
kkonganti@11 19 when:
kkonganti@11 20 task.ext.when == null || task.ext.when
kkonganti@11 21
kkonganti@11 22 script:
kkonganti@11 23 def args = (task.ext.args ?: '')
kkonganti@11 24 def skip = (meta.skip_header ?: 1)
kkonganti@11 25 prefix = (task.ext.prefix ?: meta.id)
kkonganti@11 26 """
kkonganti@11 27 newfile=\$(echo "$file" | sed -e 's/_w_dups/_uniq/g')
kkonganti@11 28
kkonganti@11 29 head -n$skip "$file" > \$newfile
kkonganti@11 30 tail -n+\$(($skip + 1)) "$file" | sort -n | uniq >> \$newfile
kkonganti@11 31
kkonganti@11 32 if [ "\$newfile" == "iTOL_metadata_uniq.txt" ]; then
kkonganti@11 33 head -n3 "$file" | tail -n1 | sed -e 's/^FIELD_LABELS/ID/' > microreact_metadata.csv
kkonganti@11 34 tail -n+\$(($skip + 1)) "$file" | sort -n | uniq >> microreact_metadata.csv
kkonganti@11 35 fi
kkonganti@11 36
kkonganti@11 37 uniqver=""
kkonganti@11 38
kkonganti@11 39 if [ "${workflow.containerEngine}" != "null" ]; then
kkonganti@11 40 uniqver=\$( uniq --help 2>&1 | sed -e '1!d; s/ (.*\$//' )
kkonganti@11 41
kkonganti@11 42 else
kkonganti@11 43 uniqver=\$( uniq --version 2>&1 | sed '1!d; s/^.*(GNU coreutils//; s/) //;' )
kkonganti@11 44 fi
kkonganti@11 45
kkonganti@11 46 cat <<-END_VERSIONS > versions.yml
kkonganti@11 47 "${task.process}":
kkonganti@11 48 head: \$uniqver
kkonganti@11 49 tail: \$uniqver
kkonganti@11 50 sort: \$uniqver
kkonganti@11 51 uniq: \$uniqver
kkonganti@11 52 END_VERSIONS
kkonganti@11 53 """
kkonganti@11 54 }