EPFL-LCSB / skimpy

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

Adding reactions to a model with compartments #12

Open PHvanLent opened 2 years ago

PHvanLent commented 2 years ago

Hello all,

Thank you a lot for this nice package, it has made many things a lot easier already. However, I run into a problem with compile_ode() when I try to add reactions to an already existing model.

The code:

filenames={ "kmodel":"models/varma_strain_1.yml"} `kmodel=load_yaml_model(filenames['kmodel'])```

name = 'R1'

Define reaction reactants sets

metabolites = ReversibleMichaelisMenten.Reactants(substrate = 'A_c', product = 'B_c') parameters1 = ReversibleMichaelisMenten.Parameters( vmax_forward = 1.0, k_equilibrium=2.0, km_substrate = 10.0, km_product = 10.0, total_enzyme_concentration = 1.0,) ####### Create the reaction object R1 = Reaction(name=name, mechanism = ReversibleMichaelisMenten, reactants=metabolites, ) kmodel.add_reaction(R1) kmodel.parametrize_by_reaction({R1.name:parameters1}) kmodel.prepare() kmodel.compile_ode()

I get the following error: ~/Documenten/Gitlab/Skimpy/Local-Skimpy/skimpy/skimpy/analysis/ode/utils.py in (.0) 65 #TODO Throw error if no cell reference compartment is given 66 ---> 67 volume_ratios = TabDict([(k,v.compartment.parameters.cell_volume.symbol/ 68 v.compartment.parameters.volume.symbol ) 69 for k,v in kinetic_model.reactants.items()])

AttributeError: 'NoneType' object has no attribute 'parameters'

Do you know what is going on here?

Kind regards,

Paul

weilandtd commented 2 years ago

Hello,

Thank you for raising this issue. Could you please print the output kinetic_model.compartments?

Best Daniel

PHvanLent commented 2 years ago

Hello Daniel,

Thank you for the fast response. The kinetic model was the one provided in the tutorials.

kmodel.compartments

Output: ' TabDict([('c', <skimpy.core.compartments.Compartment at 0x7f890cde5970>), ('e', <skimpy.core.compartments.Compartment at 0x7f890cde5e80>)])`

Kind regards,

Paul

weilandtd commented 2 years ago

Hi Paul Thank you!

so currently Skimpy supports defining all or no compartments when adding the reactions it is required to specify the compartments for the new metabolites since the Varma model specified compartments. So: kmodel.reactants.A_c.compartment = kmodel.compartments.c kmodel.reactants.B_c.compartment = kmodel.compartments.c

will as far as I tested, resolve your issue.

In the meantime, I will think to specify the error message.

PHvanLent commented 2 years ago

Hi Daniel,

Thank you, that indeed resolved the issue! Many thanks for the help and the awesome package.