Skip to content

KeyError on .convert() #51

@mdziurzynski

Description

@mdziurzynski

Hello,

I'm trying to convert my model to TFA, and I'm getting an unmanaged KeyError for some of my metabolites. It usually looks like that:

mytfa.prepare()
mytfa.convert()

2021-04-23 14:02:02,924 - thermomodel_ - INFO - # Model preparation starting...
2021-04-23 14:02:04,180 - thermomodel_ - WARNING - Warning : Pb/Pb
2021-04-23 14:02:04,181 - thermomodel_ - WARNING - Warning : Pb/Pb
2021-04-23 14:02:04,296 - thermomodel_ - INFO - # Model preparation done.
2021-04-23 14:02:04,297 - thermomodel_ - INFO - # Model conversion starting...
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-9-ebc2fae6d451> in <module>
      1 ## TFA conversion
      2 mytfa.prepare()
----> 3 mytfa.convert()#add_displacement = True)
      4 
      5 ## Info on the cobra_model

/media/data/mdz/bio_projects/tac125_metabolic_modelling/analysis/14_tfa_model_construction/pytfa/pytfa/thermo/tmodel.py in convert(self, add_potentials, add_displacement, verbose)
    658         for rxn in self.reactions:
    659             self._convert_reaction(
--> 660                 rxn, add_potentials, add_displacement, verbose
    661             )
    662 

/media/data/mdz/bio_projects/tac125_metabolic_modelling/analysis/14_tfa_model_construction/pytfa/pytfa/thermo/tmodel.py in _convert_reaction(self, rxn, add_potentials, add_displacement, verbose)
    519                             # changes in deltaGFs in the RHS term
    520                             LC_ChemMet += (
--> 521                                 self.LC_vars[met] * RT * rxn.metabolites[met]
    522                             )
    523 

KeyError: <Metabolite cpd15684_c at 0x7f3762226518>

I tried to understand what is going on, but without any success. I just know that self.LC_vars[met] is raising the error. Does it have something to do with how my metabolites/reactions are defined?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions