-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathexport.smk
More file actions
132 lines (116 loc) · 4.59 KB
/
export.smk
File metadata and controls
132 lines (116 loc) · 4.59 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
"""
This part of the workflow collects the phylogenetic tree and annotations to
export a Nextstrain dataset.
REQUIRED INPUTS:
metadata = {build_dir}/{build_name}/metadata.tsv
tree = {build_dir}/{build_name}/tree.nwk
branch_lengths = {build_dir}/{build_name}/branch_lengths.json
nt_muts = {build_dir}/{build_name}/nt_muts.json
aa_muts = {build_dir}/{build_name}/aa_muts.json
traits = {build_dir}/{build_name}/traits.json
clades = {build_dir}/{build_name}/clades.json
mutation_context = {build_dir}/{build_name}/mutation_context.json
color_ordering = path to color_ordering TSV
color_schemes = path to color_schemes TSV
lat_longs = path to lat/long TSV
description = path to description Markdown
auspice_config = path to Auspice config JSON
OPTIONAL INPUTS:
recency = {build_dir}/{build_name}/recency.json
OUTPUTS:
auspice_json = {build_dir}/{build_name}/tree.json
root_sequence = {build_dir}/{build_name}/tree_root-sequence.json
"""
rule remove_time:
input:
build_dir + "/{build_name}/branch_lengths.json",
output:
build_dir + "/{build_name}/branch_lengths_no_time.json",
log:
"logs/{build_name}/remove_time.txt",
benchmark:
"benchmarks/{build_name}/remove_time.txt"
shell:
r"""
exec &> >(tee {log:q})
python3 {workflow.basedir}/scripts/remove_timeinfo.py \
--input-node-data {input:q} \
--output-node-data {output:q}
"""
rule colors:
input:
ordering=resolve_config_path(config["color_ordering"]),
color_schemes=resolve_config_path(config["color_scheme"]),
metadata=build_dir + "/{build_name}/metadata.tsv",
output:
colors=build_dir + "/{build_name}/colors.tsv",
params:
ignore_categories=config.get("colors", {}).get("ignore_categories", []),
log:
"logs/{build_name}/colors.txt",
benchmark:
"benchmarks/{build_name}/colors.txt"
shell:
r"""
exec &> >(tee {log:q})
python3 {workflow.basedir}/scripts/assign-colors.py \
--ordering {input.ordering:q} \
--color-schemes {input.color_schemes:q} \
--output {output.colors:q} \
--ignore-categories {params.ignore_categories:q} \
--metadata {input.metadata:q}
"""
rule export:
"""
Exporting data files for auspice
"""
input:
tree=build_dir + "/{build_name}/tree.nwk",
metadata=build_dir + "/{build_name}/metadata.tsv",
branch_lengths=(
build_dir + "/{build_name}/branch_lengths.json"
if config.get("timetree", False)
else build_dir + "/{build_name}/branch_lengths_no_time.json"
),
traits=(
build_dir + "/{build_name}/traits.json"
if config.get("traits", {}).get("columns", False)
else []
),
nt_muts=build_dir + "/{build_name}/nt_muts.json",
aa_muts=build_dir + "/{build_name}/aa_muts.json",
clades=build_dir + "/{build_name}/clades.json",
mutation_context=build_dir + "/{build_name}/mutation_context.json",
recency=(
build_dir + "/{build_name}/recency.json"
if config.get("recency", False)
else []
),
colors=build_dir + "/{build_name}/colors.tsv",
lat_longs=resolve_config_path(config["lat_longs"]),
description=resolve_config_path(config["description"]),
auspice_config=resolve_config_path(config["auspice_config"]),
output:
auspice_json=build_dir + "/{build_name}/tree.json",
root_sequence=build_dir + "/{build_name}/tree_root-sequence.json",
params:
strain_id=config["strain_id_field"],
log:
"logs/{build_name}/export.txt",
benchmark:
"benchmarks/{build_name}/export.txt"
shell:
r"""
exec &> >(tee {log:q})
augur export v2 \
--tree {input.tree:q} \
--metadata {input.metadata:q} \
--metadata-id-columns {params.strain_id:q} \
--node-data {input.branch_lengths:q} {input.traits:q} {input.nt_muts:q} {input.aa_muts:q} {input.mutation_context:q} {input.clades:q} {input.recency:q} \
--colors {input.colors:q} \
--lat-longs {input.lat_longs:q} \
--description {input.description:q} \
--auspice-config {input.auspice_config:q} \
--include-root-sequence \
--output {output.auspice_json:q}
"""