segrelab / cometspy

Python interface for running COMETS simulations and analyzing the results
GNU General Public License v3.0
11 stars 9 forks source link

weird behavior with `static` compounds #20

Open hariszaf opened 1 year ago

hariszaf commented 1 year ago

Hi all and thanks a lot for comets and cometspy.

Based on the documentation site:

If I get this right, then one could have a static case with a non unlimited compound. For example, I would like to have a static medium compound of 11mM glucose.

To this end i have made a short example case:

e_coli_cobra = cobra.io.load_matlab_model("e_coli_core.mat")
e_coli = c.model(e_coli_cobra)
e_coli.initial_pop = [0, 0, 1e-7] 

test_tube = c.layout()

test_tube.set_specific_metabolite('glc__D_e', 0.011);
test_tube.set_specific_static('glc__D_e', 0.011)

test_tube.set_specific_metabolite('nh4_e', 1000);
test_tube.set_specific_metabolite('pi_e', 1000);
test_tube.set_specific_metabolite('h2o_e', 1000);
test_tube.set_specific_metabolite('h_e', 1000);

e_coli.initial_pop = [0, 0, 5e-6]

test_tube.add_model(e_coli)

sim_params = c.params()
sim_params.set_param('defaultVmax', 18.5)
sim_params.set_param('defaultKm', 0.000015)
sim_params.set_param('maxCycles', 10000)
sim_params.set_param('timeStep', 0.01)
sim_params.set_param('spaceWidth', 1)
sim_params.set_param('maxSpaceBiomass', 15)
sim_params.set_param('minSpaceBiomass', 1e-11)
sim_params.set_param('writeMediaLog', True)
sim_params.set_param('writeTotalBiomassLog', True)

experiment = c.comets(test_tube, sim_params)

experiment.run()

experiment.media[experiment.media["metabolite"]=="glc__D_e"]

image

It seems that the glc__D_e compound does not behave as static even if when you run experiment.layout.media, you see that the g_static is as it should:

image

Am i doing something wrong ?

Thank you very much in advance for all your time and help.

dukovski commented 1 year ago

If the static flag is 1, the concentration must stay the same. This is a bug. Can you send me the files so I can reproduce this? Thanks.

hariszaf commented 1 year ago

Hi @dukovski. Thanks a lot for the immediate response. Attached you can find my script and the e_coli_core model i m using for this toy case. Thanks a lot once again and I d be glad to help if possible.

comets_test_static.zip

dukovski commented 1 year ago

No problem, I will take a look tomorrow. Thanks.