Example #1
0
def test_txp_mtb_ge():
    default_test_setting = {
        'environment': {
            'volume': 1e-12 * units.L,
            'ports': {
                'exchange': (
                    'boundary',
                    'exchange',
                ),
                'external': ('boundary', 'external'),
            }
        },
        'timestep': 1,
        'total_time': 10
    }

    compartment = TransportMetabolism({})
    return simulate_compartment_in_experiment(compartment,
                                              default_test_setting)
def test_txp_mtb_ge():
    default_test_setting = {
        'environment': {
            'volume': 1e-12 * units.L,
            'ports': {
                'fields': ('fields', ),
                'external': ('boundary', 'external'),
                'dimensions': ('dimensions', ),
                'global': ('boundary', ),
            }
        },
        'timestep': 1,
        'total_time': 10
    }

    agent_id = '0'
    compartment = TransportMetabolism({'agent_id': agent_id})
    return simulate_compartment_in_experiment(compartment,
                                              default_test_setting)
Example #3
0
def test_master():
    # load the compartment
    compartment_config = {
        'external_path': ('external',),
        'global_path': ('global',),
        'agents_path': ('..', '..', 'cells',),
        'transcription': {
            'sequence': toy_chromosome_config['sequence'],
            'templates': toy_chromosome_config['promoters'],
            'genes': toy_chromosome_config['genes'],
            'promoter_affinities': toy_chromosome_config['promoter_affinities'],
            'transcription_factors': ['tfA', 'tfB'],
            'elongation_rate': 10.0}}
    compartment = Master(compartment_config)

    # simulate
    settings = {
        'timestep': 1,
        'total_time': 10}
    return simulate_compartment_in_experiment(compartment, settings)
def test_expression_chemotaxis(
        n_flagella=5,
        total_time=10,
        out_dir='out'
):
    # make the compartment
    config = get_baseline_config(n_flagella)
    compartment = ChemotaxisExpressionFlagella(config)

    # save the topology network
    plot_compartment_topology(compartment, {}, out_dir)

    # run experiment
    initial_state = get_flagella_initial_state({
        'molecules': 'internal'})
    timeline = get_timeline(total_time=total_time)
    experiment_settings = {
        'initial_state': initial_state,
        'timeline': {
            'timeline': timeline,
            'ports': {'external': ('boundary', 'external')}},
    }
    timeseries = simulate_compartment_in_experiment(
        compartment,
        experiment_settings)

    print_growth(timeseries)

    # plot
    plot_timeseries(timeseries, out_dir)

    # gene expression plot
    plot_config = {
        'ports': {
            'transcripts': 'transcripts',
            'proteins': 'proteins',
            'molecules': 'internal'}}
    plot_gene_expression_output(
        timeseries,
        plot_config,
        out_dir)
Example #5
0
def test_inclusion_body(total_time=1000):
    agent_id = '0'
    parameters = {
        'agent_id': agent_id,
        'inclusion_process': {
            'damage_rate': 1e-4,  # rapid damage
        },
        'growth_rate': {
            'growth_rate': 0.001  # fast growth
        },
    }
    compartment = InclusionBodyGrowth(parameters)

    initial_state = compartment.initial_state()

    # settings for simulation and plot
    settings = {
        'initial_state': {'agents': {agent_id: initial_state}},
        'outer_path': ('agents', agent_id),
        'return_raw_data': True,
        'timestep': 1,
        'total_time': total_time}
    return simulate_compartment_in_experiment(compartment, settings)
def run_chemotaxis_master(out_dir):
    total_time = 10

    # make the compartment
    compartment = ChemotaxisMaster({})

    # save the topology network
    settings = {'show_ports': True}
    plot_compartment_topology(compartment, settings, out_dir)

    # run an experinet
    settings = {'timestep': 1, 'total_time': total_time}
    timeseries = simulate_compartment_in_experiment(compartment, settings)

    volume_ts = timeseries['boundary']['volume']
    print('growth: {}'.format(volume_ts[-1] / volume_ts[0]))

    # plots
    # simulation output
    plot_settings = {
        'max_rows': 40,
        'remove_zeros': True,
        'skip_ports': ['reactions', 'prior_state', 'null']
    }
    plot_simulation_output(timeseries, plot_settings, out_dir)

    # gene expression plot
    gene_exp_plot_config = {
        'name': 'flagella_expression',
        'ports': {
            'transcripts': 'transcripts',
            'proteins': 'proteins',
            'molecules': 'internal'
        }
    }
    plot_gene_expression_output(timeseries, gene_exp_plot_config, out_dir)
def test_master():
    master = load_master()
    # simulate
    settings = {'timestep': 1, 'total_time': 10}
    return simulate_compartment_in_experiment(master, settings)
def test_chemotaxis_master(total_time=5):
    compartment = ChemotaxisMaster({})
    settings = {'timestep': 1, 'total_time': total_time}
    return simulate_compartment_in_experiment(compartment, settings)
    if not os.path.exists(out_dir):
        os.makedirs(out_dir)

    agent_id = '0'
    compartment = GrowthDivision({'agent_id': agent_id})

    # settings for simulation and plot
    settings = {
        'environment': {
            'volume': 1e-6 * units.L,  # L
            'ports': {
                'fields': ('fields', ),
                'external': (
                    'boundary',
                    'external',
                ),
                'global': ('boundary', ),
                'dimensions': ('dimensions', ),
            },
        },
        'outer_path':
        ('agents', agent_id),  # TODO -- need to set the agent_id through here?
        'return_raw_data': True,
        'timestep': 1,
        'total_time': 500
    }
    output_data = simulate_compartment_in_experiment(compartment, settings)

    plot_settings = {}
    plot_agents_multigen(output_data, plot_settings, out_dir)
        'external_path': environment_port
    }
    compartment = ChemotaxisMinimal(get_chemotaxis_config(config))

    # run experiment
    experiment_settings = {
        'timeline': {
            'timeline':
            get_exponential_random_timeline(exponential_random_config),
            'ports': {
                'external': ('boundary', 'external')
            }
        },
        'timestep': 0.01,
        'total_time': 100
    }
    timeseries = simulate_compartment_in_experiment(compartment,
                                                    experiment_settings)

    # plot settings for the simulations
    plot_settings = {
        'max_rows': 20,
        'remove_zeros': True,
        'overlay': {
            'reactions': 'flux'
        },
        'skip_ports': ['prior_state', 'null', 'global']
    }
    plot_simulation_output(timeseries, plot_settings, out_dir,
                           'exponential_timeline')
Example #11
0
def simulate_txp_mtb_ge(config={}, out_dir='out'):

    end_time = 2520  # 2520 sec (42 min) is the expected doubling time in minimal media
    environment_volume = 1e-14
    timeline = [
        (0, {
            ('external', 'glc__D_e'): 3.0,
            ('external', 'lcts_e'): 3.0,
        }),
        # (500, {
        #     ('external', 'glc__D_e'): 0.0,
        #     ('external', 'lcts_e'): 3.0,
        # }),
        (end_time, {})
    ]

    sim_settings = {
        'environment': {
            'volume': environment_volume * units.L,
            'ports': {
                'external': ('boundary', 'external'),
                'exchange': ('boundary', 'exchange'),
            }
        },
        'timeline': {
            'timeline': timeline,
            'ports': {
                'external': ('boundary', 'external')
            }
        }
    }

    # run simulation
    compartment = TransportMetabolism({})
    timeseries = simulate_compartment_in_experiment(compartment, sim_settings)

    # calculate growth
    volume_ts = timeseries['boundary']['volume']
    try:
        print('growth: {}'.format(volume_ts[-1] / volume_ts[0]))
    except:
        print('no volume!')

    ## plot
    # diauxic plot
    settings = {
        'internal_path': ('cytoplasm', ),
        'external_path': ('boundary', 'external'),
        'global_path': ('boundary', ),
        'exchange_path': ('boundary', 'exchange'),
        'environment_volume': 1e-13,  # L
        # 'timeline': timeline
    }
    plot_diauxic_shift(timeseries, settings, out_dir)

    # simulation plot
    plot_settings = {
        'max_rows': 30,
        'remove_zeros': True,
        'skip_ports': ['null', 'reactions'],
    }
    plot_simulation_output(timeseries, plot_settings, out_dir)