comparison 0.5.0/modules/seqkit/grep/main.nf @ 0:97cd2f532efe

planemo upload
author kkonganti
date Mon, 31 Mar 2025 14:50:40 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:97cd2f532efe
1 process SEQKIT_GREP {
2 tag "$meta.id"
3 label 'process_low'
4
5 module (params.enable_module ? "${params.swmodulepath}${params.fs}seqkit${params.fs}2.2.0" : null)
6 conda (params.enable_conda ? "bioconda::seqkit=2.2.0 conda-forge::sed=4.7 conda-forge::coreutils" : null)
7 container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
8 'https://depot.galaxyproject.org/singularity/seqkit:2.1.0--h9ee0642_0':
9 'quay.io/biocontainers/seqkit:2.1.0--h9ee0642_0' }"
10
11 input:
12 tuple val(meta), path(reads), path(pattern_file)
13
14 output:
15 tuple val(meta), path("*.gz"), emit: fastx
16 path "versions.yml" , emit: versions
17
18 when:
19 task.ext.when == null || task.ext.when
20
21 script:
22 def args = task.ext.args ?: ''
23 def prefix = task.ext.prefix ?: "${meta.id}"
24 def num_read_files = reads.toList().size()
25 def extension = "fastq"
26 if ("$reads" ==~ /.+\.fasta|.+\.fasta.gz|.+\.fa|.+\.fa.gz|.+\.fas|.+\.fas.gz|.+\.fna|.+\.fna.gz/) {
27 extension = "fasta"
28 }
29
30 if (meta.single_end || num_read_files == 1) {
31 """
32 pattern_file_contents=\$(sed '1!d' $pattern_file)
33 if [ "\$pattern_file_contents" != "DuMmY" ]; then
34 cut -f1 -d " " $pattern_file > ${prefix}.seqids.txt
35 additional_args="-f ${prefix}.seqids.txt $args"
36 else
37 additional_args="$args"
38 fi
39
40 seqkit \\
41 grep \\
42 -j $task.cpus \\
43 -o ${prefix}.seqkit-grep.${extension}.gz \\
44 \$additional_args \\
45 $reads
46
47 cat <<-END_VERSIONS > versions.yml
48 "${task.process}":
49 seqkit: \$( seqkit | sed '3!d; s/Version: //' )
50 END_VERSIONS
51 """
52 } else {
53 """
54 pattern_file_contents=\$(sed '1!d' $pattern_file)
55 if [ "\$pattern_file_contents" != "DuMmY" ]; then
56 additional_args="-f $pattern_file $args"
57 else
58 additional_args="$args"
59 fi
60
61 seqkit \\
62 grep \\
63 -j $task.cpus \\
64 -o ${prefix}.R1.seqkit-grep.${extension}.gz \\
65 \$additional_args \\
66 ${reads[0]}
67
68 seqkit \\
69 grep \\
70 -j $task.cpus \\
71 -o ${prefix}.R2.seqkit-grep.${extension}.gz \\
72 \$additional_args \\
73 ${reads[1]}
74
75 seqkit \\
76 pair \\
77 -j $task.cpus \\
78 -1 ${prefix}.R1.seqkit-grep.${extension}.gz \\
79 -2 ${prefix}.R2.seqkit-grep.${extension}.gz
80
81 rm ${prefix}.R1.seqkit-grep.${extension}.gz
82 rm ${prefix}.R2.seqkit-grep.${extension}.gz
83
84 cat <<-END_VERSIONS > versions.yml
85 "${task.process}":
86 seqkit: \$( seqkit | sed '3!d; s/Version: //' )
87 END_VERSIONS
88 """
89 }
90 }