This repository has been archived by the owner on Oct 5, 2018. It is now read-only.
forked from nf-core/rnafusion
-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.nf
194 lines (158 loc) · 4.86 KB
/
main.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
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
#!/usr/bin/env nextflow
/*
vim: syntax=groovy
-*- mode: groovy;-*-
========================================================================================
N G I - R N A S E Q F U S I O N D E T E C T
========================================================================================
New RNA-Seq Best Practice Analysis Pipeline. Started May 2017.
#### Homepage / Documentation
https://github.com/SciLifeLab/NGI-RNAfusion
#### Authors
Rickard Hammarén @Hammarn <[email protected]>
Philip Ewels @ewels <[email protected]>
*/
/*
* SET UP CONFIGURATION VARIABLES
*/
// Pipeline version
version = '0.1'
// Configurable variables - same as NGI-RNAseq for now
params.project = false
params.reads = "data/*{1,2}.fastq"
params.email = false
params.star_fusion = true
params.inspector = true
params.fusioncatcher = true
params.clusterOptions = true
params.outdir = './results'
params.fc_extra_options = ''
params.singleEnd = false
Channel
.fromFilePairs( params.reads, size: params.singleEnd ? 1 : 2 )
.ifEmpty { exit 1, "Cannot find any reads matching: ${params.reads}" }
.into { read_files_star_fusion; fusion_inspector_reads; fusioncatcher_reads}
// Validate inputs
if( params.star_fusion_reference && params.star_fusion ){
Channel.fromPath(params.star_fusion_reference)
.ifEmpty { exit 1, "STAR-fusion reference not found: ${params.star_fusion_reference}" }
.into { star_fusion_reference; star_fusion_reference_fusioninspector }
}
if( params.fusioncatcher_data_dir && params.fusioncatcher ){
fusioncatcher_data_dir = Channel
.fromPath(params.fusioncatcher_data_dir)
.ifEmpty { exit 1, "FusionCatcher data directory not found: ${params.fusioncatcher_data_dir}" }
}
/*
* STAR-Fusion
*/
process star_fusion{
tag "$name"
publishDir "${params.outdir}/Star_fusion", mode: 'copy'
// module 'bioinfo-tools'
// module 'star-fusion/1.2.0'
// module 'samtools/1.5'
input:
set val (name), file(reads) from read_files_star_fusion
file star_fusion_reference from star_fusion_reference.collect()
output:
file '*abridged.tsv' into star_fusion_abridged
file '*abridged.tsv' into fusion_candidates,fusion_candidates_list
when: params.star_fusion
script:
"""
STAR-Fusion \\
--genome_lib_dir ${star_fusion_reference}\\
--left_fq ${reads[0]} \\
--right_fq ${reads[1]} \\
--CPU ${task.cpus} \\
--output_dir .
"""
}
/*
* Fusion Catcher
*/
// Requires raw untrimmed files. FastQ files should not be merged!
process fusioncatcher {
tag "$name"
publishDir "${params.outdir}/FusionCatcher", mode: 'copy'
// module 'bioinfo-tools'
// module 'FusionCatcher'
input:
set val (name), file(reads) from fusioncatcher_reads
file fusioncatcher_data_dir from fusioncatcher_data_dir.collect()
output:
file '*.{txt,log,zip}' into fusioncatcher
when: params.fusioncatcher
script:
if (params.singleEnd) {
"""
mkdir ${reads}_data
mv ${reads} ${reads}_data/
fusioncatcher \\
-d $fusioncatcher_data_dir \\
-i ${reads}_data \\
--threads ${task.cpus} \\
-o $name \\
--skip-blat \\
--single-end \\
${params.fc_extra_options}
"""
} else {
"""
fusioncatcher \\
-d $fusioncatcher_data_dir \\
-i ${reads[0]},${reads[1]} \\
--threads ${task.cpus} \\
-o . \\
--skip-blat \\
${params.fc_extra_options}
"""
}
}
process fusion_genes_compare {
tag "$name"
publishDir "${params.outdir}/Comparative_shortlist", mode: 'copy'
input:
file ('*star_fusion.fusion_candidates.final.abridged') from fusion_candidates_list.collect()
file ('*summary_candidate_fusions.txt') from fusioncatcher.collect()
output:
file '*fusion_comparison.txt'
when: params.star_fusion && params.inspector
script:
"""
fusion_genes_compare.py *
"""
}
/*
* - FusionInspector
*/
process fusioninspector {
tag "$name"
publishDir "${params.outdir}/FusionInspector", mode: 'copy'
// module 'bioinfo-tools'
// module 'star-fusion/1.2.0'
// module 'trinity/2014-07-17'
// module 'samtools/1.5'
// module 'htslib/1.5'
// module 'perl_modules'
input:
set val (name), file(reads) from fusion_inspector_reads
file fusion_candidates
file star_fusion_reference from star_fusion_reference_fusioninspector.collect()
output:
file '*' into fusioninspector_results
when: params.inspector
script:
"""
FusionInspector \\
--fusions $fusion_candidates \\
--genome_lib $star_fusion_reference \\
--left_fq ${reads[0]} \\
--right_fq ${reads[1]} \\
--CPU ${task.cpus} \\
--out_dir . \\
--out_prefix finspector \\
--prep_for_IGV
"""
}