cobrapy icon indicating copy to clipboard operation
cobrapy copied to clipboard

trying to add existing exchange reactions changes bounds

Open Karrenbelt opened this issue 5 years ago • 1 comments

in the SBML model (e_coli_core), if I set the extracellular species as a boundary species (e.g. for kinetic simulation), and then load the model to cobra, even though the exchange reactions (and bounds) exist, it will try to add an exchange reaction, and by doing so change the bounds to (-inf, inf), changing model behaviour. Can this be circumvented?

sbml_model.species.ac_e.boundary_condition = True
cobra_model = cobra.io.read_sbml_model(sbml_model)
>>> Adding exchange reaction EX_ac_e for boundary metabolite: ac_e
>>> Ignoring reaction 'EX_ac_e' since it already exists.
cobra_model.reactions.EX_ac_e.bounds
>>> (-inf, inf)

Karrenbelt avatar Jul 31 '19 07:07 Karrenbelt

Okay, as I understand it you found a corner case. Normally models either use boundaryCondition=True on species or have exchange reactions on a model. I never encountered a model with a mix of the two things. But I clearly see your use case here. For now just set boundaryCondition=False before loading the model in cobra.

The latest develop version already sets the bounds correctly to the config values. I will add a bug fix for this special case which checks if exchange reactions already exist for species with boundaryCondition=True.

matthiaskoenig avatar Jul 31 '19 08:07 matthiaskoenig