-
Notifications
You must be signed in to change notification settings - Fork 105
/
rename_raw_data_files.nf
44 lines (38 loc) · 1.45 KB
/
rename_raw_data_files.nf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
process RENAME_RAW_DATA_FILES {
tag "$meta.id"
label 'process_low'
conda (params.enable_conda ? "conda-forge::sed=4.7" : null)
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/ubuntu:20.04' :
'ubuntu:20.04' }"
input:
tuple val(meta), path(reads)
output:
tuple val(meta), path("${meta.id}{_1,_2,}.fastq.gz", includeInputs: true), emit: fastq
path "versions.yml" , emit: versions
script:
// Add soft-links to original FastQs for consistent naming in pipeline
def args = task.ext.args ?: 'ln -s'
if (meta.single_end) {
"""
if [ ! -f ${meta.id}.fastq.gz ]; then
$args $reads ${meta.id}.fastq.gz
else
touch ${meta.id}.fastq.gz
fi
cat <<-END_VERSIONS > versions.yml
"${task.process}":
sed: \$(sed --version 2>&1 | sed -n 1p | sed 's/sed (GNU sed) //')
END_VERSIONS
"""
} else {
"""
[ -f "${meta.id}_1.fastq.gz" ] || $args "${reads[0]}" "${meta.id}_1.fastq.gz"
[ -f "${meta.id}_2.fastq.gz" ] || $args "${reads[1]}" "${meta.id}_2.fastq.gz"
cat <<-END_VERSIONS > versions.yml
"${task.process}":
sed: \$(sed --version 2>&1 | sed -n 1p | sed 's/sed (GNU sed) //')
END_VERSIONS
"""
}
}