EPFL-LCSB / skimpy

Symbolic Kinetic Models with Python
Apache License 2.0
30 stars 14 forks source link

Failure to import COBRA model #9

Closed AQ18 closed 2 years ago

AQ18 commented 2 years ago

Attempting to import this COBRA model fails:

from cobra.io.json import load_json_model
from skimpy.io.generate_from_cobra import FromCobra

cobra_model = load_json_model("iWFL_1372.json")

model_gen = FromCobra()
skimpy_model = model_gen.import_model(cobra_model)

gives traceback

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-43-9894a0b4025d> in <module>
----> 1 skimpy_model = model_gen.import_model(cobra_model)

/skimpy/skimpy/io/generate_from_cobra.py in import_model(self, cobra_model)
     77                        and (this_met .id not in self.reactants_to_exclude):
     78                         met = sanitize_cobra_vars(this_met.id)
---> 79                         this_reactant = skimpy_model.reactants[met]
     80                         this_const_met = ConstantConcentration(this_reactant)
     81                         skimpy_model.add_boundary_condition(this_const_met)

KeyError: 'fe3dcit_e'

I believe the problem is that in FromCobra().import_model(), we look up the boundary reaction metabolite this_reactant in skimpy_model.reactants, but this is not guaranteed to exist. It only exists if the metabolite was added in the previous for loop at line 60, i.e. if the metabolite appears in the non-boundary reactions too.

weilandtd commented 2 years ago

Hi @AQ18 could you provide either 1) the reaction (reaction string) as well as the reactant (using e.g. %debug in ipython) or 2) the model you were trying to import

AQ18 commented 2 years ago

The model is iWFL_1372, accessed from BiGG here. The json is available here.