Skip to content
This repository has been archived by the owner on Jan 25, 2018. It is now read-only.

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
stashkov committed May 25, 2017
1 parent 03e98d1 commit 7535fc0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pathway_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,9 @@ def save_stoichimetric_matrices(self, file_prefix='stoichimetric_empty_prefix'):
"""save all stoichimetric matrices"""
assert len(self.result) == len(self.stoichiometric_matrices)
for i, m in enumerate(self.stoichiometric_matrices):
f = open('data/%s_matrix_%s.txt' % (file_prefix, i), 'w')
path_to_file = 'data/%s_matrix_%s.txt' % (file_prefix, i)
print '{:<50}{:<25}'.format(path_to_file, nx.info(self.result[i]))
f = open(path_to_file, 'w')
f.write('matrix dimensions: %s %s\n' % (len(m), len(self.result[i].edges())))
f.write('nodes: %s\n' % ' '.join(str(n) for n in self.result[i].nodes()))
f.write('edges: %s\n' % ' '.join(str(u) + ' ' + str(v) for u, v in self.result[i].edges()))
Expand All @@ -238,8 +240,9 @@ def generate_graphml(graph):

assert len(self.result) == len(self.stoichiometric_matrices)
for i, graph in enumerate(self.result):
path_to_file = "data/" + file_prefix + "_" + str(i) + ".graphml"
graph = generate_graphml(graph)
nx.write_graphml(graph, "data/" + file_prefix + "_" + str(i) + ".graphml")
nx.write_graphml(graph, path_to_file)
return None

@staticmethod
Expand Down

0 comments on commit 7535fc0

Please sign in to comment.