forked from nf-core/modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.nf
More file actions
91 lines (84 loc) · 3.67 KB
/
Copy pathmain.nf
File metadata and controls
91 lines (84 loc) · 3.67 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
process TRIMGALORE {
tag "${meta.id}"
label 'process_high'
conda "${moduleDir}/environment.yml"
container "${workflow.containerEngine in ['singularity', 'apptainer'] && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/trim-galore:0.6.10--hdfd78af_2' :
'quay.io/biocontainers/trim-galore:0.6.10--hdfd78af_2'}"
input:
tuple val(meta), path(reads)
output:
// Two `reads_*` emits with positive-only patterns covering every trim_galore
// output mode (default trim, --hardtrim5, --hardtrim3). PE per-mate intermediates
// (`${prefix}_<N>_trimmed.fq.gz`) deliberately match neither pattern, so an
// incomplete unlink of those files on retry can't leak into either channel.
tuple val(meta), path("${prefix}{_trimmed,.*bp_3prime,.*bp_5prime}.fq.gz") , emit: reads_se, optional: true
tuple val(meta), path("${prefix}_*{_val_1,_val_2,bp_3prime,bp_5prime}.fq.gz") , emit: reads_pe, optional: true
tuple val(meta), path("*report.txt") , emit: log , optional: true
tuple val(meta), path("*unpaired{,_1,_2}.fq.gz") , emit: unpaired, optional: true
tuple val(meta), path("*.html") , emit: html , optional: true
tuple val(meta), path("*.zip") , emit: zip , optional: true
tuple val("${task.process}"), val("trimgalore"), eval('trim_galore --version | grep -Eo "[0-9]+(\\.[0-9]+)+"'), topic: versions, emit: versions_trimgalore
when:
task.ext.when == null || task.ext.when
script:
def args = task.ext.args ?: ''
// Calculate number of --cores for TrimGalore based on value of task.cpus
// See: https://github.com/FelixKrueger/TrimGalore/blob/master/CHANGELOG.md#version-060-release-on-1-mar-2019
// See: https://github.com/nf-core/atacseq/pull/65
def cores = 1
if (task.cpus) {
cores = (task.cpus as int) - 4
if (meta.single_end) {
cores = (task.cpus as int) - 3
}
if (cores < 1) {
cores = 1
}
if (cores > 8) {
cores = 8
}
}
// Added soft-links to original fastqs for consistent naming in MultiQC
prefix = task.ext.prefix ?: "${meta.id}"
if (meta.single_end) {
def args_list = args.split("\\s(?=--)").toList()
args_list.removeAll { arg -> arg.toLowerCase().contains('_r2 ') }
"""
[ ! -f ${prefix}.fastq.gz ] && ln -s ${reads} ${prefix}.fastq.gz
trim_galore \\
${args_list.join(' ')} \\
--cores ${cores} \\
--gzip \\
${prefix}.fastq.gz
"""
}
else {
"""
[ ! -f ${prefix}_1.fastq.gz ] && ln -s ${reads[0]} ${prefix}_1.fastq.gz
[ ! -f ${prefix}_2.fastq.gz ] && ln -s ${reads[1]} ${prefix}_2.fastq.gz
trim_galore \\
${args} \\
--cores ${cores} \\
--paired \\
--gzip \\
${prefix}_1.fastq.gz \\
${prefix}_2.fastq.gz
"""
}
stub:
prefix = task.ext.prefix ?: "${meta.id}"
if (meta.single_end) {
output_command = "echo '' | gzip > ${prefix}_trimmed.fq.gz ;"
output_command += "touch ${prefix}.fastq.gz_trimming_report.txt"
}
else {
output_command = "echo '' | gzip > ${prefix}_1_val_1.fq.gz ;"
output_command += "touch ${prefix}_1.fastq.gz_trimming_report.txt ;"
output_command += "echo '' | gzip > ${prefix}_2_val_2.fq.gz ;"
output_command += "touch ${prefix}_2.fastq.gz_trimming_report.txt"
}
"""
${output_command}
"""
}