You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When one builds a reaction object and adds reagents to it, one can add this reaction to the model no matter whether the corresponding species exists or not. For example,
import cbmpy as cbm
from cbmpy.CBModel import Reaction, Reagent
mod_name = 'e_coli_core.xml'
model = cbm.CBRead.readSBML3FBC(mod_name)
reagent1 = Reagent("dummy_1", "i_dont_exist", -1.0)
reagent2 = Reagent("dummy_2", "i_dont_exist_either", 1.0)
rea = Reaction("dummy")
rea.addReagent(reagent1)
rea.addReagent(reagent2)
model.addReaction(rea)
print(model.getReaction("dummy").getStoichiometry())
# prints [(-1.0, 'i_dont_exist'), (1.0, 'i_dont_exist_either')]
if model.getSpecies('i_dont_exist') is None:
print("species does not exist") # this will be printed
This might be confusing as it looks like these species exist but they actually don't.
I guess the easiest would be to add an additional check in addReagent whether reag.getSpecies() already exists in the model and if not either create the species or throw an error (I would prefer the error).
The text was updated successfully, but these errors were encountered:
willigott
changed the title
Possible to add reactions with reagents that are not part of the model
Possible to add reactions with reagents whose corresponding species are not part of the model
Apr 9, 2019
When one builds a reaction object and adds reagents to it, one can add this reaction to the model no matter whether the corresponding species exists or not. For example,
This might be confusing as it looks like these species exist but they actually don't.
I guess the easiest would be to add an additional check in
addReagent
whetherreag.getSpecies()
already exists in the model and if not either create the species or throw an error (I would prefer the error).The text was updated successfully, but these errors were encountered: