Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError on .convert() #51

Open
mdziurzynski opened this issue Apr 23, 2021 · 2 comments
Open

KeyError on .convert() #51

mdziurzynski opened this issue Apr 23, 2021 · 2 comments

Comments

@mdziurzynski
Copy link

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?

@psalvy
Copy link
Member

psalvy commented Apr 25, 2021

Good day mdziurzynski

Thanks for using pyTFA! From what I see here, it looks like you do not have a concentration variable for this metabolite cpd15684_c. Right after the prepare statement, can you check that this is the case ?

Cheers,
Pierre

@mdziurzynski
Copy link
Author

mdziurzynski commented Apr 28, 2021

Hello Pierre,

thank you for such a quick answer. Quite frankly, I wasn't able to look up the concentration variables after prepare(). What is the proper way to do that?
It appears that log concentration data is not created during _convert_metabolites method, but later on in _convert_reactions those missing LC's are required and hence the error.

I'm trying to replicate the tutorial_basics.py code on non reduced model. I prepared the lexicon, adjusted compartment data but I get this error. I uploaded the code along with a the data to this repo: https://github.com/mdziurzynski/tac125_to_pytfa

Update:
I managed to overcome this error through removal of 57 reactions from my model. All of them had their dGibbs in Seed Database set to 10000000. If I understand this correctly, that means that there are no reliable data for dGibbs for these reactions, so a placeholder values have been put, right? If yes, if there maybe any way to deal with that kind of unknowns? I read that there are ways to computationally predict dGibbs, so should this kind of approach be applied in such situations?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants