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.
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
Attempting to import this COBRA model fails:
gives traceback
I believe the problem is that in
FromCobra().import_model()
, we look up the boundary reaction metabolitethis_reactant
inskimpy_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.