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

Commit

Permalink
refactor main
Browse files Browse the repository at this point in the history
  • Loading branch information
stashkov committed Jun 3, 2017
1 parent 6f43a0f commit 98ec68b
Showing 1 changed file with 39 additions and 44 deletions.
83 changes: 39 additions & 44 deletions my_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,48 +7,43 @@
import efm_summary as efms
import time

# G = examples.generate_barabasi(7); graph_name = 'barabasi'
# G = examples.generate_graph()


# G = examples.example30()
G = examples.example31S2()
# G = generate_graph_test_loops()


nx.write_graphml(G, 'data/input_graph.graphml')

# [save_graphml(G3, z) for G3 in result ]
# save_graphml(G3, z)
# save_stoichimetric_matrices(G3, z, file_prefix=graph_name)


start = time.time()

stoichiometric_matrix = ig.InhibitionRemovalFromMethabolicPathway.stat_generate_stoichiometric_matrix(G)
ig.InhibitionRemovalFromMethabolicPathway.stat_save_stoichimetric_matrix(stoichiometric_matrix)

a = ig.InhibitionRemovalFromMethabolicPathway(G)
a.save_stoichimetric_matrices(file_prefix='Stoic')
a.save_graphml(file_prefix='graphML')

for node in G.nodes():
temp_graph = copy.deepcopy(G)
temp_graph.remove_node(node)
a = ig.InhibitionRemovalFromMethabolicPathway(temp_graph)
a.save_stoichimetric_matrices(file_prefix='Stoic_remove_node' + str(node))
a.save_graphml(file_prefix='GraphML_remove_node' + str(node))

print('Stoichiometric Matrices generated in %s' % str(time.time() - start))
start = time.time()

# ----summary

dirpath = 'data/'
print('Processing files in {}'.format(dirpath))
summary = efms.EFMSummary(dirpath)

print('\nNumber of EFMs in expanded graph: {}'.format(summary.EFM_in_expanded_graph))
summary.print_EFM_by_node()

print('#EFM calculated in %s' % str(time.time() - start))
def calculate_EFM():
dirpath = 'data/'
print('Processing files in {}'.format(dirpath))
summary = efms.EFMSummary(dirpath)
print('\nNumber of EFMs in expanded graph: {}'.format(summary.EFM_in_expanded_graph))
summary.print_EFM_by_node()


def write_stoichimetric_matrices_to_files():
stoichiometric_matrix = ig.InhibitionRemovalFromMethabolicPathway.stat_generate_stoichiometric_matrix(G)
ig.InhibitionRemovalFromMethabolicPathway.stat_save_stoichimetric_matrix(stoichiometric_matrix)
a = ig.InhibitionRemovalFromMethabolicPathway(G)
a.save_stoichimetric_matrices(file_prefix='Stoic')
a.save_graphml(file_prefix='graphML')
for node in G.nodes():
print('Working with node %s out of %s' % (node, len(G.nodes())))
temp_graph = copy.deepcopy(G)
temp_graph.remove_node(node)
a = ig.InhibitionRemovalFromMethabolicPathway(temp_graph)
a.save_stoichimetric_matrices(file_prefix='Stoic_remove_node' + str(node))
a.save_graphml(file_prefix='GraphML_remove_node' + str(node))


if __name__ == '__main__':
# G = generate_graph_test_loops()
# G = examples.generate_barabasi(7)
# G = examples.generate_graph()
# G = examples.example30()
G = examples.example31S2()

nx.write_graphml(G, 'data/input_graph.graphml')

print('Start generating stoichiometric matrices')
start = time.time()
write_stoichimetric_matrices_to_files()
print('Stoichiometric Matrices generated in {} seconds'.format(int(time.time() - start)))
start = time.time()
calculate_EFM()
print('\n#EFM calculated in {} seconds'.format(int(time.time() - start)))

0 comments on commit 98ec68b

Please sign in to comment.