-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathl3coefs_proc.py
61 lines (48 loc) · 1.54 KB
/
l3coefs_proc.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
infile = open("data/coefs/L3_coefs_nodup.csv")
outfile = open("data/coefs/L3_coefs_proc_nodup.csv","w")
coefs_dict = {}
for line in infile:
split_line = line.strip().split("\t")
mods = "_".join(split_line[0].split("_")[:-2])
mods_feat = "_".join(split_line[1].split("_")[:-1])
score = float(split_line[2])
if mods in coefs_dict.keys():
if mods_feat in coefs_dict[mods].keys():
coefs_dict[mods][mods_feat] += score
else:
coefs_dict[mods][mods_feat] = score
else:
coefs_dict[mods] = {}
if mods_feat in coefs_dict[mods].keys():
coefs_dict[mods][mods_feat] += score
else:
coefs_dict[mods][mods_feat] = score
for k,it in coefs_dict.items():
for k2,it2 in it.items():
print(k,it,k2,it2)
outfile.write("%s\t%s\t%s\n" % (k,k2,it2))
outfile.close()
infile = open("data/coefs/L3_coefs_dup.csv")
outfile = open("data/coefs/L3_coefs_proc_dup.csv","w")
coefs_dict = {}
for line in infile:
split_line = line.strip().split("\t")
mods = "_".join(split_line[0].split("_")[:-2])
mods_feat = "_".join(split_line[1].split("_")[:-1])
score = float(split_line[2])
if mods in coefs_dict.keys():
if mods_feat in coefs_dict[mods].keys():
coefs_dict[mods][mods_feat] += score
else:
coefs_dict[mods][mods_feat] = score
else:
coefs_dict[mods] = {}
if mods_feat in coefs_dict[mods].keys():
coefs_dict[mods][mods_feat] += score
else:
coefs_dict[mods][mods_feat] = score
for k,it in coefs_dict.items():
for k2,it2 in it.items():
print(k,it,k2,it2)
outfile.write("%s\t%s\t%s\n" % (k,k2,it2))
outfile.close()