-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Let's say I take an existing model and do
import cbmpy as cbm
mod = cbm.CBRead.readSBML3FBC('e_coli_core.xml.gz')
cbm.doFBAMinSum(mod)
everything will work as expected.
However, when I now add a new reaction to this model,
newmod = mod.clone()
newmod.createReaction('foo')
newmod.createReactionReagent('foo', 'M_h_e', -1.)
and try again to minimize the fluxes, I get an error
cbm.doFBAMinSum(newmod)
CPLEX is using solver option: "o"
KeyError Traceback (most recent call last)
/opt/ibm/ILOG/CPLEX_Studio128/cplex/python/3.6/x86-64_linux/cplex/_internal/_aux_functions.py in _cachelookup(item, getindexfunc, cache)
277 try:
--> 278 idx = cache[item]
279 except KeyError:KeyError: 'foo'
The reason seems to be that the stoichiometric matrix is not updated when a new reaction is added. If I do
newmod.buildStoichMatrix()
cbm.doFBAMinSum(newmod)
it will work fine.
Not sure what the best approach would be to deal with it. Maybe one could also add the build_n=True option to the function call as in doFBA?