comparison 0.2.0/modules/cat/unique/main.nf @ 11:a5f31c44f8c9

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