コード例 #1
0
def split_factor(particle, Ts, sigma):

    df, new_params = format_input(particle)
    dfparam = etc.calculate_thermal_params(new_params)

    results = dict()  # results = {'etcYeast7':[]}

    # Case (1) No temperature constraints
    model = pickle.load(open('../models/aerobic.pkl', 'rb'))
    with model as m:
        etc.set_sigma(m, sigma)
        r = m.optimize().objective_value
        results['ori'] = [r for T in Ts]
        print('Case 1:', results['ori'])

    # Case (2) based on (1) Include the temperature dependent NGAM
    model = pickle.load(open('../models/aerobic.pkl', 'rb'))
    for T in Ts:
        with model as m:
            etc.set_NGAMT(m, T)
            etc.set_sigma(m, sigma)

            r = m.optimize().objective_value
            results['NGAM'] = results.get('NGAM', []) + [r]
    print('Case 2:', results['NGAM'])

    # Case (3) based on (1) Include the temperatuer dependent kcat
    model = pickle.load(open('../models/aerobic.pkl', 'rb'))
    for T in Ts:
        with model as m:
            etc.map_kcatT(m, T, dfparam)
            etc.set_sigma(m, sigma)

            r = m.optimize().objective_value
            results['kcat'] = results.get('kcat', []) + [r]
    print('Case 3:', results['kcat'])

    # Case (4) based on (1) Include the temperature dependent unfolding process
    model = pickle.load(open('../models/aerobic.pkl', 'rb'))
    for T in Ts:
        with model as m:
            etc.map_fNT(m, T, dfparam)
            etc.set_sigma(m, sigma)

            try:
                r = m.optimize().objective_value
            except:
                r = None
            results['unfolding'] = results.get('unfolding', []) + [r]

    print('Case 4:', results['unfolding'])

    # Case (5) with all constraints
    model = pickle.load(open('../models/aerobic.pkl', 'rb'))
    results['etc'] = etc.simulate_growth(model, Ts, sigma, dfparam)
    print('Case 5:', results['etc'])

    return results
コード例 #2
0
ファイル: GEMS.py プロジェクト: SysBioChalmers/BayesianGEM
def format_input(thermalParams):
    new_params = params.copy()
    for key,val in thermalParams.items():
        [ind,col] = key.split('_')
        new_params.loc[ind,col] = val
    
    # Update T90
    new_params['T90'] = params['T90']-params['Tm'] + new_params['Tm']

    df = etc.calculate_thermal_params(new_params)
    return df,new_params
コード例 #3
0
def do_fcc_at_T(T,params,sigma,delta):
    # Ts:     temperatures at which simulation will be performed
    # params: a dataframe with Topt, Tm, T90, dCpt of all enzymes
    # sigma:  enzyme saturation factor
    # delta:  the fold change to be made for kcat of each enzyme
    #
    # return a dataframe with temperature as column and enzyme id as index
    
    model = pickle.load(open('../models/aerobic.pkl','rb'))
    
    # 1. Calculate thermal parameters
    dfparam = etc.calculate_thermal_params(params)
    enzymes = list(set([met.id for met in model.metabolites 
                        if met.id.startswith('prot_') and met.id != 'prot_pool']))
    
    # 2. do fcc at each temperature
    data = dict()
    
    etc.map_fNT(model,T,dfparam)
    etc.map_kcatT(model,T,dfparam)
    etc.set_NGAMT(model,T)
    etc.set_sigma(model,sigma)

    # Get all enzymes
    try:    u0 = model.optimize().objective_value
    except: u0 = None
    print('Model Track u0:',T,u0)
    for enz_id in enzymes: 
        if u0 is None or u0 == 0: data[enz_id.split('_')[1]] = None
        else:
            with model as m:
                enz = m.metabolites.get_by_id(enz_id)
                # Perturbe kcat in all reactions of this enzyme 
                for rxn in enz.reactions:
                    if rxn.id.startswith('draw_'): continue
                    new_coeff = rxn.get_coefficient(enz)/(1+delta)
                    etc.change_rxn_coeff(rxn,enz,new_coeff)
                try:u = m.optimize().objective_value
                except: u = None
                
                if u is None: fc = None
                else: fc = (u-u0)/u0/delta

                data[enz.id.split('_')[1]] = fc

    # 3. Create a dataframe with temperature as column and enzyme ids as index
    lst, index = [], []
    for k,v in data.items():
        lst.append(v)
        index.append(k)
    dfres = pd.DataFrame(data={T:lst},index=index)
    return dfres        
コード例 #4
0
def format_input(thermalParams):
    # thermalParams: a dictionary with ids like uniprotid_Topt
    params = pd.read_csv('../data/model_enzyme_params.csv', index_col=0)
    new_params = params.copy()
    for key, val in thermalParams.items():
        [ind, col] = key.split('_')
        new_params.loc[ind, col] = val

    # Update T90
    new_params['T90'] = params['T90'] - params['Tm'] + new_params['Tm']

    df = etc.calculate_thermal_params(new_params)
    return df, new_params