def plot_death_freeze_state_test(): out_dir = os.path.join(PROCESS_OUT_DIR, 'death_freeze_state') if not os.path.exists(out_dir): os.makedirs(out_dir) timeseries = test_death_freeze_state(asserts=False) plot_settings = {} plot_simulation_output(timeseries, plot_settings, out_dir)
def main(): out_dir = os.path.join(TEST_OUT_DIR, NAME) os.makedirs(out_dir, exist_ok=True) timeseries = run_injector() plot_settings = {} plot_simulation_output(timeseries, plot_settings, out_dir) save_timeseries(timeseries, out_dir, NAME + '.csv')
def run_compartment(out_dir): data = test_growth_rate() mass = data['global']['mass'] growth = mass[-1] / mass[0] print('growth: {}'.format(growth)) plot_settings = {} plot_simulation_output(data, plot_settings, out_dir)
def main(): out_dir = os.path.join(TEST_OUT_DIR, NAME) if not os.path.exists(out_dir): os.makedirs(out_dir) timeseries = run_injector() plot_settings = {} plot_simulation_output(timeseries, plot_settings, out_dir) save_timeseries(timeseries, out_dir)
def main(): out_dir = os.path.join(PROCESS_OUT_DIR, AntibioticTransport.name) if not os.path.exists(out_dir): os.makedirs(out_dir) timeseries = run_antibiotic_transport() plot_settings = {} plot_simulation_output(timeseries, plot_settings, out_dir) save_timeseries(timeseries, out_dir)
def main(): """run test and plot""" out_dir = os.path.join(PROCESS_OUT_DIR, NAME) if not os.path.exists(out_dir): os.makedirs(out_dir) data = test_growth_rate() plot_settings = {} plot_simulation_output(data, plot_settings, out_dir)
def main(): out_dir = os.path.join(PROCESS_OUT_DIR, 'dynamic_modeler') if not os.path.exists(out_dir): os.makedirs(out_dir) output = run_process() # plot the simulation output plot_settings = {} plot_simulation_output(output, plot_settings, out_dir)
def main(): '''Simulate the process and plot results.''' # make an output directory to save plots out_dir = os.path.join(PROCESS_OUT_DIR, NAME) os.makedirs(out_dir, exist_ok=True) output = run_template_process() # plot the simulation output plot_settings = {} plot_simulation_output(output, plot_settings, out_dir)
def main(): '''Simulate the composite and plot results.''' #make an output directory to save plots out_dir = os.path.join(COMPARTMENT_OUT_DIR, NAME) if not os.path.exists(out_dir): os.makedirs(out_dir) output = test_connector() # plot simulation output plot_settings = {} plot_simulation_output(output, plot_settings, out_dir)
def main(): test_experiment() data = run_experiment() agents_plot_settings = { 'agents_key': 'agents', } plot_simulation_output( timeseries_from_data(data), agents_plot_settings, OUT_DIR, 'simulation', )
def main(): '''Simulate the process and plot results.''' # make an output directory to save plots out_dir = os.path.join(PROCESS_OUT_DIR, 'pgm') if not os.path.exists(out_dir): os.makedirs(out_dir) output = run_process() # plot the simulation output plot_settings = {} plot_simulation_output(output, plot_settings, out_dir)
def plot_sim_output(timeseries, out_dir='out'): print_growth(timeseries['global']) # plot plot_settings = { 'max_rows': 30, 'remove_zeros': True, 'skip_ports': ['exchange', 'reactions']} plot_simulation_output( timeseries, plot_settings, out_dir, 'cobra_composite')
def run_gene_expression(total_time=10, out_dir='out'): timeseries = test_gene_expression(total_time) plot_settings = { 'name': 'gene_expression', 'ports': { 'transcripts': 'transcripts', 'molecules': 'molecules', 'proteins': 'proteins' } } plot_gene_expression_output(timeseries, plot_settings, out_dir) sim_plot_settings = {'max_rows': 25} plot_simulation_output(timeseries, sim_plot_settings, out_dir)
def main(): """run the tests and plot""" out_dir = os.path.join(PROCESS_OUT_DIR, 'toy_gillespie') if not os.path.exists(out_dir): os.makedirs(out_dir) process_output = test_gillespie_process() composite_output = test_gillespie_composite() # plot the simulation output plot_settings = {} plot_simulation_output( process_output, plot_settings, out_dir, filename='process') plot_simulation_output( composite_output, plot_settings, out_dir, filename='composite')
def run_master(out_dir): timeseries = test_master() volume_ts = timeseries['global']['volume'] print('growth: {}'.format(volume_ts[-1]/volume_ts[0])) expression_plot_settings = { 'name': 'gene_expression', 'ports': { 'transcripts': 'transcripts', 'molecules': 'metabolites', 'proteins': 'proteins'}} plot_gene_expression_output(timeseries, expression_plot_settings, out_dir) plot_settings = { 'max_rows': 20, 'remove_zeros': True, 'skip_ports': ['prior_state', 'null', 'flux_bounds', 'chromosome', 'reactions']} plot_simulation_output(timeseries, plot_settings, out_dir)
def main(): out_dir = os.path.join(PROCESS_OUT_DIR, NAME) os.makedirs(out_dir, exist_ok=True) parser = argparse.ArgumentParser(description='metabolism process') parser.add_argument( '--bigg', '-b', action='store_true', default=False, ) parser.add_argument( '--toy', '-t', action='store_true', default=False, ) args = parser.parse_args() if args.toy: timeseries = test_toy_metabolism(total_time=2500) print_growth(timeseries['global']) plot_settings = {} plot_simulation_output(timeseries, plot_settings, out_dir, 'toy_metabolism') else: timeseries = run_bigg(total_time=2500) # save_timeseries(timeseries, out_dir) # TODO -- make a test with timeseries reference print_growth(timeseries['global']) # plot plot_settings = { 'max_rows': 30, 'remove_zeros': True, 'skip_ports': ['exchange', 'reactions'] } plot_simulation_output(timeseries, plot_settings, out_dir, 'BiGG_simulation')
def run_inclusion_body(out_dir='out'): # initialize the process by passing initial_parameters initial_parameters = {'growth_rate': 1e-1} inclusion_body_process = InclusionBody(initial_parameters) # get initial state initial_state = inclusion_body_process.initial_state({ 'initial_mass': 1.0, 'molecules': { 'biomass': 1.0 } }) # run the simulation sim_settings = {'initial_state': initial_state, 'total_time': 100} output = simulate_process(inclusion_body_process, sim_settings) # plot the simulation output plot_settings = {} plot_simulation_output(output, plot_settings, out_dir)
'_properties': { 'mw': 1.0 * units.g / units.mol, }, }, }, 'nucleoside_phosphates': { 'ATP': { '_default': 2.0, '_emit': True, }, 'ADP': { '_default': 0.0, '_emit': True, } }, } if __name__ == '__main__': parameters = { 'k_cat': 1.5, 'time_step': 0.1, } my_process = GlucosePhosphorylation(parameters) settings = { 'total_time': 10, } timeseries = simulate_process(my_process, settings) plot_simulation_output(timeseries, {}, './')
def run_death(): out_dir = os.path.join(PROCESS_OUT_DIR, NAME) os.makedirs(out_dir, exist_ok=True) output = test_death() plot_simulation_output(output, {}, out_dir)
return {'internal': internal_update} # test functions def get_toy_expression_config(): toy_expression_rates = { 'protein1': 1e-2, 'protein2': 1e-1, 'protein3': 1e0 } return {'expression_rates': toy_expression_rates} def test_expression(end_time=10): expression_config = get_toy_expression_config() # load process expression = MinimalExpression(expression_config) settings = {'total_time': end_time} return simulate_process_in_experiment(expression, settings) if __name__ == '__main__': out_dir = os.path.join(PROCESS_OUT_DIR, NAME) if not os.path.exists(out_dir): os.makedirs(out_dir) timeseries = test_expression(1000) plot_simulation_output(timeseries, {}, out_dir)
save_timeseries(timeseries, out_dir) volume_ts = timeseries['global']['volume'] mass_ts = timeseries['global']['mass'] print('volume growth: {}'.format(volume_ts[-1] / volume_ts[0])) print('mass growth: {}'.format(mass_ts[-1] / mass_ts[0])) # plot settings plot_settings = { 'max_rows': 30, 'remove_zeros': True, 'skip_ports': ['exchange', 'reactions'] } # make plots from simulation output plot_simulation_output(timeseries, plot_settings, out_dir, 'BiGG_simulation') plot_exchanges(timeseries, sim_settings, out_dir) # # make plot of energy reactions # stoichiometry = metabolism.fba.stoichiometry # energy_carriers = [get_synonym(mol_id) for mol_id in BiGG_energy_carriers] # energy_reactions = get_reactions(stoichiometry, energy_carriers) # energy_plot_settings = {'reactions': energy_reactions} # energy_synthesis_plot(timeseries, energy_plot_settings, out_dir) # make a gephi network run_sim_save_network(get_iAF1260b_config(), out_dir) else: timeseries = test_toy_metabolism() plot_settings = {}
expression = ODE_expression(config) settings = {'timeline': {'timeline': timeline}} return simulate_process_in_experiment(expression, settings) if __name__ == '__main__': out_dir = os.path.join(PROCESS_OUT_DIR, NAME) if not os.path.exists(out_dir): os.makedirs(out_dir) parser = argparse.ArgumentParser(description='ODE expression') parser.add_argument('--lacY', '-l', action='store_true', default=False) parser.add_argument('--flagella', '-f', action='store_true', default=False) args = parser.parse_args() if args.flagella: timeline = [(2520, {})] timeseries = test_expression(get_flagella_expression(), timeline) plot_simulation_output(timeseries, {}, out_dir, 'flagella_expression') else: total_time = 5000 shift_time1 = int(total_time / 5) shift_time2 = int(3 * total_time / 5) timeline = [ (0, {('external', 'glc__D_e'): 10}), (shift_time1, {('external', 'glc__D_e'): 0}), (shift_time2, {('external', 'glc__D_e'): 10}), (total_time, {})] timeseries = test_expression(get_lacy_config(), timeline) plot_simulation_output(timeseries, {}, out_dir, 'lacY_expression')
'total_time': end_time } return simulate_process_in_experiment(kinetic_process, settings) def test_convenience_kinetics_correlated_to_reference(): timeseries = test_convenience_kinetics() flattened = flatten_timeseries(timeseries) reference_timeseries = load_timeseries( os.path.join(REFERENCE_DATA_DIR, NAME + '.csv')) assert_timeseries_close(flattened, reference_timeseries, tolerances={ 'internal_pyr_c': 9, 'internal_pep_c': 9, 'internal_g6p_c': 9, }) if __name__ == '__main__': out_dir = os.path.join(PROCESS_OUT_DIR, NAME) if not os.path.exists(out_dir): os.makedirs(out_dir) timeseries = test_convenience_kinetics() plot_settings = {} plot_simulation_output(timeseries, plot_settings, out_dir) save_timeseries(timeseries, out_dir)
def toy_plot(data: OutputDict, config: Optional[Dict] = None, out_dir: Optional[str] = 'out') -> None: del config # unused plot_simulation_output(data, out_dir=out_dir)