|
3 | 3 | import numpy as np |
4 | 4 | from csnanalysis.matrix import * |
5 | 5 | import itertools |
| 6 | +from copy import deepcopy |
6 | 7 |
|
7 | 8 | class CSN(object): |
8 | 9 |
|
@@ -41,7 +42,7 @@ def __init__(self, counts, symmetrize=False): |
41 | 42 | self.graph = nx.DiGraph() |
42 | 43 | labels = [{'label' : i, 'count' : int(totcounts[i][0])} for i in range(self.nnodes)] |
43 | 44 | 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)) |
45 | 46 |
|
46 | 47 | # remove self edges from graph |
47 | 48 | self_edges = [(i,i) for i in range(self.nnodes)] |
@@ -128,7 +129,10 @@ def colors_from_committors(self,comm): |
128 | 129 | for i in range(min(3,nbasin)): |
129 | 130 | if node not in rgb: |
130 | 131 | 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) |
132 | 136 |
|
133 | 137 | return rgb |
134 | 138 |
|
@@ -277,7 +281,15 @@ def calc_committors(self,basins,labels=None,basin_labels=None,add_basins=False,t |
277 | 281 | full_comm = committor(self.transmat,basins,tol=tol,maxstep=maxstep) |
278 | 282 | else: |
279 | 283 | # 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) |
281 | 293 | full_comm = np.zeros((self.transmat.shape[0],len(basins)),dtype=float) |
282 | 294 | for i,ind in enumerate(self.trim_indices): |
283 | 295 | full_comm[ind] = comm[i] |
|
0 commit comments