forked from pockerman/hidden_markov_modeling
-
Notifications
You must be signed in to change notification settings - Fork 0
/
analysis_helpers.py
executable file
·49 lines (37 loc) · 1.62 KB
/
analysis_helpers.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
"""
Various helpers to be used in the analysis module
"""
from helpers import WindowType
def save_cluster(filename, cluster, statistic, wtype):
with open(filename, 'w') as file:
file.write(str(cluster.get_window_statistics(statistic=statistic,
window_type=wtype)))
def save_clusters(clusters, statistic):
for cluster in clusters:
wga_file = "cluster_"+str(cluster.cidx) +"_wga_w_" + statistic + ".txt"
save_cluster(filename=wga_file, cluster=cluster,
statistic=statistic, wtype=WindowType.WGA)
no_wga_file = "cluster_"+str(cluster.cidx) +"_no_wga_w_" + statistic + ".txt"
save_cluster(filename=no_wga_file, cluster=cluster,
statistic=statistic, wtype=WindowType.NO_WGA)
def save_windows_statistic(windows, statistic, region_id=None):
window_stats = \
[window.get_rd_stats(statistics=statistic,
name=WindowType.NO_WGA)
for window in windows if not window.is_n_window()]
if region_id is not None:
filename = "no_wga_windows_" + statistic + "_" + str(region_id) + ".txt"
else:
filename = "no_wga_windows_" + statistic + ".txt"
with open(filename, 'w') as file:
file.write(str(window_stats))
window_stats = \
[window.get_rd_stats(statistics=statistic,
name=WindowType.WGA)
for window in windows if not window.is_n_window()]
if region_id is not None:
filename = "wga_windows_" + statistic + "_" + str(region_id) + ".txt"
else:
filename = "wga_windows_" + statistic + ".txt"
with open(filename, 'w') as file:
file.write(str(window_stats))