Skip to content
Snippets Groups Projects
Select Git revision
  • fix_gcc_error
  • master default protected
2 results

GSMM_Simulations.ipynb

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    GSMM_Simulations.ipynb 4.43 KiB

    Calculations of Substrate and Production Rates and Yields

    • Execute a single cell:
    • Execute all cells: Menu: Run Run All Cells
    • To reboot kernel:

    Find more in the reference (menu: Help Jupyter Reference).

    import os
    import pandas as pd
    # import numpy as np
    from datetime import date
    
    import matplotlib.pyplot as plt
    %matplotlib inline
    
    from cobra.io import read_sbml_model, write_sbml_model
    from iambcodes.cobra import *
    

    Data loading and variables setup

    Today = date.today().strftime('%y%m%d')
    BaseDir = '/home/ulf/Documents/Ustilago_maydis-GEM/'
    TargetDir = os.path.join(BaseDir, 'data/Simulations')
    ImageType = 'png'
    SBMLFile = 'iCL1079.xml'
    SBMLAddress = os.path.join(BaseDir, 'model', SBMLFile)
    
    model = read_sbml_model(SBMLAddress)
    model

    Substrate tests

    In the following code, the model is tested for growth rates on defined substrates and the corresponding uptake rates.

    SubNames = ['EX_glc__D_e','EX_glc__D_e','EX_glc__D_e']
    SubRates = [.1, 1, 1.5]
    
    Growth = list()
    for myName, myRate in zip(SubNames, SubRates):
        Growth.append(TestSubstrate(model, EX_Sub_Act=[myName], EX_Sub_Off=['EX_glc__D_e'], Rate=myRate))
        
    plt.plot(SubRates, Growth, 'o')

    Plotting simulation and measured growth

    RCFile = os.path.join(BaseDir,'data','GrowthRates','RatesCompare.xlsx')
    RCSheet = 'RateCompare'
    FigureGrowth = '{}_Growth_SimVsExp.{}'.format(Today, ImageType)
    FigureGrowthPath = os.path.join(TargetDir, FigureGrowth)
    
    RateComp = pd.read_excel(RCFile, sheet_name=RCSheet)
    # Substrate acceleration plot
    plt.errorbar(RateComp['Substrate-uptake'], RateComp['Growth-Rate'], xerr=RateComp['Uptake-Std'], yerr=RateComp['Growth-Rate-Std'], fmt='ok', label='exp. growth rates') #, 'xk', label='Substrate uptake'
    # plt.plot(RateComp['Growth-Rate'], SA_ic+SubAcc*RateComp['Growth-Rate'], '-k', label='fit, accel.{}(+/-{})mmol/gCDW/h/h'.format(round(SubAcc,2), round(SA_sl_sterr,2)))
    plt.title('Growth rate VS substrate uptake')
    plt.xlabel('Substrate uptake in mmol/gCDW/h')
    plt.ylabel('Growth rate in /h')
    plt.plot(SubRates, Growth, 'xr', label='simulations', ms=10, markeredgewidth=3)
    plt.legend()
    plt.savefig(FigureGrowthPath)
    plt.show()
    print('Growth rate versus substrate uptake figure saved as {}'.format(FigureGrowthPath))