Пример #1
0
def init_cache(request):
    m = request.config.cache.get('small_etfl', None)
    m = create_etfl_model(has_thermo=False,
                          has_neidhardt=False,
                          n_mu_bins=4,
                          optimize=False)
    request.config.cache.set('small_etfl', json_dumps_model(m))
Пример #2
0
def write_conf(model, conf):
    filename = 'outputs/' + conf['tag'] + '/config.yaml'
    conf['objective'] = str(model.objective.expression)
    with open(filename, 'w') as fid:
        yaml.dump(config, fid)


if __name__ == '__main__':
    config = read_config(CONFIG)

    if config['model'] != 'debug':
        model = load_json_model(config['model'],
                                solver=config['options']['solver'])
    else:
        from etfl.tests.small_model import create_etfl_model
        model = create_etfl_model(0, 1, solver=config['options']['solver'])

    standard_solver_config(model)
    model.solver.configuration.verbosity = config['options']['verbose']

    copy_number = int(config['simulation']['copy_number'])
    vector_generator = vec_dict[config['simulation']['vector']]
    has_rnap = config['simulation']['add_rnap']

    my_plasmid = vector_generator(model, has_rnap)

    #####################
    # Model integration #
    #####################

    # 1. Adding RNAP eq constraints
Пример #3
0
        'EX_lcts_e': lac_fun,
        'EX_o2_e': o2_diff,
        'EX_ac_e': ac_fun,
    }

    uptake_funs = get_uptake_funs()

    if not has_lcts:
        medium_funs.pop('EX_lcts_e')
        uptake_funs.pop('EX_lcts_e')

    if config['model'] != 'debug':
        model = load_json_model(config['model'])
    else:
        from etfl.tests.small_model import create_etfl_model
        model = create_etfl_model(0, 0)

    standard_solver_config(model)
    model.solver.configuration.verbosity = 0

    ini_sol = prepare_model(model,
                            v0=config['assumptions']['v0'],
                            S0=config['assumptions']['S0'],
                            uptake_fun=uptake_funs)

    time_data = run_detfl(model=model,
                          yaml_file=CONFIG,
                          ini_sol=ini_sol,
                          uptake_funs=uptake_funs,
                          medium_funs=medium_funs)
Пример #4
0
from etfl.tests.small_model import create_etfl_model
from etfl.optim.config import standard_solver_config
from pytfa.optim.debugging import find_maxed_vars

m = create_etfl_model(0, 1)

mv = find_maxed_vars(m)
from etfl.io.dict import model_to_dict, model_from_dict

dm = model_to_dict(m)

md = model_from_dict(dm)

standard_solver_config(md)

md.optimize()

print(abs(m.solution.objective_value - md.solution.objective_value))

print('Objective            : {}'.format(md.solution.objective_value))
print(' - Glucose uptake    : {}'.format(md.reactions.EX_glc__D_e.flux))
print(' - Growth            : {}'.format(md.growth_reaction.flux))
print(' - Ribosomes produced: {}'.format(md.ribosome.X))
print(' - RNAP produced: {}'.format(md.rnap.X))

print(mv)

assert abs(m.solution.objective_value - md.solution.objective_value
           ) < md.solver.configuration.tolerances.optimality
Пример #5
0
        mus.append(sol)

    return ramp, mus


for o in [growth] + objs:
    result[o] = pd.DataFrame(index=scales, columns=scales)

for k in scales:
    prot_scale = 10**k

    for l in range(k, max(scales) + 1):
        mrna_scale = 10**l

        model[k, l] = create_etfl_model(has_thermo=True,
                                        has_neidhardt=False,
                                        mrna_scaling=mrna_scale,
                                        prot_scaling=prot_scale)
        this_model = model[k, l]

        mincoeff = model[k, l].solver.problem.MinCoeff
        maxcoeff = model[k, l].solver.problem.MaxCoeff

        if not hasattr(this_model, 'solution'):

            result[growth].loc[k, l] = np.nan
            for o in objs:
                result[o].loc[k, l] = np.nan
                ramp_results[k, l] = glucose_ramp(this_model)
            continue

        coeffs[k, l] = (mincoeff, maxcoeff, np.log10(maxcoeff / mincoeff))
Пример #6
0
def test_thermo():
    create_etfl_model(has_thermo=False,
                      has_neidhardt=True,
                      n_mu_bins=4,
                      optimize=False)