forked from zaleCao/elegansNet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HL.py
68 lines (55 loc) · 1.97 KB
/
HL.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
62
63
64
65
66
67
68
import networkx as nx
import matplotlib.pyplot as plt
import csv
import pandas
import random
import pickle
import analysis as al
try:
import pygraphviz
from networkx.drawing.nx_agraph import graphviz_layout
except ImportError:
try:
import pydotplus
from networkx.drawing.nx_pydot import graphviz_layout
except ImportError:
raise ImportError("This example needs Graphviz and either "
"PyGraphviz or PyDotPlus")
G = nx.read_graphml("data/c.elegans.herm_pharynx_1.graphml")
timesteps = 500
simulation_no = 100
timedelay_range = 20
probabilityData = {}
median = al.medianDegree(G)
hubFraction = al.nodeDegreeClassification(G, median)
with open('data/randomResults/activityData.txt', 'rb') as f:
activitydata = pickle.load(f)
with open('data/randomResults/hopcountData.txt', 'rb') as f:
hopcountdata = pickle.load(f)
with open('data/randomResults/died.txt', 'rb') as f:
died = pickle.load(f)
'''
for i in range(simulation_no):
probabilityData[i] = al.probability_calulations(activitydata[i], timesteps, timedelay_range)
'''
probabilityData = al.all_itr_probability_calulation(G, activitydata, simulation_no, timesteps, timedelay_range, died)
with open('data/randomResults/probabilityData.txt', 'wb') as f:
pickle.dump(probabilityData, f)
#with open('data/randomResults/probabilityData.txt', 'rb') as f:
# probabilityData = pickle.load(f)
TE = al.TE(G, probabilityData, timedelay_range)
with open('data/randomResults/TEdata.txt', 'wb') as f:
pickle.dump(TE, f)
#with open('data/randomResults/TEdata.txt', 'rb') as f:
# TE = pickle.load(f)
dTE = al.dTE(G, TE, timedelay_range)
with open('data/randomResults/dTEdata.txt', 'wb') as f:
pickle.dump(dTE, f)
#with open('data/randomResults/dTEdata.txt', 'rb') as f:
# dTE = pickle.load(f)
HL = al.HL(G, dTE, timedelay_range)
with open('data/randomResults/HLdata.txt', 'wb') as f:
pickle.dump(HL, f)
#with open('data/randomResults/HLdata.txt', 'rb') as f:
# HL= pickle.load(f)
#store data