def convert_cobra_to_tfa(cobra_model): """ Make tfa analysis of the model """ path_to_data = join(this_directory, '..', 'data/thermo_data.thermodb') thermo_data = load_thermoDB(path_to_data) tmodel = pytfa.ThermoModel(thermo_data, cobra_model) # for comp in tmodel.compartments.values(): # comp['c_min'] = 1e-8 tmodel.prepare() tmodel.convert(add_displacement=True) # Set the solver tmodel.solver = GLPK # Set solver options # GLPK option optimality and integrality deprecated #tmodel.solver.configuration.tolerances.optimality = 1e-9 #tmodel.solver.configuration.tolerances.integrality = 1e-9 tmodel.solver.configuration.tolerances.feasibility = 1e-9 # Find a solution solution = tmodel.optimize() return tmodel
def convert2thermo(model, name): # Initialize the model tmodel = pytfa.ThermoModel(thermo_data, model) tmodel.name = name # Annotate the model annotate_from_lexicon(tmodel, lexicon) apply_compartment_data(tmodel, compartment_data) ## TFA conversion tmodel.prepare() tmodel.convert() tmodel.solver = solver return tmodel
#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() # integrating metabolomics data (comment out this part if not integrating) df = pd.read_csv('metabolomics_data.csv', sep=';') df['model ID'] = df['model ID'].astype(str)
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) """ Generate a draft Kinetic Model """ # Generate the KineticModel # Define the molecules that should be considered small-molecules # These molecules will not be accounted explicitly in the kinetic mechanism as