-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.nf
More file actions
205 lines (161 loc) · 4.53 KB
/
test.nf
File metadata and controls
205 lines (161 loc) · 4.53 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
#!/usr/bin/env nextflow
params.fqs = "$baseDir/test_data/**.gz"
params.transcriptome = "$baseDir/test_data/c.elegans.cdna.ncrna.fa"
params.output = "results"
params.multiqc = "$baseDir/multiqc"
params.fragment_len = '250'
params.fragment_sd = '50'
params.bootstrap = '100'
params.experiment = "$baseDir/experiment_info.txt"
params.email = ""
log.info """\
R N A S E Q - N F P I P E L I N E
===================================
transcriptome: ${ params.transcriptome }
fqs : ${ params.fqs }
output : ${ params.output }
fragment_len : ${ params.fragment_len }
fragment_sd : ${ params.fragment_sd }
bootstrap : ${ params.bootstrap }
experiment : ${ params.experiment }
email : ${ params.email }
"""
.stripIndent()
transcriptome_file = file(params.transcriptome)
multiqc_file = file(params.multiqc)
exp_file = file(params.experiment)
/*
* Make sure files exist
*/
if( !transcriptome_file.exists() ) exit 1, "Missing transcriptome file: ${transcriptome_file}"
if( !exp_file.exists() ) exit 1, "Missing Experiment parameters file: ${exp_file}"
Channel
.fromFilePairs( params.fqs, size: -1 )
.ifEmpty { error "Cannot find any reads matching: ${params.fqs}" }
.into { read_1_ch; read_2_ch; read_3_ch }
process qc_index {
tag "$transcriptome_file.simpleName"
input:
file transcriptome from transcriptome_file
output:
file 'index' into index_ch
"""
salmon index -t $transcriptome -i index
"""
}
process kal_index {
input:
file transcriptome_file
output:
file "transcriptome.index" into transcriptome_index
script:
"""
kallisto index -i transcriptome.index ${transcriptome_file}
"""
}
process kal_mapping {
tag "reads: $name"
input:
file index from transcriptome_index
set val(name), file(fq) from read_1_ch
output:
file "kallisto_${name}" into kallisto_out_dirs
script:
//
// Kallisto tools mapper
//
def single = fq instanceof Path
if( !single ){
"""
mkdir kallisto_${name}
kallisto quant --bootstrap ${params.bootstrap} -i ${index} -t ${task.cpus} -o kallisto_${name} ${fq}
"""
}
else {
"""
mkdir kallisto_${name}
kallisto quant --single -l ${params.fragment_len} -s ${params.fragment_sd} --bootstrap ${params.bootstrap} -i ${index} -t ${task.cpus} -o kallisto_${name} ${fq}
"""
}
}
process salmon_quant {
tag "${ name }"
input:
file index from index_ch
set val(name), file( fq ) from read_2_ch
output:
file("${name}_quant") into quant_ch
script:
def single = fq instanceof Path
if( !single ){
"""
salmon quant --libType=U -i index -1 ${fq[0]} -2 ${fq[1]} -o ${name}_quant
"""
}
else {
"""
salmon quant -i index -l U -r ${fq} -o ${name}_quant
"""
}
}
process fastqc {
tag "${ name }"
input:
set val(name), file(fq) from read_3_ch
output:
file("${name}_log") into fastqc_ch
script:
"""
mkdir -p ${name}_log
fastqc -o ${name}_log -f fastq -q ${fq}
"""
}
process multiqc {
input:
file('*') from quant_ch.mix(fastqc_ch).collect()
file(config) from multiqc_file
output:
file('multiqc_report.html')
script:
"""
cp $config/* .
echo "custom_logo: \$PWD/logo.png" >> multiqc_config.yaml
multiqc .
"""
}
process sleuth {
input:
file 'kallisto/*' from kallisto_out_dirs.collect()
file exp_file
output:
file 'sleuth_object.so'
script:
//
// Setup sleuth R dependancies and environment
//
"""
sleuth.R kallisto ${exp_file}
"""
}
workflow.onComplete {
summary = """
Pipeline execution summary
---------------------------
Completed at: ${workflow.complete}
Duration : ${workflow.duration}
Success : ${workflow.success}
workDir : ${workflow.workDir}
exit status : ${workflow.exitStatus}
Error report: ${workflow.errorReport ?: '-'}
"""
println summary
def outlog = new File("${params.output}/log.txt")
outlog.newWriter().withWriter {
outlog << param_summary
outlog << summary
}
// mail summary
if (params.email) {
['mail', '-s', 'SEmRNA-seq-nf', params.email].execute() << summary
}
}