-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcobrapy_test.py
115 lines (84 loc) · 2.9 KB
/
cobrapy_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#Jonathan Foldi
#June 13, 2020
#cobrapy test
from __future__ import print_function
import cobra
import cobra.test
import os
from os.path import join
from cobra.util.solver import linear_reaction_coefficients
### "ecoli" and "salmonella" are also valid arguments
##model = cobra.test.create_test_model("textbook")
##
##
##print(len(model.reactions))
##print(len(model.metabolites))
##print(len(model.genes))
##
##print(model.reactions[29])
##
##pgi = model.reactions.get_by_id("PGI")
##print(pgi.name)
#can get specific reactions from searching by metabolite and then getting
# all the reactions in which it's present
#can do the same thing for genes
#MODELS
#can iterate throgh al the reactions of a model and od a knockout of each one
# and see how that affects biomass
# Iterate through the the objects in the model
##print("Reactions")
##print("---------")
##for x in model.reactions:
## print("%s : %s" % (x.id, x.reaction))
##
##print("")
##print("Metabolites")
##print("-----------")
##for x in model.metabolites:
## print('%9s : %s' % (x.id, x.formula))
##
##print("")
##print("Genes")
##print("-----")
##for x in model.genes:
## associated_ids = (i.id for i in x.reactions)
## print("%s is associated with reactions: %s" %
## (x.id, "{" + ", ".join(associated_ids) + "}"))
#TEST MODELS
##data_dir = cobra.test.data_dir
##
##print("mini test files: ")
##print(", ".join(i for i in os.listdir(data_dir) if i.startswith("mini")))
##
##textbook_model = cobra.test.create_test_model("textbook")
##ecoli_model = cobra.test.create_test_model("ecoli")
##salmonella_model = cobra.test.create_test_model("salmonella")
##
##model_reactions = (cobra.io.read_sbml_model(join(data_dir, "mini_fbc2.xml")).reactions)
##print(len(model_reactions))
print (os.getcwd())
#set woroking directory to cobrapy folder when importing locally stored files
data_dir = os.getcwd()
print('starting easy here')#so that can find hte start more easily in the shell
easy = cobra.io.read_sbml_model(join(data_dir, "easy.xml"))
##
print(len(easy.reactions),"is how many reactions there are in easy")
easy_solution = easy.optimize()
print(easy_solution,'is the optimized for easy')
#this works!!!
print('starting theta here')
theta = cobra.io.read_sbml_model(join(data_dir, "b-theta.xml"))
print(len(theta.reactions),"is how many reactions there are in theta")
theta_solution = theta.optimize()
print(theta_solution,'is the optimized for theta')
solutions = [easy_solution, theta_solution]
models = ['easy','theta']
model_var = [easy,theta]
for num in range(2):
print (solutions[num].objective_value,' is the objective value for model ',models[num])
print (solutions[num].status,' is the status for model ',models[num])
for num in range(2):
print (model_var[num].summary(),' is the summary for model ',models[num])
#f = open("b-theta.xml", "r")
#print(f.read(100000))
##print(len(theta.reactions))