2021-02-12 16:22:07 +00:00
|
|
|
process CAT_FASTQ {
|
|
|
|
tag "$meta.id"
|
2022-09-19 09:54:47 +00:00
|
|
|
label 'process_single'
|
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 ?
|
2022-04-22 13:50:07 +00:00
|
|
|
'https://depot.galaxyproject.org/singularity/ubuntu:20.04' :
|
|
|
|
'ubuntu:20.04' }"
|
2021-02-12 16:22:07 +00:00
|
|
|
|
|
|
|
input:
|
2021-12-13 19:18:27 +00:00
|
|
|
tuple val(meta), path(reads, stageAs: "input*/*")
|
2021-02-12 16:22:07 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2022-02-04 08:53:32 +00:00
|
|
|
when:
|
|
|
|
task.ext.when == null || task.ext.when
|
|
|
|
|
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}"
|
2022-09-28 12:28:52 +00:00
|
|
|
def readList = reads instanceof List ? reads.collect{ it.toString() } : [reads.toString()]
|
2021-02-12 16:22:07 +00:00
|
|
|
if (meta.single_end) {
|
2022-09-20 12:46:01 +00:00
|
|
|
if (readList.size >= 1) {
|
2021-02-12 16:22:07 +00:00
|
|
|
"""
|
2021-12-13 19:18:27 +00:00
|
|
|
cat ${readList.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 {
|
2022-09-20 12:46:01 +00:00
|
|
|
if (readList.size >= 2) {
|
2021-02-12 16:22:07 +00:00
|
|
|
def read1 = []
|
|
|
|
def read2 = []
|
|
|
|
readList.eachWithIndex{ v, ix -> ( ix & 1 ? read2 : read1 ) << v }
|
|
|
|
"""
|
2021-12-13 19:18:27 +00:00
|
|
|
cat ${read1.join(' ')} > ${prefix}_1.merged.fastq.gz
|
|
|
|
cat ${read2.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
|
|
|
"""
|
|
|
|
}
|
|
|
|
}
|
2022-08-09 07:18:37 +00:00
|
|
|
|
|
|
|
stub:
|
|
|
|
def prefix = task.ext.prefix ?: "${meta.id}"
|
2022-09-28 12:28:52 +00:00
|
|
|
def readList = reads instanceof List ? reads.collect{ it.toString() } : [reads.toString()]
|
2022-08-09 07:18:37 +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
|
|
|
|
"""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-12 16:22:07 +00:00
|
|
|
}
|