-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworkflow.nf
186 lines (120 loc) · 5.73 KB
/
workflow.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
#!/usr/bin/env nextflow
nextflow.enable.dsl=2
import java.nio.file.Paths
include { create_subset; create_subset_by_lineage; create_fasta; rename_headers } from "./preprocessing/preprocessing.nf"
include { nextstrain_filter; nextstrain_align; nextstrain_tree; nextstrain_tree_refine; nextstrain_tree_refine_clock_iterations; nextstrain_traits; nextstrain_ancestral; nextstrain_translate; nextstrain_clades; nextstrain_export } from "./pipeline/pipeline.nf"
include { manipulate_json; clean_directories } from "./postprocessing/postprocessing.nf"
workflow nextstrain_augur_refine_clock_iterations {
main:
clocks = Channel.of(1..params.clock)
iterations = Channel.of(params.start_iteration..params.stop_iteration)
metadata_file = params.metadata
create_subset(iterations)
if (params.make_alignment) {
FASTA = params.master_fasta
} else {
FASTA = params.nextalign
}
create_fasta(create_subset.out.metadata, FASTA)
meta_with_fasta = create_subset.out.metadata.join(create_fasta.out.fasta)
rename_headers(meta_with_fasta)
meta_with_fasta_filtered = create_subset.out.metadata.join(rename_headers.out.renamed)
nextstrain_filter(meta_with_fasta_filtered)
nextstrain_align(nextstrain_filter.out.filtered)
if (params.make_alignment) {
nextstrain_align(nextstrain_filter.out.filtered)
ALIGNMENT = nextstrain_align.out.alignment
} else {
ALIGNMENT = nextstrain_filter.out.filtered
}
nextstrain_tree(ALIGNMENT)
refine_inputs = nextstrain_tree.out.tree.join(create_subset.out.metadata).join(ALIGNMENT)
nextstrain_tree_refine_clock_iterations(refine_inputs, clocks)
emit:
tree = nextstrain_tree_refine_clock_iterations.out.refined_tree
dirs = nextstrain_tree_refine_clock_iterations.out.final_directories
}
workflow nextstrain_random_subsets {
main:
iterations = Channel.of(params.start_iteration..params.stop_iteration)
metadata_file = params.metadata
create_subset(iterations)
if (params.make_alignment) {
FASTA = params.master_fasta
} else {
FASTA = params.nextalign
}
create_fasta(create_subset.out.metadata, FASTA)
meta_with_fasta = create_subset.out.metadata.join(create_fasta.out.fasta)
rename_headers(meta_with_fasta)
meta_with_fasta_filtered = create_subset.out.metadata.join(rename_headers.out.renamed)
nextstrain_filter(meta_with_fasta_filtered)
if (params.make_alignment) {
nextstrain_align(nextstrain_filter.out.filtered)
ALIGNMENT = nextstrain_align.out.alignment
} else {
ALIGNMENT = nextstrain_filter.out.filtered
}
nextstrain_tree(ALIGNMENT)
refine_inputs = nextstrain_tree.out.tree.join(create_subset.out.metadata).join(ALIGNMENT)
nextstrain_tree_refine(refine_inputs)
traits_input = create_subset.out.metadata.join(nextstrain_tree_refine.out.refined)
nextstrain_traits(traits_input)
ancestral_inputs = ALIGNMENT.join(nextstrain_tree_refine.out.refined)
nextstrain_ancestral(ancestral_inputs)
translate_inputs = nextstrain_tree_refine.out.refined.join(nextstrain_ancestral.out.ancestral)
nextstrain_translate(translate_inputs)
clades_input = translate_inputs.join(nextstrain_translate.out.translation)
nextstrain_clades(clades_input)
final_input = refine_inputs.join(clades_input).join(
nextstrain_traits.out.traits).join(nextstrain_clades.out.clades).distinct()
nextstrain_export(final_input)
manipulate_json(nextstrain_export.out.export_json)
emit:
jsons = manipulate_json.out.edited_json
dirs = manipulate_json.out.final_dirs
}
workflow nextstrain_by_lineage {
main:
lineage_list = Channel.fromList(params.lineages)
create_subset_by_lineage(lineage_list)
if (params.make_alignment) {
FASTA = params.master_fasta
} else {
FASTA = params.nextalign
}
create_fasta(create_subset_by_lineage.out.lineage, FASTA)
meta_with_fasta = create_subset_by_lineage.out.lineage.join(create_fasta.out.fasta)
rename_headers(meta_with_fasta)
meta_with_fasta_filtered = create_subset_by_lineage.out.lineage.join(rename_headers.out.renamed)
nextstrain_filter(meta_with_fasta_filtered)
if (params.make_alignment) {
nextstrain_align(nextstrain_filter.out.filtered)
ALIGNMENT = nextstrain_align.out.alignment
} else {
ALIGNMENT = nextstrain_filter.out.filtered
}
nextstrain_tree(ALIGNMENT)
refine_inputs = nextstrain_tree.out.tree.join(create_subset_by_lineage.out.lineage).join(ALIGNMENT)
nextstrain_tree_refine(refine_inputs)
traits_input = create_subset_by_lineage.out.lineage.join(nextstrain_tree_refine.out.refined)
nextstrain_traits(traits_input)
ancestral_inputs = ALIGNMENT.join(nextstrain_tree_refine.out.refined)
nextstrain_ancestral(ancestral_inputs)
translate_inputs = nextstrain_tree_refine.out.refined.join(nextstrain_ancestral.out.ancestral)
nextstrain_translate(translate_inputs)
clades_input = translate_inputs.join(nextstrain_translate.out.translation)
nextstrain_clades(clades_input)
final_input = refine_inputs.join(clades_input).join(
nextstrain_traits.out.traits).join(nextstrain_clades.out.clades).distinct()
nextstrain_export(final_input)
manipulate_json(nextstrain_export.out.export_json)
emit:
jsons = manipulate_json.out.edited_json
dirs = manipulate_json.out.final_dirs
}
workflow directory_cleanup {
take: location_dir
main:
clean_directories(location_dir)
}