2022-02-18 15:51:01 +00:00
|
|
|
process CAT_FASTQ {
|
|
|
|
tag "$meta.id"
|
2022-10-05 10:24:18 +00:00
|
|
|
label 'process_single'
|
2022-02-18 15:51:01 +00:00
|
|
|
|
2022-12-23 16:23:05 +00:00
|
|
|
conda "conda-forge::sed=4.7"
|
2022-02-18 15:51:01 +00:00
|
|
|
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
|
2022-09-08 06:08:36 +00:00
|
|
|
'https://depot.galaxyproject.org/singularity/ubuntu:20.04' :
|
|
|
|
'ubuntu:20.04' }"
|
2022-02-18 15:51:01 +00:00
|
|
|
|
|
|
|
input:
|
|
|
|
tuple val(meta), path(reads, stageAs: "input*/*")
|
|
|
|
|
|
|
|
output:
|
|
|
|
tuple val(meta), path("*.merged.fastq.gz"), emit: reads
|
|
|
|
path "versions.yml" , emit: versions
|
|
|
|
|
|
|
|
when:
|
|
|
|
task.ext.when == null || task.ext.when
|
|
|
|
|
|
|
|
script:
|
|
|
|
def args = task.ext.args ?: ''
|
|
|
|
def prefix = task.ext.prefix ?: "${meta.id}"
|
2022-10-05 10:24:18 +00:00
|
|
|
def readList = reads instanceof List ? reads.collect{ it.toString() } : [reads.toString()]
|
2022-02-18 15:51:01 +00:00
|
|
|
if (meta.single_end) {
|
2022-10-05 10:24:18 +00:00
|
|
|
if (readList.size >= 1) {
|
2022-02-18 15:51:01 +00:00
|
|
|
"""
|
|
|
|
cat ${readList.join(' ')} > ${prefix}.merged.fastq.gz
|
|
|
|
|
|
|
|
cat <<-END_VERSIONS > versions.yml
|
|
|
|
"${task.process}":
|
|
|
|
cat: \$(echo \$(cat --version 2>&1) | sed 's/^.*coreutils) //; s/ .*\$//')
|
|
|
|
END_VERSIONS
|
|
|
|
"""
|
|
|
|
}
|
|
|
|
} else {
|
2022-10-05 10:24:18 +00:00
|
|
|
if (readList.size >= 2) {
|
2022-02-18 15:51:01 +00:00
|
|
|
def read1 = []
|
|
|
|
def read2 = []
|
|
|
|
readList.eachWithIndex{ v, ix -> ( ix & 1 ? read2 : read1 ) << v }
|
|
|
|
"""
|
|
|
|
cat ${read1.join(' ')} > ${prefix}_1.merged.fastq.gz
|
|
|
|
cat ${read2.join(' ')} > ${prefix}_2.merged.fastq.gz
|
|
|
|
|
|
|
|
cat <<-END_VERSIONS > versions.yml
|
|
|
|
"${task.process}":
|
|
|
|
cat: \$(echo \$(cat --version 2>&1) | sed 's/^.*coreutils) //; s/ .*\$//')
|
|
|
|
END_VERSIONS
|
|
|
|
"""
|
|
|
|
}
|
|
|
|
}
|
2022-09-08 06:08:36 +00:00
|
|
|
|
|
|
|
stub:
|
|
|
|
def prefix = task.ext.prefix ?: "${meta.id}"
|
2022-10-05 10:24:18 +00:00
|
|
|
def readList = reads instanceof List ? reads.collect{ it.toString() } : [reads.toString()]
|
2022-09-08 06:08:36 +00:00
|
|
|
if (meta.single_end) {
|
|
|
|
if (readList.size > 1) {
|
|
|
|
"""
|
|
|
|
touch ${prefix}.merged.fastq.gz
|
|
|
|
|
|
|
|
cat <<-END_VERSIONS > versions.yml
|
|
|
|
"${task.process}":
|
|
|
|
cat: \$(echo \$(cat --version 2>&1) | sed 's/^.*coreutils) //; s/ .*\$//')
|
|
|
|
END_VERSIONS
|
|
|
|
"""
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (readList.size > 2) {
|
|
|
|
"""
|
|
|
|
touch ${prefix}_1.merged.fastq.gz
|
|
|
|
touch ${prefix}_2.merged.fastq.gz
|
|
|
|
|
|
|
|
cat <<-END_VERSIONS > versions.yml
|
|
|
|
"${task.process}":
|
|
|
|
cat: \$(echo \$(cat --version 2>&1) | sed 's/^.*coreutils) //; s/ .*\$//')
|
|
|
|
END_VERSIONS
|
|
|
|
"""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-18 15:51:01 +00:00
|
|
|
}
|