diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/0.2.0/modules/cat/unique/main.nf	Mon Jul 15 16:11:44 2024 -0400
@@ -0,0 +1,54 @@
+process CAT_UNIQUE {
+    tag "${meta.id}"
+    label "process_pico"
+
+    module (params.enable_module ? "${params.swmodulepath}${params.fs}perl${params.fs}5.30.0" : null)
+    conda (params.enable_conda ? "conda-forge::perl conda-forge::coreutils bioconda::perl-bioperl=1.7.8" : null)
+    container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
+        'https://depot.galaxyproject.org/singularity/perl-bioperl:1.7.8--hdfd78af_1' :
+        'quay.io/biocontainers/perl-bioperl:1.7.8--hdfd78af_1' }"
+
+    input:
+        tuple val(meta), path(file)
+
+    output:
+        path '*_uniq.txt'   , emit: txt
+        path '*metadata.csv', emit: csv, optional: true
+        path 'versions.yml' , emit: versions
+
+    when:
+        task.ext.when == null || task.ext.when
+
+    script:
+        def args = (task.ext.args ?: '')
+        def skip = (meta.skip_header ?: 1)
+        prefix = (task.ext.prefix ?: meta.id)
+        """
+        newfile=\$(echo "$file" | sed -e 's/_w_dups/_uniq/g')
+
+        head -n$skip "$file" > \$newfile
+        tail -n+\$(($skip + 1)) "$file" | sort -n | uniq >> \$newfile
+
+        if [ "\$newfile" == "iTOL_metadata_uniq.txt" ]; then
+            head -n3 "$file"  | tail -n1 | sed -e 's/^FIELD_LABELS/ID/' > microreact_metadata.csv
+            tail -n+\$(($skip + 1)) "$file" | sort -n | uniq >> microreact_metadata.csv
+        fi
+
+        uniqver=""
+
+        if [ "${workflow.containerEngine}" != "null" ]; then
+            uniqver=\$( uniq --help 2>&1 | sed -e '1!d; s/ (.*\$//' )
+            
+        else
+            uniqver=\$( uniq --version 2>&1 | sed '1!d; s/^.*(GNU coreutils//; s/) //;' )
+        fi
+
+        cat <<-END_VERSIONS > versions.yml
+        "${task.process}": 
+            head: \$uniqver
+            tail: \$uniqver
+            sort: \$uniqver
+            uniq: \$uniqver
+        END_VERSIONS
+        """
+}
\ No newline at end of file