-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtreeval.nf
More file actions
executable file
·351 lines (299 loc) · 12.3 KB
/
treeval.nf
File metadata and controls
executable file
·351 lines (299 loc) · 12.3 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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
IMPORT MODULES / SUBWORKFLOWS / FUNCTIONS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
IMPORT LOCAL MODULES/SUBWORKFLOWS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
//
// IMPORT: SUBWORKFLOWS CALLED BY THE MAIN
//
include { GENERATE_GENOME } from '../subworkflows/local/generate_genome'
include { INSILICO_DIGEST } from '../subworkflows/local/insilico_digest'
include { GENE_ALIGNMENT } from '../subworkflows/local/gene_alignment'
include { SELFCOMP } from '../subworkflows/local/selfcomp'
include { SYNTENY } from '../subworkflows/local/synteny'
include { READ_COVERAGE } from '../subworkflows/local/read_coverage'
include { REPEAT_DENSITY } from '../subworkflows/local/repeat_density'
include { GAP_FINDER } from '../subworkflows/local/gap_finder'
include { TELO_FINDER } from '../subworkflows/local/telo_finder'
include { BUSCO_ANNOTATION } from '../subworkflows/local/busco_annotation'
include { HIC_MAPPING } from '../subworkflows/local/hic_mapping'
include { KMER } from '../subworkflows/local/kmer'
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
IMPORT NF-CORE MODULES/SUBWORKFLOWS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
//
// IMPORT: Installed directly from nf-core/modules
//
include { paramsSummaryMap } from 'plugin/nf-schema'
include { softwareVersionsToYAML } from '../subworkflows/nf-core/utils_nfcore_pipeline'
include { methodsDescriptionText } from '../subworkflows/local/utils_nfcore_treeval_pipeline'
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
RUN MAIN WORKFLOW
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
workflow TREEVAL {
take:
assembly_id // channel:
reference // channel:
map_order // channel: hic mapping order (from yaml)
assem_reads // channel: path to longreads directory (from yaml)
kmer_prof_file // channel:
hic_reads // channel: path to hic reads directory (from yaml)
supp_reads // channel:
align_genesets // channel: paths to genesets in from yaml
synteny_paths // channel: path to syntenic genomes (from yaml)
intron_size // channel:
teloseq // channel: telomere motif sequence (from yaml)
lineageinfo // channel:
lineagespath // channel:
main:
//
// PRE-PIPELINE CHANNEL SETTING - channel setting for required files
//
ch_versions = Channel.empty()
exclude_steps_list = params.steps == "NONE" ? [] : params.steps.tokenize(',').collect { it.trim() }
all_steps_list = ["insilico_digest", "gene_alignment", "repeat_density", "gap_finder", "selfcomp", "synteny", "read_coverage", "telo_finder", "busco", "kmer", "hic_mapping", "NONE"]
jbrowse_include_list = ["insilico_digest", "gene_alignment", "selfcomp", "synteny", "busco", "kmer"]
combined_include_list = ["insilico_digest", "repeat_density", "gap_finder", "synteny", "read_coverage", "telo_finder", "busco", "kmer", "hic_mapping"]
rapid_include_list = ["repeat_density", "gap_finder", "read_coverage", "telo_finder", "hic_mapping", "kmer"]
// Map of mode to corresponding include list for cleaner logic
mode_include_map = [
"JBROWSE" : jbrowse_include_list,
"RAPID" : rapid_include_list,
"RAPID_TOL" : rapid_include_list,
"FULL_COMBINED" : combined_include_list
]
//
// Determine workflow steps based on run mode
// Take processes from the mode's include list, remove any CLI excluded steps
//
include_workflow_steps = mode_include_map.containsKey(params.mode) ?
(mode_include_map[params.mode] - exclude_steps_list).unique() :
(all_steps_list - exclude_steps_list).unique()
// This acts as a "double check" for the user
log.info "[Treeval: Info] PROCESSES TO RUN INCLUDE: $include_workflow_steps"
// Validate that all requested steps are valid
invalid_steps = exclude_steps_list - all_steps_list
if (invalid_steps) {
log.error "[Treeval: Error] Invalid step(s) specified in --steps: ${invalid_steps.join(", ")}"
log.error "[Treeval: Error] Valid options are: ${all_steps_list.join(", ")}"
System.exit(1)
}
// Validate that include_workflow_steps contains only valid steps (safety check)
invalid_include_steps = include_workflow_steps - all_steps_list
if (invalid_include_steps) {
log.error "[Treeval: Error] Internal error - invalid workflow steps detected: ${invalid_include_steps.join(", ")}"
System.exit(1)
}
//
// ASSET CHANNELS: Set up channels for required asset files
//
Channel
.fromPath( "${projectDir}/assets/gene_alignment/assm_*.as", checkIfExists: true)
.map { as_file ->
tuple (
[ type : as_file.baseName.split('_').last() ],
as_file
)
}
.set { gene_alignment_asfiles }
Channel
.fromPath( "${projectDir}/assets/digest/digest.as", checkIfExists: true )
.set { digest_asfile }
Channel
.fromPath( "${projectDir}/assets/self_comp/selfcomp.as", checkIfExists: true )
.set { selfcomp_asfile }
Channel
.fromPath( "${projectDir}/assets/busco_gene/busco.as", checkIfExists: true )
.set { buscogene_asfile }
Channel
.fromPath( "${projectDir}/assets/busco_gene/lep_ancestral.tsv", checkIfExists: true )
.set { ancestral_table }
//
// SUBWORKFLOW: Takes input fasta file and sample ID to generate a my.genome file
//
GENERATE_GENOME (
reference,
map_order
)
ch_versions = ch_versions.mix( GENERATE_GENOME.out.versions )
//
// SUBWORKFLOW: Takes reference, channel of enzymes, my.genome, assembly_id and as file to generate
// file with enzymatic digest sites.
//
if ( include_workflow_steps.contains("insilico_digest")) {
ch_enzyme = Channel.of( "bspq1","bsss1","DLE1" )
INSILICO_DIGEST (
GENERATE_GENOME.out.dot_genome,
reference,
ch_enzyme,
digest_asfile
)
ch_versions = ch_versions.mix( INSILICO_DIGEST.out.versions )
}
//
// SUBWORKFLOW: FOR SPLITTING THE REF GENOME INTO SCAFFOLD CHUNKS AND RUNNING SOME SUBWORKFLOWS
// ON THOSE CHUNKS
// THIS WILL BE REQUIRED FOR LARGER GENOMES EST > 6GB
//
// REFERENCE_GENOME_SPLIT --> SELFCOMP
// --> GENE_ALIGNMENT
// BOTH WOULD REQUIRE A POST SUBWORKFLOW MERGE STEP TO MERGE TOGETHER THE SCAFFOLD
// BASED ALIGNMENTS/SELFCOMPS INTO A GENOME REPRESENTATIVE ONE.
// FOR GENE ALIGNMENT WOULD THIS REQUIRE A .GENOME FILE AND INDEX PER SCAFFOLD?
//
// SUBWORKFLOW: Takes input fasta to generate BB files containing alignment data
//
if ( include_workflow_steps.contains("gene_alignment")) {
GENE_ALIGNMENT (
GENERATE_GENOME.out.dot_genome,
reference,
GENERATE_GENOME.out.ref_index,
align_genesets,
intron_size,
gene_alignment_asfiles
)
ch_versions = ch_versions.mix(GENE_ALIGNMENT.out.versions)
}
//
// SUBWORKFLOW: GENERATES A BIGWIG FOR A REPEAT DENSITY TRACK
//
if ( include_workflow_steps.contains("repeat_density")) {
REPEAT_DENSITY (
reference,
GENERATE_GENOME.out.dot_genome
)
ch_versions = ch_versions.mix( REPEAT_DENSITY.out.versions )
ch_repeat_density = REPEAT_DENSITY.out.repeat_density
} else {
ch_repeat_density = Channel.of([[],[]])
}
//
// SUBWORKFLOW: GENERATES A GAP.BED FILE TO ID THE LOCATIONS OF GAPS
//
if ( include_workflow_steps.contains("gap_finder")) {
GAP_FINDER (
reference
)
ch_versions = ch_versions.mix( GAP_FINDER.out.versions )
ch_gap_file = GAP_FINDER.out.gap_file
} else {
ch_gap_file = Channel.of([[],[]])
}
//
// SUBWORKFLOW: Takes reference file, .genome file, mummer variables, motif length variable and as
// file to generate a file containing sites of self-complementary sequence.
//
if ( include_workflow_steps.contains("selfcomp")) {
SELFCOMP (
reference,
GENERATE_GENOME.out.dot_genome,
selfcomp_asfile
)
ch_versions = ch_versions.mix( SELFCOMP.out.versions )
}
//
// SUBWORKFLOW: Takes reference, the directory of syntenic genomes and order/clade of sequence
// and generates a file of syntenic blocks.
//
if ( include_workflow_steps.contains("synteny")) {
SYNTENY (
reference,
synteny_paths
)
ch_versions = ch_versions.mix( SYNTENY.out.versions )
}
//
// SUBWORKFLOW: Takes reference, pacbio reads
//
if ( include_workflow_steps.contains("read_coverage")) {
READ_COVERAGE (
reference,
GENERATE_GENOME.out.dot_genome,
assem_reads
)
ch_versions = ch_versions.mix( READ_COVERAGE.out.versions )
ch_coverage_bg_norm = READ_COVERAGE.out.ch_covbw_nor
} else {
ch_coverage_bg_norm = Channel.of([[],[]])
}
//
// SUBWORKFLOW: GENERATE TELOMERE WINDOW FILES WITH PACBIO READS AND REFERENCE
//
if ( include_workflow_steps.contains("telo_finder")) {
TELO_FINDER ( reference,
teloseq
)
ch_versions = ch_versions.mix( TELO_FINDER.out.versions )
ch_telo_bedgraph = TELO_FINDER.out.bedgraph_file
} else {
ch_telo_bedgraph = Channel.of([[],[]])
}
//
// SUBWORKFLOW: GENERATE BUSCO ANNOTATION FOR ANCESTRAL UNITS
//
if ( include_workflow_steps.contains("busco")) {
BUSCO_ANNOTATION (
GENERATE_GENOME.out.dot_genome,
reference,
lineageinfo,
lineagespath,
buscogene_asfile,
ancestral_table
)
ch_versions = ch_versions.mix( BUSCO_ANNOTATION.out.versions )
}
//
// SUBWORKFLOW: Takes reads and assembly, produces kmer plot
//
if ( include_workflow_steps.contains("kmer")) {
KMER (
reference,
assem_reads
)
ch_versions = ch_versions.mix( KMER.out.versions )
}
//
// SUBWORKFLOW: GENERATE HIC MAPPING TO GENERATE PRETEXT FILES AND JUICEBOX
//
if ( include_workflow_steps.contains("hic_mapping")) {
HIC_MAPPING (
reference,
GENERATE_GENOME.out.ref_index,
GENERATE_GENOME.out.dot_genome,
hic_reads,
assembly_id,
ch_gap_file,
ch_coverage_bg_norm,
ch_telo_bedgraph,
ch_repeat_density,
params.mode
)
ch_versions = ch_versions.mix( HIC_MAPPING.out.versions )
}
//
// Collate and save software versions
//
softwareVersionsToYAML(ch_versions)
.collectFile(
storeDir: "${params.outdir}/pipeline_info",
name: 'treeval_software_' + 'versions.yml',
sort: true,
newLine: true
).set { ch_collated_versions }
emit:
versions = ch_versions // channel: [ path(versions.yml) ]
}
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
THE END
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/