def test_clamp_sid(): r = load_model(MODEL_REPRESSILATOR) # Perform clamping r_clamp = clamp_species(r, sids=["X"], boundary_condition=True) assert r_clamp assert isinstance(r_clamp, roadrunner.RoadRunner)
def test_plotting(): r = load_model(MODEL_REPRESSILATOR) simulator = Simulator(MODEL_REPRESSILATOR) changeset = ChangeSet.parameter_sensitivity_changeset(r, sensitivity=0.5) tcsims = ensemble( TimecourseSim([ Timecourse(start=0, end=400, steps=400), ]), changeset) result = simulator.timecourses(tcsims) # create figure fig, (ax1) = plt.subplots(nrows=1, ncols=1, figsize=(5, 5)) fig.subplots_adjust(wspace=0.3, hspace=0.3) add_line(ax=ax1, data=result, xid='time', yid="X", label="X") add_line(ax=ax1, data=result, xid='time', yid="Y", label="Y", color="darkblue") ax1.legend() plt.show()
def run_sensitivity(): """ Parameter sensitivity simulations. :return: """ simulator = Simulator(MODEL_REPRESSILATOR) # parameter sensitivity # FIXME: make work with parallel r = load_model(MODEL_REPRESSILATOR) changeset = ChangeSet.parameter_sensitivity_changeset(r) tc_sim = TimecourseSim([ Timecourse(start=0, end=100, steps=100), Timecourse(start=0, end=200, steps=100, model_changes={"boundary_condition": { "X": True }}), Timecourse(start=0, end=100, steps=100, model_changes={"boundary_condition": { "X": False }}), ]) tc_sims = ensemble(tc_sim, changeset=changeset) result = simulator.timecourses(tc_sims) # create figure fig, (ax1) = plt.subplots(nrows=1, ncols=1, figsize=(5, 5)) fig.subplots_adjust(wspace=0.3, hspace=0.3) add_line(ax=ax1, data=result, xid='time', yid="X", label="X") add_line(ax=ax1, data=result, xid='time', yid="Y", label="Y", color="darkblue") add_line(ax=ax1, data=result, xid='time', yid="Z", label="Z", color="darkorange") ax1.legend() plt.show()
ax.plot(x, data.mean[yid], '-', color=color, label="sim {}".format(label)) else: x = data[xid] * xf ax.plot(x, data[yid], '-', color=color, label="sim {}".format(label)) if __name__ == "__main__": from sbmlsim.tests.constants import MODEL_REPRESSILATOR from sbmlsim.model import load_model from sbmlsim.parametrization import ChangeSet from sbmlsim.simulation_serial import TimecourseSimulation, Timecourse, timecourses r = load_model(MODEL_REPRESSILATOR) # parameter sensitivity changeset = ChangeSet.parameter_sensitivity_changeset(r, sensitivity=0.05) tc_sims = TimecourseSimulation([ Timecourse(start=0, end=100, steps=100), Timecourse(start=0, end=200, steps=100, model_changes={"boundary_condition": { "X": True }}), Timecourse(start=0, end=100, steps=100, model_changes={"boundary_condition": {
def test_species_df(): r = load_model(MODEL_REPRESSILATOR) df = species_df(r) assert df is not None assert "sid" in df
def test_parameter_df(): r = load_model(MODEL_REPRESSILATOR) df = parameter_df(r) assert df is not None assert "sid" in df
def __init__(self, path, selections: List[str] = None): self.r = load_model(path=path, selections=selections)
changes_init = pkpd.init_concentrations_changes(r, 'som', 0E-6) # [0 nmol/L] tcsims = ensemble( TimecourseSim([ Timecourse(start=0, end=60, steps=120, changes=changes_init), Timecourse(start=0, end=60, steps=120, changes={'Ri_som': 10.0E-6}), # [mg/min], Timecourse(start=0, end=60, steps=120, changes={'Ri_som': 20.0E-6}), # [mg/min], Timecourse(start=0, end=60, steps=120, changes={'Ri_som': 40.0E-6}), # [mg/min], Timecourse(start=0, end=60, steps=120, changes={'Ri_som': 80.0E-6}), # [mg/min], ]), ChangeSet.parameter_sensitivity_changeset(r, 0.1) ) return simulator.timecourses(tcsims) if __name__ == "__main__": import sys r = load_model(MODEL_GLCWB) simulator = Simulator(MODEL_GLCWB) results = {} for f_simulate in [po_bolus, iv_bolus, iv_infusion, clamp, mix, stepped_clamp]: f_key = f_simulate.__name__ print(f_key) result = f_simulate(simulator, r) print(result) print("results:", len(result), sys.getsizeof(result)) results[f_key] = result for key, result in results.items(): somatostatin_plot(result, title=key) plt.show() import ray