コード例 #1
0
ファイル: test_ORACLE.py プロジェクト: EPFL-LCSB/skimpy
def test_oracle_ode():

    # Initialize parameter sampler
    sampling_parameters = SimpleParameterSampler.Parameters(n_samples=1)
    sampler = SimpleParameterSampler(sampling_parameters)

    # Sample the model
    parameter_population = sampler.sample(kmodel, flux_dict,
                                          concentration_dict)

    kmodel.compile_ode(sim_type=QSSA)
    kmodel.initial_conditions = TabDict([
        (k, v) for k, v in concentration_dict.items()
    ])

    solutions = []
    for parameters in parameter_population:
        kmodel.parameters = parameters
        this_sol_qssa = kmodel.solve_ode(np.linspace(0.0, 10.0, 1000),
                                         solver_type='cvode')
        solutions.append(this_sol_qssa)

    this_sol_qssa.plot('test.html')

    solpop = ODESolutionPopulation(solutions)
コード例 #2
0
ファイル: test_ORACLE.py プロジェクト: EPFL-LCSB/skimpy
def test_oracle_parameter_sampling():

    # Initialize parameter sampler
    sampling_parameters = SimpleParameterSampler.Parameters(n_samples=100)
    sampler = SimpleParameterSampler(sampling_parameters)

    # Sample the model
    parameter_population = sampler.sample(kmodel, flux_dict,
                                          concentration_dict)
コード例 #3
0
ファイル: test_ORACLE.py プロジェクト: EPFL-LCSB/skimpy
def test_oracle_mca():

    # Initialize parameter sampler
    sampling_parameters = SimpleParameterSampler.Parameters(n_samples=1)
    sampler = SimpleParameterSampler(sampling_parameters)

    # Sample the model
    parameter_population = sampler.sample(kmodel, flux_dict,
                                          concentration_dict)
    """
    Calculate control coefficients 
    """
    flux_control_coeff = kmodel.flux_control_fun(flux_dict, concentration_dict,
                                                 parameter_population)

    concentration_control_coeff = kmodel.concentration_control_fun(
        flux_dict, concentration_dict, parameter_population)
コード例 #4
0
ファイル: test_sampling.py プロジェクト: EPFL-LCSB/skimpy
def test_parameter_sampling_linear_pathway():
    this_model = build_linear_pathway_model()

    this_model.prepare(mca=True)
    this_model.compile_mca(sim_type=QSSA)

    flux_dict = {'E1': 1.0, 'E2': 1.0, 'E3': 1.0}
    concentration_dict = {'A': 10.0, 'B': 5.0, 'C': 1.0, 'D': 0.05}

    parameters = SimpleParameterSampler.Parameters(n_samples=10)
    sampler = SimpleParameterSampler(parameters)

    parameter_population_A = sampler.sample(this_model,
                                            flux_dict,
                                            concentration_dict,
                                            seed=10)

    parameter_population_B = sampler.sample(this_model,
                                            flux_dict,
                                            concentration_dict,
                                            seed=10)

    parameter_population_C = sampler.sample(this_model,
                                            flux_dict,
                                            concentration_dict,
                                            seed=20)

    assert (parameter_population_A == parameter_population_B)
    assert (not (parameter_population_B == parameter_population_C))
コード例 #5
0
this_model.parametrize_by_reaction({
    'E1': parameters_1,
    'E2': parameters_2,
    'E3': parameters_3
})

this_model.prepare(mca=True)
#this_model.compile_mca()

this_model.compile_jacobian(type=SYMBOLIC, sim_type=QSSA)

flux_dict = {'E1': 1.0, 'E2': 1.0, 'E3': 1.0}
concentration_dict = {'A': 3.0, 'B': 2.0, 'C': 1.0, 'D': 0.5}

parameters = SimpleParameterSampler.Parameters(n_samples=10)
sampler = SimpleParameterSampler(parameters)

parameter_population = sampler.sample(this_model, flux_dict,
                                      concentration_dict)

#this_model.compile_ode(sim_type = QSSA)

# TODO can change this back to this_model.initial_conditions.A = 3.0 once
# tabdict is fixed
this_model.initial_conditions['A'] = 3.0
this_model.initial_conditions['B'] = 2.0
this_model.initial_conditions['C'] = 3.0
this_model.initial_conditions['D'] = 0.5

solutions = []
コード例 #6
0
ファイル: tutorial_GMCA.py プロジェクト: EPFL-LCSB/skimpy

def calculate_model_output(model_parameters):
    # calculate all flux control coefficients
    flux_control_coeff_0 = kmodel.flux_control_fun(fluxes, concentrations,
                                                   model_parameters._data)

    # Choose a particular reaction we want to analyse
    df = flux_control_coeff_0.slice_by('flux', 'ENO')
    # Select only some of the Vmax's
    df = df[df.index.isin(outputs_to_analyse)]
    return df


# Initialize parameter sampler
sampling_parameters = SimpleParameterSampler.Parameters(n_samples=200)
sampler = SimpleParameterSampler(sampling_parameters)

# Sample the model (A matrix)
parameter_population = sampler.sample(kmodel, fluxes, concentrations)
parameter_population = ParameterValuePopulation(parameter_population, kmodel)

# Construct B,C matrices given parameter_population and parameters_to_resample
parameters_to_resample = [[
    kmodel.parameters.km_substrate_ENO,
], [
    kmodel.parameters.km_product_ENO,
], [
    kmodel.parameters.km_substrate_PGM,
], [
    kmodel.parameters.km_product_PGM,
コード例 #7
0
path_to_kmodel = './../../models/kin_varma.yml'
path_for_output = './output/paramter_pop_{}.h5'
kmodel = load_yaml_model(path_to_kmodel)

# Perp and compile to sample parameters
kmodel.prepare()
kmodel.compile_jacobian(ncpu=NCPU)

# Constraint glucose transporter KMs
kmodel.reactions.GLCptspp.parameters.km_substrate2.bounds = (14.99, 15.01)




sampler_params = SimpleParameterSampler.Parameters(n_samples=N_PARAMETER_SAMPLES)
sampler = SimpleParameterSampler(sampler_params)

lambda_max_all = []
lambda_min_all = []

S = get_stoichiometry(kmodel, kmodel.reactants).todense()

from skimpy.utils.namespace import *
from skimpy.analysis.ode.utils import make_flux_fun
fluxfun= make_flux_fun(kmodel, QSSA)
fluxes = []

for i, sample in samples.iterrows():
    # Load fluxes and concentrations
    fluxes = load_fluxes(sample, tmodel, kmodel,
コード例 #8
0
    k: sanitize_cobra_vars(v)
    for k, v in zip(variable_names, metabolite_ids)
}
concentration_dict = {
    mapping_dict[k]: v
    for k, v in temp_concentration_dict.items()
}
"""
Sample the kinetic parameters based on linear stablity 
"""
this_skimpy_model.prepare(mca=True)
# Compile MCA functions
this_skimpy_model.compile_mca(sim_type=QSSA)

# Initialize parameter sampler
sampling_parameters = SimpleParameterSampler.Parameters(n_samples=5)
sampler = SimpleParameterSampler(sampling_parameters)

# Sample the model
parameter_population = sampler.sample(this_skimpy_model, flux_dict,
                                      concentration_dict)
"""
Calculate control coefficients
"""
parameter_list = TabDict([(k, p.symbol)
                          for k, p in this_skimpy_model.parameters.items()
                          if p.name.startswith('vmax_forward')])

this_skimpy_model.compile_mca(sim_type=QSSA, parameter_list=parameter_list)

flux_control_coeff = this_skimpy_model.flux_control_fun(