-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_instances_templates.py
More file actions
282 lines (273 loc) · 10.6 KB
/
update_instances_templates.py
File metadata and controls
282 lines (273 loc) · 10.6 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
import ast
# Read the current test_results.py
with open('test_results.py', 'r') as f:
content = f.read()
# Parse the results list
tree = ast.parse(content)
results_assign = None
for node in ast.walk(tree):
if isinstance(node, ast.Assign) and len(node.targets) == 1 and isinstance(node.targets[0], ast.Name) and node.targets[0].id == 'results':
results_assign = node
break
if not results_assign:
raise ValueError("Could not find results assignment")
# Get the current results list
current_results = ast.literal_eval(ast.unparse(results_assign.value))
# New instances data (from the diff test output for example #4)
new_instances = {
"headers": {
"id": {
"title": "Add",
"type": "selection_id",
"order": -1
},
"label": {
"title": "Name",
"type": "markdown",
"order": 0,
"sort": {
"0": "Asc"
}
},
"parent": {
"title": "Parent Type",
"type": "markdown",
"order": 1
},
"template": {
"title": "Template",
"type": "markdown",
"order": 4
},
"tags": {
"title": "Gross Types",
"type": "tags",
"order": 3
},
"source": {
"title": "Data Source",
"type": "markdown",
"order": 5
},
"source_id": {
"title": "Data Source",
"type": "markdown",
"order": 6
},
"dataset": {
"title": "Dataset",
"type": "markdown",
"order": 7
},
"license": {
"title": "License",
"type": "markdown",
"order": 8
},
"thumbnail": {
"title": "Thumbnail",
"type": "markdown",
"order": 9
}
},
"rows": [
{
"id": "VFB_00102107",
"label": "[ME on JRC2018Unisex adult brain](VFB_00102107)",
"tags": "Nervous_system|Adult|Visual_system|Synaptic_neuropil_domain",
"parent": "[medulla](FBbt_00003748)",
"source": "",
"source_id": "",
"template": "[JRC2018U](VFB_00101567)",
"dataset": "[JRC 2018 templates & ROIs](JRC2018)",
"license": "",
"thumbnail": "[](VFB_00101567,VFB_00102107)"
},
{
"id": "VFB_00101385",
"label": "[ME(R) on JRC_FlyEM_Hemibrain](VFB_00101385)",
"tags": "Nervous_system|Adult|Visual_system|Synaptic_neuropil_domain",
"parent": "[medulla](FBbt_00003748)",
"source": "",
"source_id": "",
"template": "[JRCFIB2018Fum](VFB_00101384)",
"dataset": "[JRC_FlyEM_Hemibrain painted domains](Xu2020roi)",
"license": "",
"thumbnail": "[ on JRC_FlyEM_Hemibrain aligned to JRCFIB2018Fum\")](VFB_00101384,VFB_00101385)"
},
{
"id": "VFB_00030810",
"label": "[medulla on adult brain template Ito2014](VFB_00030810)",
"tags": "Nervous_system|Visual_system|Adult|Synaptic_neuropil_domain",
"parent": "[medulla](FBbt_00003748)",
"source": "",
"source_id": "",
"template": "[adult brain template Ito2014](VFB_00030786)",
"dataset": "[BrainName neuropils and tracts - Ito half-brain](BrainName_Ito_half_brain)",
"license": "",
"thumbnail": "[](VFB_00030786,VFB_00030810)"
},
{
"id": "VFB_00030624",
"label": "[medulla on adult brain template JFRC2](VFB_00030624)",
"tags": "Nervous_system|Visual_system|Adult|Synaptic_neuropil_domain",
"parent": "[medulla](FBbt_00003748)",
"source": "",
"source_id": "",
"template": "[JFRC2](VFB_00017894)",
"dataset": "[BrainName neuropils on adult brain JFRC2 (Jenett, Shinomya)](JenettShinomya_BrainName)",
"license": "",
"thumbnail": "[](VFB_00017894,VFB_00030624)"
}
],
"count": 4
}
# New templates data (from the diff test output for example #5)
new_templates = {
"headers": {
"id": {
"title": "Add",
"type": "selection_id",
"order": -1
},
"order": {
"title": "Order",
"type": "numeric",
"order": 1,
"sort": {
"0": "Asc"
}
},
"name": {
"title": "Name",
"type": "markdown",
"order": 1,
"sort": {
"1": "Asc"
}
},
"tags": {
"title": "Tags",
"type": "tags",
"order": 2
},
"thumbnail": {
"title": "Thumbnail",
"type": "markdown",
"order": 9
},
"dataset": {
"title": "Dataset",
"type": "metadata",
"order": 3
},
"license": {
"title": "License",
"type": "metadata",
"order": 4
}
},
"rows": [
{
"id": "VFB_00200000",
"order": 2,
"name": "[JRCVNC2018U](VFB_00200000)",
"tags": "Nervous_system|Adult|Ganglion",
"thumbnail": "[](VFB_00200000)",
"dataset": "[JRC 2018 templates & ROIs](JRC2018)",
"license": "[CC-BY-NC-SA](VFBlicense_CC_BY_NC_SA_4_0)"
},
{
"id": "VFB_00120000",
"order": 10,
"name": "[Adult T1 Leg (Kuan2020)](VFB_00120000)",
"tags": "Adult|Anatomy",
"thumbnail": "[')](VFB_00120000)",
"dataset": "[Millimeter-scale imaging of a Drosophila leg at single-neuron resolution](Kuan2020)",
"license": "[CC_BY](VFBlicense_CC_BY_4_0)"
},
{
"id": "VFB_00110000",
"order": 9,
"name": "[Adult Head (McKellar2020)](VFB_00110000)",
"tags": "Adult|Anatomy",
"thumbnail": "[')](VFB_00110000)",
"dataset": "[GAL4 lines from McKellar et al., 2020](McKellar2020)",
"license": "[CC_BY_SA](VFBlicense_CC_BY_SA_4_0)"
},
{
"id": "VFB_00101567",
"order": 1,
"name": "[JRC2018U](VFB_00101567)",
"tags": "Nervous_system|Adult",
"thumbnail": "[](VFB_00101567)",
"dataset": "[JRC 2018 templates & ROIs](JRC2018)",
"license": "[CC-BY-NC-SA](VFBlicense_CC_BY_NC_SA_4_0)"
},
{
"id": "VFB_00101384",
"order": 4,
"name": "[JRCFIB2018Fum](VFB_00101384)",
"tags": "Nervous_system|Adult",
"thumbnail": "[](VFB_00101384)",
"dataset": "[JRC_FlyEM_Hemibrain painted domains](Xu2020roi)",
"license": "[CC_BY](VFBlicense_CC_BY_4_0)"
},
{
"id": "VFB_00100000",
"order": 7,
"name": "[COURT2018VNS](VFB_00100000)",
"tags": "Nervous_system|Adult|Ganglion",
"thumbnail": "[](VFB_00100000)",
"dataset": "[Adult VNS neuropils (Court2017)](Court2017)",
"license": "[CC_BY_SA](VFBlicense_CC_BY_SA_4_0)"
},
{
"id": "VFB_00050000",
"order": 5,
"name": "[L1 larval CNS ssTEM - Cardona/Janelia](VFB_00050000)",
"tags": "Nervous_system|Larva",
"thumbnail": "[](VFB_00050000)",
"dataset": "[larval hugin neurons - EM (Schlegel2016)](Schlegel2016), [Neurons involved in larval fast escape response - EM (Ohyama2016)](Ohyama2015)",
"license": "[CC_BY](VFBlicense_CC_BY_4_0), [CC_BY_SA](VFBlicense_CC_BY_SA_4_0)"
},
{
"id": "VFB_00049000",
"order": 6,
"name": "[L3 CNS template - Wood2018](VFB_00049000)",
"tags": "Nervous_system|Larva",
"thumbnail": "[](VFB_00049000)",
"dataset": "[L3 Larval CNS Template (Truman2016)](Truman2016)",
"license": "[CC_BY_SA](VFBlicense_CC_BY_SA_4_0)"
},
{
"id": "VFB_00030786",
"order": 8,
"name": "[adult brain template Ito2014](VFB_00030786)",
"tags": "Nervous_system|Adult",
"thumbnail": "[](VFB_00030786)",
"dataset": "[BrainName neuropils and tracts - Ito half-brain](BrainName_Ito_half_brain)",
"license": "[CC_BY_SA](VFBlicense_CC_BY_SA_4_0)"
},
{
"id": "VFB_00017894",
"order": 3,
"name": "[JFRC2](VFB_00017894)",
"tags": "Nervous_system|Adult",
"thumbnail": "[](VFB_00017894)",
"dataset": "[FlyLight - GMR GAL4 collection (Jenett2012)](Jenett2012)",
"license": "[CC-BY-NC-SA](VFBlicense_CC_BY_NC_SA_4_0)"
}
],
"count": 10
}
# Update the results
current_results[3] = new_instances
current_results[4] = new_templates
# Write back to file
import pprint
with open('test_results.py', 'w') as f:
f.write('results = ')
f.write(pprint.pformat(current_results, width=120))
f.write('\n')
print("Updated test_results.py with new instances and templates data.")