annotate 0.5.0/modules/cat/fastq/main.nf @ 0:97cd2f532efe

planemo upload
author kkonganti
date Mon, 31 Mar 2025 14:50:40 -0400
parents
children
rev   line source
kkonganti@0 1 process CAT_FASTQ {
kkonganti@0 2 tag "$meta.id"
kkonganti@0 3 label 'process_micro'
kkonganti@0 4
kkonganti@0 5 conda (params.enable_conda ? "conda-forge::sed=4.7 conda-forge::gzip" : null)
kkonganti@0 6 container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
kkonganti@0 7 'https://containers.biocontainers.pro/s3/SingImgsRepo/biocontainers/v1.2.0_cv1/biocontainers_v1.2.0_cv1.img' :
kkonganti@0 8 'biocontainers/biocontainers:v1.2.0_cv1' }"
kkonganti@0 9
kkonganti@0 10 input:
kkonganti@0 11 tuple val(meta), path(reads, stageAs: "input*/*")
kkonganti@0 12
kkonganti@0 13 output:
kkonganti@0 14 tuple val(meta), path("*.merged.fastq.gz"), emit: catted_reads
kkonganti@0 15 path "versions.yml" , emit: versions
kkonganti@0 16
kkonganti@0 17 when:
kkonganti@0 18 task.ext.when == null || task.ext.when
kkonganti@0 19
kkonganti@0 20 script:
kkonganti@0 21 def args = task.ext.args ?: ''
kkonganti@0 22 def prefix = task.ext.prefix ?: "${meta.id}"
kkonganti@0 23 def readList = reads.collect{ it.toString() }
kkonganti@0 24 def is_in_gz = readList[0].endsWith('.gz')
kkonganti@0 25 def gz_or_ungz = (is_in_gz ? '' : ' | gzip')
kkonganti@0 26 def pigz_or_ungz = (is_in_gz ? '' : " | pigz -p ${task.cpus}")
kkonganti@0 27 if (meta.single_end) {
kkonganti@0 28 if (readList.size > 1) {
kkonganti@0 29 """
kkonganti@0 30 zcmd="gzip"
kkonganti@0 31 zver=""
kkonganti@0 32
kkonganti@0 33 if type pigz > /dev/null 2>&1; then
kkonganti@0 34 cat ${readList.join(' ')} ${pigz_or_ungz} > ${prefix}.merged.fastq.gz
kkonganti@0 35 zcmd="pigz"
kkonganti@0 36 zver=\$( echo \$( \$zcmd --version 2>&1 ) | sed -e '1!d' | sed "s/\$zcmd //" )
kkonganti@0 37 else
kkonganti@0 38 cat ${readList.join(' ')} ${gz_or_ungz} > ${prefix}.merged.fastq.gz
kkonganti@0 39 zcmd="gzip"
kkonganti@0 40
kkonganti@0 41 if [ "${workflow.containerEngine}" != "null" ]; then
kkonganti@0 42 zver=\$( echo \$( \$zcmd --help 2>&1 ) | sed -e '1!d; s/ (.*\$//' )
kkonganti@0 43 else
kkonganti@0 44 zver=\$( echo \$( \$zcmd --version 2>&1 ) | sed "s/^.*(\$zcmd) //; s/\$zcmd //; s/ Copyright.*\$//" )
kkonganti@0 45 fi
kkonganti@0 46 fi
kkonganti@0 47
kkonganti@0 48 cat <<-END_VERSIONS > versions.yml
kkonganti@0 49 "${task.process}":
kkonganti@0 50 cat: \$( echo \$(cat --version 2>&1) | sed 's/^.*coreutils) //; s/ .*\$//' )
kkonganti@0 51 \$zcmd: \$zver
kkonganti@0 52 END_VERSIONS
kkonganti@0 53 """
kkonganti@0 54 }
kkonganti@0 55 } else {
kkonganti@0 56 if (readList.size > 2) {
kkonganti@0 57 def read1 = []
kkonganti@0 58 def read2 = []
kkonganti@0 59 readList.eachWithIndex{ v, ix -> ( ix & 1 ? read2 : read1 ) << v }
kkonganti@0 60 """
kkonganti@0 61 zcmd="gzip"
kkonganti@0 62 zver=""
kkonganti@0 63
kkonganti@0 64 if type pigz > /dev/null 2>&1; then
kkonganti@0 65 cat ${read1.join(' ')} ${pigz_or_ungz} > ${prefix}_1.merged.fastq.gz
kkonganti@0 66 cat ${read2.join(' ')} ${pigz_or_ungz} > ${prefix}_2.merged.fastq.gz
kkonganti@0 67 zcmd="pigz"
kkonganti@0 68 zver=\$( echo \$( \$zcmd --version 2>&1 ) | sed -e '1!d' | sed "s/\$zcmd //" )
kkonganti@0 69 else
kkonganti@0 70 cat ${read1.join(' ')} ${gz_or_ungz} > ${prefix}_1.merged.fastq.gz
kkonganti@0 71 cat ${read2.join(' ')} ${gz_or_ungz} > ${prefix}_2.merged.fastq.gz
kkonganti@0 72 zcmd="gzip"
kkonganti@0 73
kkonganti@0 74 if [ "${workflow.containerEngine}" != "null" ]; then
kkonganti@0 75 zver=\$( echo \$( \$zcmd --help 2>&1 ) | sed -e '1!d; s/ (.*\$//' )
kkonganti@0 76 else
kkonganti@0 77 zver=\$( echo \$( \$zcmd --version 2>&1 ) | sed "s/^.*(\$zcmd) //; s/\$zcmd //; s/ Copyright.*\$//" )
kkonganti@0 78 fi
kkonganti@0 79 fi
kkonganti@0 80
kkonganti@0 81 cat <<-END_VERSIONS > versions.yml
kkonganti@0 82 "${task.process}":
kkonganti@0 83 cat: \$( echo \$(cat --version 2>&1) | sed 's/^.*coreutils) //; s/ .*\$//' )
kkonganti@0 84 \$zcmd: \$zver
kkonganti@0 85 END_VERSIONS
kkonganti@0 86 """
kkonganti@0 87 }
kkonganti@0 88 }
kkonganti@0 89 }