-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparapipe.nf
207 lines (170 loc) · 6.18 KB
/
parapipe.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
195
196
197
198
199
200
201
202
203
204
205
206
207
#!/usr/bin/env nextflow
// enable dsl2
nextflow.enable.dsl=2
// import modules
include {printHelp} from './modules/help.nf'
include {captureEnv} from './modules/captureEnv.nf'
include {prepRef} from './workflows/prepref.nf'
include {preprocessing} from './workflows/preprocessing.nf'
include {phyloMOI} from './workflows/phyloMOI.nf'
/*
ANSI escape codes to allow colour-coded output messages
This code is from https://github.com/angelovangel
*/
ANSI_GREEN = "\033[1;32m"
ANSI_RED = "\033[1;31m"
ANSI_RESET = "\033[0m"
params.help = ""
if (params.help) {
printHelp()
exit(0)
}
// check mandatory parameters
if ( params.input_dir == null ) {
exit 1, "error: please provide an --input_dir argument. Use --help for an explenation for the parameters."
}
if ( params.output_dir == null ) {
exit 1, "error: please provide an --output_dir argument. Use --help for an explenation for the parameters."
}
if ( params.ref == null ) {
exit 1, "error: please provide a --ref argument. Use --help for an explenation for the parameters."
}
if ( params.pattern == null ) {
exit 1, "error: please provide a --pattern argument. Use --help for an explenation for the parameters."
}
// initialise default parameters
if ( params.yaml == null ) {
yaml = "false"
}
else {
yaml = params.yaml
}
if ( params.read_n_threshold == null ) {
read_n_threshold = 1000000
}
else {
read_n_threshold = params.read_n_threshold
}
if ( params.database == null ) {
database = "/false/"
}
else {
database = params.database
}
if ( params.mincov == null ) {
mincov = 0.8
}
else {
mincov = params.mincov
}
if ( params.missing == null ) {
missing = 0.1
}
else {
missing = params.missing
}
if ( params.maf == null ) {
maf = 0.05
}
else {
maf = params.maf
}
if ( params.mac == null ) {
mac = 5
}
else {
mac = params.mac
}
log.info """
===================================================================================================
██████╗░░█████╗░██████╗░░█████╗░██████╗░██╗██████╗░███████╗
██╔══██╗██╔══██╗██╔══██╗██╔══██╗██╔══██╗██║██╔══██╗██╔════╝
██████╔╝███████║██████╔╝███████║██████╔╝██║██████╔╝█████╗░░
██╔═══╝░██╔══██║██╔══██╗██╔══██║██╔═══╝░██║██╔═══╝░██╔══╝░░
██║░░░░░██║░░██║██║░░██║██║░░██║██║░░░░░██║██║░░░░░███████╗
╚═╝░░░░░╚═╝░░╚═╝╚═╝░░╚═╝╚═╝░░╚═╝╚═╝░░░░░╚═╝╚═╝░░░░░╚══════╝
===================================================================================================
Parameters used:
---------------------------------------------------------------------------------------------------
--input_dir ${params.input_dir}
--output_dir ${params.output_dir}
--ref ${params.ref}
--pattern ${params.pattern}
--read_n_threshold ${read_n_threshold}
--yaml ${yaml}
--database ${database}
--mincov ${mincov}
--missing ${missing}
--maf ${maf}
--mac ${mac}
Runtime data:
---------------------------------------------------------------------------------------------------
Profile ${workflow.profile}
User ${workflow.userName}
Launch dir ${workflow.launchDir}
"""
.stripIndent()
// main pipeline workflow
workflow {
pattern = params.pattern
reads = params.input_dir + pattern
numfiles = file(reads) // count the number of files
Channel.fromFilePairs(reads, flat: true, checkIfExists: true, size: -1)
.ifEmpty { error "cannot find any files matching ${pattern} in ${params.input_dir}" }
.set{ input_files }
main:
/************************************************
* ENV CAPTURE START *
*************************************************/
captureEnv( params.input_dir, \
params.output_dir, \
params.ref, \
yaml, \
database, \
params.read_n_threshold, \
mincov, \
missing, \
maf, \
mac )
/************************************************
* PREPREF WORKFLOW START *
*************************************************/
prepRef(params.ref)
/************************************************
* PREPROCESSING WORKFLOW START *
*************************************************/
preprocessing( input_files, \
prepRef.out.ref_bt2index, \
read_n_threshold )
/************************************************
* PARAPIPE SNP AND MOI WORKFLOW START *
*************************************************/
phyloMOI( input_files, \
captureEnv.out.env_json, \
database, \
preprocessing.out.bam_pre, \
prepRef.out.refdata, \
params.ref, \
preprocessing.out.multiQC_report, \
yaml, \
mincov, \
missing, \
maf, \
mac )
}
workflow.onComplete {
if ( workflow.success ) {
log.info """
============================================
${ANSI_GREEN}PARAPIPE completed successfully
"""
.stripIndent()
}
else {
log.info """
===========================================
${ANSI_RED}Finished with errors${ANSI_RESET}
"""
.stripIndent()
}
}