-
Notifications
You must be signed in to change notification settings - Fork 0
/
determine_as.py
48 lines (39 loc) · 1.16 KB
/
determine_as.py
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
import json
from os import listdir
# download all JSON files into a directory called "json"
all_filenames = listdir("json")
print(all_filenames)
# get file names from directroy
json_filenames = []
for i in all_filenames:
if "json" in i:
json_filenames.append(i)
# created nested list of cc_annotations
anatom_struct = []
for j in json_filenames:
with open("json/" + j, "r") as current_file:
data = json.load(current_file)
anatom_struct.append(data["ccf_annotations"])
# flatten into one list
flattened_list = []
for m in anatom_struct:
for n in m:
flattened_list.append(n)
# get counts for each element
dict = {}
for k in flattened_list:
if k in dict.keys():
dict[k] = dict[k] + 1
else:
dict[k] = 1
# print results and compare counts to length of flattened_list
sum = 0
for item in dict:
sum = sum + dict[item]
print(str(item) + " was found " + str(dict[item]) + " times.")
print()
print("Total #AS: " + str(sum))
print("Counts: " + str(len(flattened_list)))
print("Total #AS is equal to counts: " + str(sum == len(flattened_list)))
# get #unique AS
print("Unique AS: " + str(len(dict.keys())))