Skip to content

Commit

Permalink
Fixed exception handling for --calc-L option
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbrownza committed Jun 4, 2017
1 parent 51c2485 commit 5328f95
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions calc_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,11 @@ def calc_shortest_path(protein_graph, prefix, generate_plots=True):

for i in range(num_nodes):
for j in range(num_nodes):
dj_path_matrix[i,j] = path_dict[i][j]

try:
dj_path_matrix[i,j] = path_dict[i][j]
except KeyError, ke:
raise nx.exception.NetworkXNoPath("No link between %d and %d" % (i, j))

np.savetxt("%s_L.dat" % prefix, dj_path_matrix)

avg_L_per_node = np.sum(dj_path_matrix, axis=0)/(num_nodes - 1)
Expand Down

0 comments on commit 5328f95

Please sign in to comment.