forked from maranasgroup/optstoic-gams
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptStoic.gms
executable file
·241 lines (185 loc) · 5 KB
/
optStoic.gms
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
$Ontext
optStoic
Authors: Anupam Chowdhury, Chiam Yu Ng
DESCRIPTION
The objective of this code (optStoic.gms) is to identify the overall stoichiometry of
reactants and products. The code identifies the maximum achievable yields of the
target product subject to thermodynamic restrictions.
In this sample code, we use glucose as substrate and acetate/1,3-propanediol as product.
OUTPUT FILE
optStoic_output.csv - a comma-separated list of model status, metabolites and stoichiometric
coefficients, the standard Gibbs free energy of reaction.
For more information, please refer to the paper below:
Anupam Chowdhury and Costas D. Maranas
"Designing overall stoichiometric conversions and intervening metabolic reactions"
Scientific Reports, 2015
$Offtext
$INLINECOM /* */
$set fpath data/
$set fsuffix _modified
$set substrate C00267
Options
limrow = 1000
optCR = 1E-9
optCA = 0.0
iterlim = 1000000
decimals = 8
reslim = 1000000
work = 50000000
mip = cplex
minlp = baron;
***********************
Sets
i metabolites
/
$include "%fpath%metabolites%fsuffix%.txt"
/
j "elements, charge and dGf"
/
'C'
'H'
'N'
'O'
'P'
'S'
'F'
'Cl'
'Mg'
'Fe'
'Se'
'Co'
'As'
'Br'
'I'
'R'
'charge'
'dGf'
/
elem(j) subset of j
/
'C'
'H'
'O'
'charge'
/
dG(j) change in Gibbs free energy of formation / 'dGf'/
pdt(i) list of target products
/
'C00033' /*acetate*/
'C02457' /*13pdo*/
/
allow(i) metabolites allowed to participate in a reaction
/
'C00007' /*o2*/
'C00267' /*glc*/
'C00011' /*co2*/
'C00080' /*h+*/
'C00001' /*h2o*/
'C02457' /*13pdo*/
'C00033' /*acetate*/
/
;
***********************
Parameters
m(i,j) metabolite details
/
$include "%fpath%metabolite_details.txt"
/
c "standard Gibbs free energy of a reaction" /0/
dGmax "maximum allowed value of free energy change" /-5/
;
***********************
Variables
zp objective function
s(i) stoichiometric coefficient of metabolite i
;
***********************
Equations
obj define objective function
stoic elemental and charge balance
bal the overall conversion should have a free energy change lesser or equal to dGmax
;
obj.. zp =e= sum(i$pdt(i),s(i))/(-s('%substrate%'));
stoic(j)$(elem(j)).. sum(i,s(i)*m(i,j)) =e= 0;
bal(j)$(dG(j)).. sum(i,s(i)*m(i,j)) =l= dGmax*(-s('%substrate%'));
***********************
Model optstoic
/
obj
stoic
bal
/
;
file f1 /optStoic_output.csv/;
f1.pc=5;
put f1;
*CSV file header
put 'product', 'modelstat', 'obj_value', 'dGr_overall', 'stoichiometric_coefficient', 'metabolite'/;
********************************************************************************
* Example 1: glucose -> acetate *
********************************************************************************
*set the upper and lower bound of stoichoimetric coefficient
s.lo(i) = -15;
s.up(i) = 15;
*set stoichiometric coefficient glucose to -1 (reactant)
s.up('%substrate%') = -1;
*allow water to be either co-reactant or co-product
s.up('C00001') = 15;
s.lo('C00001') = -15;
*turn off oxygen
s.up('C00007') = 0;
s.lo('C00007') = 0;
*turn off other product
s.fx(i)$pdt(i)= 0;
*set lb of target product's stoichiometry coefficient to 1
s.lo('C00033') = 1; /*acetate*/
*set ub of target product's stoichiometry coefficient to 15
s.up('C00033') = 15; /*acetate*/
*set stoichiometric coefficient of metabolites not allowed to participate in final reaction to 0
s.fx(i)$(not allow(i)) = 0;
optstoic.optfile = 1;
optstoic.holdfixed = 1;
Solve optstoic using minlp maximizing zp;
*get dG of the entire reaction
c = sum(i, s.l(i)*m(i,'dGf'))/(-s.l('%substrate%'));
*output result
put 'C00033',optstoic.modelstat:0:0,zp.l:0:4,c:0:4,;
loop(i$(s.l(i) ne 0),
put s.l(i):0:4,i.tl,;
);
put /;
if(optstoic.modelstat ne 1,
put optstoic.modelstat:0:0,"infeasible"/;
);
********************************************************************************
* Example 2: glucose -> 1,3-propanediol *
********************************************************************************
*set the upper and lower bound of stoichoimetric coefficient
s.lo(i) = -15;
s.up(i) = 15;
*set ub of stoichiometric coefficient of substrate(e.g. glucose) to -1 (reactant)
s.up('%substrate%') = -1;
*make oxygen a reactant
s.up('C00007') = 0;
*turn off other products
s.fx(i)$pdt(i) = 0;
*set lb of target product's stoichiometry coefficient to 1
s.lo('C02457') = 1;
*set ub of target product's stoichiometry coefficient to 15
s.up('C02457') = 15;
*set stoichiometric coefficient of metabolites not allowed to participate in final reaction to 0
s.fx(i)$(not allow(i)) = 0;
optstoic.optfile = 1;
optstoic.holdfixed = 1;
Solve optstoic using minlp maximizing zp;
*get dG of the entire reaction
c = sum(i, s.l(i)*m(i,'dGf'))/(-s.l('%substrate%'));
*output result
put 'C02457', optstoic.modelstat:0:0,zp.l:0:4,c:0:4,;
loop(i$(s.l(i) ne 0),
put s.l(i):0:4,i.tl,;
);
put /;
if(optstoic.modelstat ne 1,
put optstoic.modelstat:0:0,"infeasible"/;
);