-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathindex_data.py
More file actions
38 lines (29 loc) · 1.27 KB
/
index_data.py
File metadata and controls
38 lines (29 loc) · 1.27 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
from __future__ import print_function
import os
import glob
import json
import os
from collections import defaultdict
def main():
datasets = defaultdict(list)
#use a path from the location of the python script so that it can be called from outside the same folder
base_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)),'data')
for run_name in os.listdir(base_dir):
for summary_path in glob.glob(os.path.join(base_dir, run_name, '*.summ.json')):
dataset_name = summary_path.split('/')[-1].split('.')[0]
run = {
'summary_path': os.path.join('data', run_name, dataset_name + '.summ.json'),
'muts_path': os.path.join('data', run_name, dataset_name + '.muts.json'),
'name': dataset_name,
}
clusters_path = os.path.join('data', run_name, dataset_name + '.clusters.json')
if os.path.isfile(clusters_path):
run['clusters_path'] = clusters_path
mutass_path = os.path.join('data', run_name, dataset_name + '.mutass')
if os.path.isdir(mutass_path):
run['mutass_path'] = mutass_path
datasets[run_name].append(run)
out_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'data', 'index.json')
with open(out_path, 'w') as outf:
print(json.dumps(datasets), file=outf)
main()