annotate 0.4.0/modules/cat/fastq/main.nf @ 101:ce6d9548fe89

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