def simulate_toy(sbml_path, out_dir, dts=[0.1, 1.0, 5.0], figures=True, tend=50, ode_integrator="cvode"): """ Simulate the diauxic growth model. :return: solution data frame """ plot_kwargs = { 'markersize': 4, 'marker': 's', 'alpha': 0.5 } dfs = [] for dt in dts: df, dfba_model, dfba_simulator = simulate_dfba(sbml_path, tend=tend, dt=dt, ode_integrator=ode_integrator) dfs.append(df) analyse_uniqueness(dfba_simulator) # generic analysis analysis = DFBAAnalysis(df=df, ode_model=dfba_simulator.ode_model) if figures: analysis.plot_reactions(os.path.join(out_dir, "fig_reactions_generic_dt{}.png".format(dt)), **plot_kwargs) analysis.plot_species(os.path.join(out_dir, "fig_species_generic_dt{}.png".format(dt)), **plot_kwargs) analysis.save_csv(os.path.join(out_dir, "data_simulation_generic_dt{}.csv".format(dt))) # custom model plots if figures: print_species(dfs=dfs, filepath=os.path.join(out_dir, "fig_species.png"), **plot_kwargs) print_fluxes(dfs=dfs, filepath=os.path.join(out_dir, "fig_fluxes.png"), **plot_kwargs) return dfs
def simulate_diauxic_growth(sbml_path, out_dir, dts=[0.01, 0.1], figures=True): """ Simulate the diauxic growth model. :return: solution data frame """ tend = 15 dfs = [] for dt in dts: df, dfba_model, dfba_simulator = simulate_dfba(sbml_path, tend=tend, dt=dt, pfba=False) dfs.append(df) # uniqueness of solution analyse_uniqueness(dfba_simulator) # generic analysis # analysis = DFBAAnalysis(df=df, rr_comp=dfba_simulator.ode_model) # analysis.plot_reactions(os.path.join(out_dir, "fig_reactions_generic_dt{}.png".format(dt)), # **plot_kwargs) # analysis.plot_species(os.path.join(out_dir, "fig_species_generic_dt{}.png".format(dt)), # **plot_kwargs) # analysis.save_csv(os.path.join(out_dir, "data_simulation_generic_dt{}.csv".format(dt))) if figures: # custom model plots plot_kwargs = { 'markersize': 4, 'marker': 'None', 'alpha': 0.5 } analyse.print_species(filepath=os.path.join(out_dir, "fig_species.png"), dfs=dfs, **plot_kwargs) analyse.print_fluxes(filepath=os.path.join(out_dir, "fig_fluxes.png"), dfs=dfs, **plot_kwargs) return dfs
def simulate_toy(sbml_path, out_dir, dts=[0.1, 1.0, 5.0], figures=True, tend=50, ode_integrator="cvode"): """ Simulate the diauxic growth model. :return: solution data frame """ plot_kwargs = {'markersize': 4, 'marker': 's', 'alpha': 0.5} dfs = [] for dt in dts: df, dfba_model, dfba_simulator = simulate_dfba( sbml_path, tend=tend, dt=dt, ode_integrator=ode_integrator) dfs.append(df) analyse_uniqueness(dfba_simulator) # generic analysis analysis = DFBAAnalysis(df=df, ode_model=dfba_simulator.ode_model) if figures: analysis.plot_reactions( os.path.join(out_dir, "fig_reactions_generic_dt{}.png".format(dt)), **plot_kwargs) analysis.plot_species( os.path.join(out_dir, "fig_species_generic_dt{}.png".format(dt)), **plot_kwargs) analysis.save_csv( os.path.join(out_dir, "data_simulation_generic_dt{}.csv".format(dt))) # custom model plots if figures: print_species(dfs=dfs, filepath=os.path.join(out_dir, "fig_species.png"), **plot_kwargs) print_fluxes(dfs=dfs, filepath=os.path.join(out_dir, "fig_fluxes.png"), **plot_kwargs) return dfs
# In[3]: # get the absolute path to the top model from sbmlutils.dfba.toy_wholecell import settings as toysettings from sbmlutils.dfba.toy_wholecell import model_factory as toyfactory from sbmlutils.dfba.toy_wholecell import simulate as toysimulate sbml_path = os.path.join( utils.versioned_directory(toysettings.OUT_DIR, toysettings.VERSION), toysettings.TOP_LOCATION) print(sbml_path) # run simulation with the top model from sbmlutils.dfba.simulator import simulate_dfba df, dfba_model, dfba_simulator = simulate_dfba(sbml_path, tend=50, dt=5.0) df # ## Toy example # In[4]: from sbmlutils.dfba.toy_wholecell import settings as toysettings from sbmlutils.dfba.toy_wholecell import model_factory as toyfactory from sbmlutils.dfba.toy_wholecell import simulate as toysimulate import tempfile test_dir = tempfile.mkdtemp() # create the toy model toyfactory.create_model(test_dir)
# In[3]: # get the absolute path to the top model from sbmlutils.dfba.toy_wholecell import settings as toysettings from sbmlutils.dfba.toy_wholecell import model_factory as toyfactory from sbmlutils.dfba.toy_wholecell import simulate as toysimulate sbml_path = os.path.join(utils.versioned_directory(toysettings.OUT_DIR, toysettings.VERSION), toysettings.TOP_LOCATION) print(sbml_path) # run simulation with the top model from sbmlutils.dfba.simulator import simulate_dfba df, dfba_model, dfba_simulator = simulate_dfba(sbml_path, tend=50, dt=5.0) df # ## Toy example # In[4]: from sbmlutils.dfba.toy_wholecell import settings as toysettings from sbmlutils.dfba.toy_wholecell import model_factory as toyfactory from sbmlutils.dfba.toy_wholecell import simulate as toysimulate import tempfile test_dir = tempfile.mkdtemp()