Beispiel #1
0
def import_toy_model_from_cobra():
    path_to_model = join(this_directory, '..', 'models/toy_model.mat')

    cobra_model = import_matlab_model(path_to_model)
    #Test the model
    solution = cobra_model.optimize()

    return cobra_model
Beispiel #2
0
            res[rxn._id][i] = optsoln.objective_value
    model.objective = oldobj
    model.objective_direction = olddir
    model.remove_cons_vars(maxcons)

    #sol = pd.DataFrame.from_dict(data=res, orient='index', columns=['minimum','maximum'])
    #sol.to_csv('sol.csv',encoding='utf-8')

    return pd.DataFrame.from_dict(data=res,
                                  orient='index',
                                  columns=['minimum', 'maximum'])


# In[32]:

cobra_model = import_matlab_model(
    'C:/Users/farza/Documents/Master_3/Systemes biology/small_ecoli.mat')
fba_solution = cobra_model.optimize()

thermo_data = load_thermoDB(
    'C:/Users/farza/Documents/Master_3/Systemes biology/thermo_data.thermodb')
tfa_model = pytfa.ThermoModel(thermo_data, cobra_model)
tfa_model.solver = 'optlang-glpk'

tfa_model.prepare()
tfa_model.convert()

## Info on the model
tfa_model.print_info()

## Optimality
tfa_solution = tfa_model.optimize()
from skimpy.core import *
from skimpy.mechanisms import *
from skimpy.utils.namespace import *
from skimpy.sampling.simple_parameter_sampler import SimpleParameterSampler
from skimpy.core.solution import ODESolutionPopulation
from skimpy.io.generate_from_pytfa import FromPyTFA
from skimpy.utils.general import sanitize_cobra_vars
from skimpy.utils.tabdict import TabDict

from skimpy.analysis.oracle import *
""" 
Import and curate a model
"""

this_cobra_model = import_matlab_model('../../models/toy_model.mat', 'model')
""" 
Make tfa model
"""

# Convert to a thermodynamics model
thermo_data = load_thermoDB('../../data/thermo_data.thermodb')
this_pytfa_model = pytfa.ThermoModel(thermo_data, this_cobra_model)

GLPK = 'optlang-glpk'
this_pytfa_model.solver = GLPK

## TFA conversion
this_pytfa_model.prepare()
this_pytfa_model.convert(add_displacement=True)
""" 
Beispiel #4
0
                        if lnmet>min_ln:
                            min_ln = lnmet
        res[met._id] = [min_ln,max_ln]
        tfa_model.log_concentration.get_by_id(met._id).variable.ub = up_b;
        tfa_model.log_concentration.get_by_id(met._id).variable.lb = lo_b;
            
    model.objective = oldobj
    model.objective_direction = olddir
    model.remove_cons_vars(maxcons)
    return pd.DataFrame.from_dict(data=res, orient='index', columns=['minimum','maximum'])





cobra_model = import_matlab_model('C:/users/vicci/Desktop/vcpre/small_ecoli.mat')
fba_solution = cobra_model.optimize()



thermo_data = load_thermoDB('C:/users/vicci/Desktop/vcpre/thermo_data.thermodb')
tfa_model = pytfa.ThermoModel(thermo_data, cobra_model)
tfa_model.solver = 'optlang-glpk'



tfa_model.prepare()
tfa_model.convert()


## Info on the model
Beispiel #5
0
CPLEX = 'optlang-cplex'
GUROBI = 'optlang-gurobi'
GLPK = 'optlang-glpk'
solver = GLPK

case = 'reduced' # 'reduced' or full'

# Load reaction DB
print("Loading thermo data...")

thermo_data = load_thermoDB('../data/thermo_data.thermodb')

print("Done !")

if case == 'reduced':
    cobra_model = import_matlab_model('../models/small_ecoli.mat')
    mytfa = pytfa.ThermoModel(thermo_data, cobra_model)
    biomass_rxn = 'Ec_biomass_iJO1366_WT_53p95M'
elif case == 'full':
    # We import pre-compiled data as it is faster for bigger models
    cobra_model = load_json_model('../models/iJO1366.json')

    lexicon = read_lexicon('../models/iJO1366/lexicon.csv')
    compartment_data = read_compartment_data('../models/iJO1366/compartment_data.json')

    # Initialize the cobra_model
    mytfa = pytfa.ThermoModel(thermo_data, cobra_model)

    # Annotate the cobra_model
    annotate_from_lexicon(mytfa, lexicon)
    apply_compartment_data(mytfa, compartment_data)
Beispiel #6
0
    gly_rxns = [
        'ENO', 'FBA', 'FBP', 'GAPD', 'PDH', 'PFK', 'PGI', 'PGK', 'PGM', 'PPS',
        'PYK', 'TPI'
    ]
    cofactor_regen_rxns = ['NADTRHD', 'NADH16', 'NADTRHD', 'ATPM', 'ATPS4r']
    for x in gly_rxns:
        model.reactions.get_by_id(x).subsystem = 'Glycolysis'
    for x in cofactor_regen_rxns:
        model.reactions.get_by_id(x).subsystem = 'Cofactor Regeneration'

    path_to_params = join(this_directory, '..',
                          'tests/redgem_params_textbook.yaml')

else:
    path_to_model = join(this_directory, '..', 'models/small_ecoli.mat')
    model = import_matlab_model(path_to_model)
    path_to_params = join(this_directory, '..', 'tests/redgem_params.yml')

thermoDB = join(this_directory, '..', 'data/thermo_data.thermodb')
path_to_lexicon = join(this_directory, '..', 'models/iJO1366/lexicon.csv')
path_to_compartment_data = join(this_directory, '..',
                                'models/iJO1366/compartment_data.json')

# Scaling to avoid numerical errors with bad lumps
for rxn in model.reactions:
    if rxn.id.startswith('LMPD_'):
        rxn.add_metabolites(
            {x: v * (0.1 - 1)
             for x, v in rxn.metabolites.items()})

thermo_data = load_thermoDB(thermoDB)