Skip to content

Commit aa9a697

Browse files
committed
working complete tutorial
1 parent d84394f commit aa9a697

File tree

6 files changed

+124
-46
lines changed

6 files changed

+124
-46
lines changed

csnanalysis/csn.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import numpy as np
44
from csnanalysis.matrix import *
55
import itertools
6+
from copy import deepcopy
67

78
class CSN(object):
89

@@ -41,7 +42,7 @@ def __init__(self, counts, symmetrize=False):
4142
self.graph = nx.DiGraph()
4243
labels = [{'label' : i, 'count' : int(totcounts[i][0])} for i in range(self.nnodes)]
4344
self.graph.add_nodes_from(zip(range(self.nnodes),labels))
44-
self.graph.add_weighted_edges_from(zip(self.transmat.col,self.transmat.row,self.transmat.data))
45+
self.graph.add_weighted_edges_from(zip(self.transmat.col,self.transmat.row,100*self.transmat.data))
4546

4647
# remove self edges from graph
4748
self_edges = [(i,i) for i in range(self.nnodes)]
@@ -128,7 +129,10 @@ def colors_from_committors(self,comm):
128129
for i in range(min(3,nbasin)):
129130
if node not in rgb:
130131
rgb[node] = {}
131-
rgb[node][colors[i]] = highc*comm[node,i]/maxc
132+
if maxc == 0:
133+
rgb[node][colors[i]] = 0
134+
else:
135+
rgb[node][colors[i]] = int(highc*comm[node,i]/maxc)
132136

133137
return rgb
134138

@@ -277,7 +281,15 @@ def calc_committors(self,basins,labels=None,basin_labels=None,add_basins=False,t
277281
full_comm = committor(self.transmat,basins,tol=tol,maxstep=maxstep)
278282
else:
279283
# use trimmed transition matrix
280-
comm = committor(self.transmat,basins,tol=tol,maxstep=maxstep)
284+
trim_basins = []
285+
for i,b in enumerate(basins):
286+
trim_basins.append([])
287+
for j,state in enumerate(b):
288+
try:
289+
trim_basins[i].append(self.trim_indices.index(state))
290+
except:
291+
pass
292+
comm = committor(self.trim_transmat,trim_basins,tol=tol,maxstep=maxstep)
281293
full_comm = np.zeros((self.transmat.shape[0],len(basins)),dtype=float)
282294
for i,ind in enumerate(self.trim_indices):
283295
full_comm[ind] = comm[i]

examples/committor_net_3state.png

315 KB
Loading

examples/examples.ipynb

Lines changed: 108 additions & 40 deletions
Large diffs are not rendered by default.

examples/state_A.dat

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/state_B.dat

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/state_U.dat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4 11 29 56 57 67 115 213 251 252 299 301 303 305 327 340 404 504 537 560 573 583 627 631 639 683 704 708 717 765 844 867 923 940 941 1010 1068 1070 1105 1138 1151 1157 1162 1243 1256 1287 1344 1348 1382 1412 1428 1455 1490 1569 1596 1640 1690 1744 1758 1776 1805 1815 1817 1825 1893 1922 1930 1933 1936 1960 1989 1993 1994 2062 2066 2076 2097 2147 2171 2183 2185 2199 2212 2302 2320 2345 2389 2408 2430 2470 2481 2513 2517 2536 2542 2606 2608 2618 2723 2749 2811 2813 2830 2870 2917 2931 2963 2995 3075 3087 3169 3183 3204 3212 3214 3247 3249 3251 3269 3270 3278 3305 3357 3466 3475 3480 3501 3536 3593 3600 3604 3611 3740 3781 3794 3810 3868 3897 3907 3962 3967 3969 3979 3989
1+
365 2830 1155 1529 3242 2201 1854 3251 2303 3899 806 2952 2322 1154 189 2343 3080 1024 3385 968 2228 1298 2475 2493 615 3918 1394 2472 1734 1787 81 156 593 3668 1412 1965 3215 415 959 1201 3894 2893 1077 158 2651 3176 975 3999 73 1758 1861 3437 1595 329 863 3767 3859 1099 1103 165 1143 3256 1530 3128 1911 1093 1320 3502 1851 711 2156 1130 3335 218 1611 1624 2579 3904 3596 3046 3219 3775 65 2558 1706 180 2489 2887 3644 3930 462 2400 1378 2020 2589 1203 302 2731 1956 632 1435 712 1889 2749 1008 354 2549 1755 986 2784 442 2925 2091 2111 2163 2379 1812 185 1499 1300 140 12 2937 37 3598 1065 1645 2947 3018 1288 2622 1781 1352 2915 1586 3175 934 148 1780 209 3021 45 2846 1133 193 126 746 3225 3791 613 1598 1246 1166 1951 391 2088 1705 548 3858 1564 3280 3579 2413 555 215 1626 1795 2128 974 24 520 3650 401 2093 1351 2743 3054 1377 1756 2504 3069 2756 3951 3177 3141 120 2871 3924 1 3750 375 1170 2066 2458 3980 2710 3092 49 1711 2244 2392 2959 2901 2150 1072 2920 2039 2062 1441 3564 1896 1327 752 2196 1687 257 3680 286 1046 2770 1793 2647 2879 418 721 507 1197

0 commit comments

Comments
 (0)