2021-02-12 16:22:07 +00:00
|
|
|
process CAT_FASTQ {
|
|
|
|
tag "$meta.id"
|
2021-03-16 17:16:47 +00:00
|
|
|
label 'process_low'
|
2021-02-12 16:22:07 +00:00
|
|
|
|
2021-02-16 23:58:23 +00:00
|
|
|
conda (params.enable_conda ? "conda-forge::sed=4.7" : null)
|
2021-11-26 07:58:40 +00:00
|
|
|
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
|
|
|
|
'https://containers.biocontainers.pro/s3/SingImgsRepo/biocontainers/v1.2.0_cv1/biocontainers_v1.2.0_cv1.img' :
|
|
|
|
'biocontainers/biocontainers:v1.2.0_cv1' }"
|
2021-02-12 16:22:07 +00:00
|
|
|
|
|
|
|
input:
|
|
|
|
tuple val(meta), path(reads)
|
|
|
|
|
|
|
|
output:
|
|
|
|
tuple val(meta), path("*.merged.fastq.gz"), emit: reads
|
2021-10-01 13:04:56 +00:00
|
|
|
path "versions.yml" , emit: versions
|
2021-02-12 16:22:07 +00:00
|
|
|
|
|
|
|
script:
|
2021-11-26 07:58:40 +00:00
|
|
|
def args = task.ext.args ?: ''
|
2021-12-02 12:39:55 +00:00
|
|
|
def prefix = task.ext.prefix ?: "${meta.id}"
|
2021-02-12 16:22:07 +00:00
|
|
|
def readList = reads.collect{ it.toString() }
|
|
|
|
if (meta.single_end) {
|
|
|
|
if (readList.size > 1) {
|
|
|
|
"""
|
|
|
|
cat ${readList.sort().join(' ')} > ${prefix}.merged.fastq.gz
|
2021-09-28 20:14:11 +00:00
|
|
|
|
|
|
|
cat <<-END_VERSIONS > versions.yml
|
2021-11-26 07:58:40 +00:00
|
|
|
"${task.process}":
|
|
|
|
cat: \$(echo \$(cat --version 2>&1) | sed 's/^.*coreutils) //; s/ .*\$//')
|
2021-09-28 20:14:11 +00:00
|
|
|
END_VERSIONS
|
2021-02-12 16:22:07 +00:00
|
|
|
"""
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (readList.size > 2) {
|
|
|
|
def read1 = []
|
|
|
|
def read2 = []
|
|
|
|
readList.eachWithIndex{ v, ix -> ( ix & 1 ? read2 : read1 ) << v }
|
|
|
|
"""
|
|
|
|
cat ${read1.sort().join(' ')} > ${prefix}_1.merged.fastq.gz
|
|
|
|
cat ${read2.sort().join(' ')} > ${prefix}_2.merged.fastq.gz
|
2021-09-28 20:14:11 +00:00
|
|
|
|
|
|
|
cat <<-END_VERSIONS > versions.yml
|
2021-11-26 07:58:40 +00:00
|
|
|
"${task.process}":
|
|
|
|
cat: \$(echo \$(cat --version 2>&1) | sed 's/^.*coreutils) //; s/ .*\$//')
|
2021-09-28 20:14:11 +00:00
|
|
|
END_VERSIONS
|
2021-02-12 16:22:07 +00:00
|
|
|
"""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|