{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"run_control": {
"marked": true
}
},
"source": [
"# Input, output fluxes and flux of energy in C3 metabolism"
]
},
{
"cell_type": "markdown",
"metadata": {
"run_control": {
"marked": true
}
},
"source": [
"## 0. Initialization"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"ExecuteTime": {
"end_time": "2019-05-06T13:44:14.368690Z",
"start_time": "2019-05-06T15:44:09.283556+02:00"
},
"code_folding": [],
"collapsed": false,
"run_control": {
"marked": true
}
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"//anaconda/lib/python2.7/site-packages/cryptography/hazmat/primitives/constant_time.py:26 \u001b[1;31mCryptographyDeprecationWarning\u001b[0m: Support for your Python version is deprecated. The next version of cryptography will remove support. Please upgrade to a 2.7.x release that supports hmac.compare_digest as soon as possible.\n"
]
},
{
"data": {
"text/html": [
" \n",
" "
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"load obo file ../src/go_basic.obo\n",
"../src/go_basic.obo: fmt(1.2) rel(2017-10-20) 49,155 GO Terms\n"
]
}
],
"source": [
"#Import sys\n",
"import sys \n",
"sys.path.append(\"../src/\") \n",
"\n",
"#Import init for initialisation & loading user-defined functions\n",
"from init_fba import *\n",
"\n",
"#Initialize notebook settings\n",
"theNotebook = '2019-05-06-mb-genC3'\n",
"init_notebook(theNotebook)\n",
"\n",
"#load sbml model\n",
"c3_model = load_sbml_model()\n",
"\n",
"#goatools\n",
"from goatools import obo_parser\n",
"goDB = obo_parser.GODag('../src/go_basic.obo')"
]
},
{
"cell_type": "markdown",
"metadata": {
"ExecuteTime": {
"end_time": "2017-06-07T15:40:14.346980",
"start_time": "2017-06-07T15:40:14.344930"
},
"run_control": {
"marked": true
}
},
"source": [
"### 0.1 Functions"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"ExecuteTime": {
"end_time": "2019-05-06T13:44:14.408139Z",
"start_time": "2019-05-06T15:44:14.370310+02:00"
},
"code_folding": [],
"collapsed": true
},
"outputs": [],
"source": [
"def proportion_E_consumption(L_m, name, save_fig = True):\n",
" D_E_Con_RXN = {}\n",
" L_r_E_Con = []\n",
"\n",
"\n",
" for m_id in L_m:\n",
" for r_obj in c3_model.metabolites.get_by_id(m_id).reactions:\n",
" r_id = r_obj.id\n",
" if not r_id[:2] in ['Tr','Ex','Im'] :\n",
" flux = round(result_pfba_c3.fluxes[r_id] * r_obj.get_coefficient(m_id),5)\n",
" if flux < 0 :\n",
" L_r_E_Con.append(r_id)\n",
" D_E_Con_RXN[r_id] = abs(flux)\n",
"\n",
" E_Con_Total = sum(D_E_Con_RXN.values())\n",
"\n",
" D_E_Con_goTerm = {}\n",
" for r_id in D_E_Con_RXN:\n",
" r_obj = c3_model.reactions.get_by_id(r_id)\n",
" L_goId = r_obj.annotation['go']\n",
" if not isinstance(L_goId, list):\n",
" L_goId = [L_goId]\n",
" L_goTerm = [goDB[goId].name for goId in L_goId]\n",
" if not L_goTerm[0] in D_E_Con_goTerm:\n",
" D_E_Con_goTerm[L_goTerm[0]] = 0\n",
" D_E_Con_goTerm[L_goTerm[0]] += D_E_Con_RXN[r_id]\n",
"\n",
"\n",
" D_E_Con_goTerm = {goTerm: flux for goTerm, flux in D_E_Con_goTerm.items() if flux/E_Con_Total > 0.01}\n",
" D_E_Con_goTerm['Others'] = E_Con_Total - sum(D_E_Con_goTerm.values())\n",
"\n",
" trace = go.Pie(\n",
" labels = D_E_Con_goTerm.keys(),\n",
" values = D_E_Con_goTerm.values(),\n",
" textfont=dict(size=18,family='Arial',),\n",
" marker=dict(colors=[D_goTerm_col[goTerm] for goTerm in D_E_Con_goTerm],\n",
" line=dict(color='#FFF', width=1)),\n",
" )\n",
"\n",
" data = [trace]\n",
"\n",
" layout = go.Layout(\n",
" height=600, \n",
" width=750,\n",
" title='Proportion of %s Consumption' %name\n",
" )\n",
"\n",
" fig = go.Figure(data=data, layout=layout)\n",
" \n",
" if save_fig:\n",
" iplot(fig,filename='%s_consumption' %name, image='svg',image_height=500,image_width=750)\n",
" sleep(5)\n",
" else:\n",
" iplot(fig)\n",
" return E_Con_Total"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"ExecuteTime": {
"end_time": "2019-05-06T13:44:14.442256Z",
"start_time": "2019-05-06T15:44:14.409813+02:00"
},
"code_folding": [],
"collapsed": true
},
"outputs": [],
"source": [
"def proportion_E_production(L_m, name, savefig = True):\n",
"\n",
"\n",
" D_E_Pro_RXN = {}\n",
" L_r_E_Pro = []\n",
"\n",
"\n",
" for m_id in L_m:\n",
" for r_obj in c3_model.metabolites.get_by_id(m_id).reactions:\n",
" r_id = r_obj.id\n",
" if not r_id[:2] in ['Tr','Ex','Im'] :\n",
" flux = round(result_pfba_c3.fluxes[r_id] * r_obj.get_coefficient(m_id),5)\n",
" if flux > 0 :\n",
" L_r_E_Pro.append(r_id)\n",
" D_E_Pro_RXN[r_id] = abs(flux)\n",
"\n",
" E_Pro_Total = sum(D_E_Pro_RXN.values())\n",
"\n",
" D_E_Pro_goTerm = {}\n",
" for r_id in D_E_Pro_RXN:\n",
" r_obj = c3_model.reactions.get_by_id(r_id)\n",
" L_goId = r_obj.annotation['go']\n",
" if not isinstance(L_goId, list):\n",
" L_goId = [L_goId]\n",
" L_goTerm = [goDB[goId].name for goId in L_goId]\n",
" if not L_goTerm[0] in D_E_Pro_goTerm:\n",
" D_E_Pro_goTerm[L_goTerm[0]] = 0\n",
" D_E_Pro_goTerm[L_goTerm[0]] += D_E_Pro_RXN[r_id]\n",
"\n",
"\n",
" D_E_Pro_goTerm = {goTerm: flux for goTerm, flux in D_E_Pro_goTerm.items() if flux/E_Pro_Total > 0.01}\n",
" D_E_Pro_goTerm['Others'] = E_Pro_Total - sum(D_E_Pro_goTerm.values())\n",
"\n",
" trace = go.Pie(\n",
" labels = D_E_Pro_goTerm.keys(),\n",
" values = D_E_Pro_goTerm.values(),\n",
" textfont=dict(size=18,family='Arial',),\n",
" marker=dict(colors=[D_goTerm_col[goTerm] for goTerm in D_E_Pro_goTerm],\n",
" line=dict(color='#FFF', width=1)),\n",
" )\n",
"\n",
"\n",
"\n",
" data = [trace]\n",
"\n",
" layout = go.Layout(\n",
" height=600, \n",
" width=750,\n",
" title='Proportion of %s Production' %name\n",
" )\n",
"\n",
" fig = go.Figure(data=data, layout=layout)\n",
" \n",
" if save_fig:\n",
" iplot(fig,filename='%s_Production' %name,image='svg',image_height=500,image_width=750)\n",
" sleep(5)\n",
" else:\n",
" iplot(fig)\n",
" return E_Pro_Total"
]
},
{
"cell_type": "markdown",
"metadata": {
"run_control": {
"marked": true
}
},
"source": [
"## 1. C3 Model"
]
},
{
"cell_type": "markdown",
"metadata": {
"ExecuteTime": {
"end_time": "2017-06-20T12:42:07.597174",
"start_time": "2017-06-20T12:42:07.594879"
},
"run_control": {
"marked": true
}
},
"source": [
"### 1.1 Constraints"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"ExecuteTime": {
"end_time": "2019-05-06T13:44:14.462896Z",
"start_time": "2019-05-06T15:44:14.443774+02:00"
},
"collapsed": false,
"run_control": {
"marked": true
}
},
"outputs": [],
"source": [
"#CONSTRAINT: Set flux of all export reaction to zero\n",
"for r_obj in c3_model.reactions:\n",
" r_id = r_obj.id\n",
" if r_id[0:2] == \"Ex\":\n",
" r_obj.bounds = (0.,0.)\n",
"\n",
"#CONSTRAINT: Divergent fluxes of export and import reactions\n",
"set_bounds('Im_CO2', (-inf, inf), c3_model)\n",
"set_bounds('Im_H2O', (-inf, inf), c3_model)\n",
"set_bounds('Im_H2S', (0.,0.), c3_model)\n",
"set_bounds('Im_NH4', (0., 0.), c3_model)\n",
"set_bounds('Im_NO3', (0., inf), c3_model)\n",
"set_bounds('Im_Pi', (0., inf), c3_model)\n",
"set_bounds('Im_SO4', (0., inf), c3_model)\n",
"set_bounds('Ex_O2', (-inf, inf), c3_model)\n",
"set_bounds('Ex_Suc', (0., inf), c3_model)\n",
"set_bounds('Ex_starch', (0., inf), c3_model)\n",
"set_bounds('Ex_AA', (0., inf), c3_model)\n",
"\n",
"#CONSTRAINT: ???\n",
"set_bounds('G6PDH_h', (0.,0.), c3_model)\n",
"set_bounds('PPIF6PK_c', (0,0.), c3_model)\n",
"\n",
"#CONSTRAINT: max. photon consumption 1000 μE\n",
"set_bounds('Im_hnu', (0, 1000), c3_model)\n",
"\n",
"#CONSTRAINT: CO2 uptake rate in C3 plants is about 20 μmol/(m2*s)\n",
"f_CO2 = 20 #[μmol/(m2*s)] \n",
"set_bounds('Im_CO2', (0, f_CO2), c3_model)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"ExecuteTime": {
"end_time": "2019-05-06T13:44:14.468980Z",
"start_time": "2019-05-06T15:44:14.464788+02:00"
},
"code_folding": [],
"collapsed": false,
"run_control": {
"marked": true
}
},
"outputs": [],
"source": [
"#CONSTRAINT: Maintenace cost\n",
"\n",
"atp_cost_L3_m = 0.009111187245501572 #Mitochondria-L3-ATP Cost [µmol*s-1*m-2]\n",
"atp_cost_L3_h = 0.15270708327974447 #Chloroplast-L3-ATP Cost [µmol*s-1*m-2]\n",
"atp_cost_L3_p = 0.0076669066992201855 #Peroxisome-L3-ATP Cost [µmol*s-1*m-2]\n",
"atp_cost_L3_c = 0.042683072918274702 #Cytosl/Other-L3-ATP Cost [µmol*s-1*m-2]\n",
"\n",
"set_fixed_flux('NGAM_c',atp_cost_L3_c + atp_cost_L3_p, c3_model)\n",
"set_fixed_flux('NGAM_m',atp_cost_L3_m, c3_model)\n",
"set_fixed_flux('NGAM_h',atp_cost_L3_h, c3_model)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"ExecuteTime": {
"end_time": "2019-05-06T13:44:14.483243Z",
"start_time": "2019-05-06T15:44:14.471168+02:00"
},
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
""
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#CONSTRAINT: Output of sucrose : total amino acid and sucrose : starch\n",
"set_fixed_flux_ratio({'Ex_Suc':2.2,'Ex_AA':1.0}, c3_model)\n",
"set_fixed_flux_ratio({'Ex_Suc':1.0,'Ex_starch':1.0}, c3_model)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"ExecuteTime": {
"end_time": "2019-05-06T13:44:14.491883Z",
"start_time": "2019-05-06T15:44:14.484583+02:00"
},
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
""
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#CONSTRAINT: oxygenation : decarboxylation = 1 : 10\n",
"set_fixed_flux_ratio({'RBC_h':10,'RBO_h':1}, c3_model)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"ExecuteTime": {
"end_time": "2019-05-06T13:44:14.497069Z",
"start_time": "2019-05-06T15:44:14.493756+02:00"
},
"collapsed": false,
"run_control": {
"marked": true
}
},
"outputs": [],
"source": [
"#CONSTRAINT: fluxes through the chloroplastic NADPH dehydrogenase and plastoquinol oxidase were set to zero \n",
"#because the contributions of NADPH dehydrogenase (Yamamoto et al., 2011) and plastoquinol oxidase \n",
"#(Josse et al., 2000) to photosynthesis are thought to be minor.\n",
"set_bounds('AOX4_h',(0,0), c3_model)\n",
"set_bounds('iCitDHNADP_h',(0,0), c3_model)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"ExecuteTime": {
"end_time": "2019-05-06T13:44:14.501036Z",
"start_time": "2019-05-06T15:44:14.498590+02:00"
},
"collapsed": true
},
"outputs": [],
"source": [
"#CONSTRAINT: NTT is only active at night\n",
"set_fixed_flux('Tr_NTT',0, c3_model)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"ExecuteTime": {
"end_time": "2019-05-06T13:44:14.506120Z",
"start_time": "2019-05-06T15:44:14.502906+02:00"
},
"collapsed": true
},
"outputs": [],
"source": [
"#CONSTRAINT: No uncoupled pyruvate transport\n",
"set_bounds('Tr_Pyr1',(0,0), c3_model)\n",
"set_bounds('Tr_Pyr2',(0,0), c3_model)"
]
},
{
"cell_type": "markdown",
"metadata": {
"run_control": {
"marked": true
}
},
"source": [
"## 2. FBA"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"ExecuteTime": {
"end_time": "2019-05-06T13:44:14.714462Z",
"start_time": "2019-05-06T15:44:14.507900+02:00"
},
"collapsed": false,
"run_control": {
"marked": true
}
},
"outputs": [],
"source": [
"#Set FBA solver\n",
"c3_model.solver = \"glpk\"\n",
"\n",
"#Optimize/Maximize sucrose output\n",
"Ex_Suc = c3_model.reactions.get_by_id(\"Ex_Suc\")\n",
"Ex_Suc.objective_coefficient = 1.\n",
"result_fba_c3 = c3_model.optimize('maximize') #perform FBA\n",
"\n",
"\n",
"#Optimize/Minimize total flux\n",
"if result_fba_c3.status == 'optimal': # check if feasible\n",
" result_pfba_c3 = cobra.flux_analysis.parsimonious.pfba(c3_model) #perform pFBA"
]
},
{
"cell_type": "markdown",
"metadata": {
"ExecuteTime": {
"end_time": "2018-02-06T17:54:23.611334+01:00",
"start_time": "2018-02-06T17:54:23.609194"
},
"run_control": {
"marked": true
}
},
"source": [
"## 4 Figures"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"ExecuteTime": {
"end_time": "2019-05-06T13:44:14.718101Z",
"start_time": "2019-05-06T15:44:14.715795+02:00"
},
"collapsed": true
},
"outputs": [],
"source": [
"save_fig = False"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"ExecuteTime": {
"end_time": "2019-05-06T13:44:14.730153Z",
"start_time": "2019-05-06T15:44:14.720030+02:00"
},
"collapsed": true
},
"outputs": [],
"source": [
"#Map GO terms to reactions consuming or producing ATP, NADH, NADPH in all compartments\n",
"\n",
"L_m = ['ATP_c', 'ATP_h', 'ATP_m', 'NADH_c', 'NADH_p', 'NADH_m', 'NADH_h', 'NADPH_c', 'NADPH_m', 'NADPH_h']\n",
"\n",
"L_goTerm = []\n",
"\n",
"for m_id in L_m:\n",
" for r_obj in c3_model.metabolites.get_by_id(m_id).reactions:\n",
" r_id = r_obj.id\n",
" if not r_id[:2] in ['Tr','Ex','Im'] :\n",
" L_goId_r = r_obj.annotation['go']\n",
" if not isinstance(L_goId_r, list):\n",
" L_goId_r = [L_goId_r]\n",
" L_goTerm_r = [goDB[goId].name for goId in L_goId_r]\n",
" L_goTerm += L_goTerm_r\n",
"\n",
"L_goTerm = list(set(L_goTerm))\n",
"L_col = ['hsl('+str(h)+',50%'+',50%)' for h in np.linspace(0, 360, len(L_goTerm)+1)]\n",
"D_goTerm_col = {L_goTerm[n]: col for n, col in enumerate(L_col) if n < len(L_goTerm)}\n",
"D_goTerm_col['Others'] = L_col[-1]"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {
"ExecuteTime": {
"end_time": "2019-05-06T13:44:15.056237Z",
"start_time": "2019-05-06T15:44:14.731973+02:00"
},
"collapsed": false
},
"outputs": [
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"linkText": "Export to plot.ly",
"plotlyServerURL": "https://plot.ly",
"showLink": false
},
"data": [
{
"labels": [
"photosynthesis, light reaction",
"oxidative phosphorylation",
"canonical glycolysis",
"Others"
],
"marker": {
"colors": [
"hsl(122.553191489,50%,50%)",
"hsl(153.191489362,50%,50%)",
"hsl(298.723404255,50%,50%)",
"hsl(360.0,50%,50%)"
],
"line": {
"color": "#FFF",
"width": 1
}
},
"textfont": {
"family": "Arial",
"size": 18
},
"type": "pie",
"uid": "41c884c2-08dd-42ce-8bcd-e98fb4196d0c",
"values": [
72.6417,
0.75527,
1.2955699999999999,
0.05081000000001268
]
}
],
"layout": {
"height": 600,
"title": {
"text": "Proportion of ATP Production"
},
"width": 750
}
},
"text/html": [
"\n",
" \n",
" \n",
"
\n",
" \n",
"
"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"linkText": "Export to plot.ly",
"plotlyServerURL": "https://plot.ly",
"showLink": false
},
"data": [
{
"labels": [
"Others",
"photorespiration",
"nucleotide metabolic process",
"starch biosynthetic process",
"reductive pentose-phosphate cycle"
],
"marker": {
"colors": [
"hsl(360.0,50%,50%)",
"hsl(7.65957446809,50%,50%)",
"hsl(306.382978723,50%,50%)",
"hsl(107.234042553,50%,50%)",
"hsl(275.744680851,50%,50%)"
],
"line": {
"color": "#FFF",
"width": 1
}
},
"textfont": {
"family": "Arial",
"size": 18
},
"type": "pie",
"uid": "345e603d-7c4d-4d55-a053-22cefbd044df",
"values": [
1.047690000000003,
1.02446,
0.77355,
1.53436,
69.30005
]
}
],
"layout": {
"height": 600,
"title": {
"text": "Proportion of ATP Consumption"
},
"width": 750
}
},
"text/html": [
"\n",
" \n",
" \n",
"
\n",
" \n",
"
"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"#Proportion of subsystems in ATP production and consumption\n",
"L_m = ['ATP_c', 'ATP_h', 'ATP_m']\n",
"ATP_Pro = proportion_E_production(L_m, 'ATP', save_fig)\n",
"ATP_Con = proportion_E_consumption(L_m, 'ATP', save_fig)"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"ExecuteTime": {
"end_time": "2019-05-06T13:44:15.344911Z",
"start_time": "2019-05-06T15:44:15.057759+02:00"
},
"collapsed": false
},
"outputs": [
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"linkText": "Export to plot.ly",
"plotlyServerURL": "https://plot.ly",
"showLink": false
},
"data": [
{
"labels": [
"nitrate assimilation",
"photosynthesis, light reaction",
"Others"
],
"marker": {
"colors": [
"hsl(84.2553191489,50%,50%)",
"hsl(122.553191489,50%,50%)",
"hsl(360.0,50%,50%)"
],
"line": {
"color": "#FFF",
"width": 1
}
},
"textfont": {
"family": "Arial",
"size": 18
},
"type": "pie",
"uid": "6b566d70-fef1-451d-b564-46d8d38ad08f",
"values": [
0.49953,
46.31579,
0.16320000000000334
]
}
],
"layout": {
"height": 600,
"title": {
"text": "Proportion of NADPH Production"
},
"width": 750
}
},
"text/html": [
"\n",
" \n",
" \n",
"
\n",
" \n",
"
"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"linkText": "Export to plot.ly",
"plotlyServerURL": "https://plot.ly",
"showLink": false
},
"data": [
{
"labels": [
"glutamate biosynthetic process",
"Others",
"reductive pentose-phosphate cycle"
],
"marker": {
"colors": [
"hsl(191.489361702,50%,50%)",
"hsl(360.0,50%,50%)",
"hsl(275.744680851,50%,50%)"
],
"line": {
"color": "#FFF",
"width": 1
}
},
"textfont": {
"family": "Arial",
"size": 18
},
"type": "pie",
"uid": "30acfdde-67af-416e-b9ed-ba7b3e543e40",
"values": [
0.66063,
0.282669999999996,
46.03523
]
}
],
"layout": {
"height": 600,
"title": {
"text": "Proportion of NADPH Consumption"
},
"width": 750
}
},
"text/html": [
"\n",
" \n",
" \n",
"
\n",
" \n",
"
"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"#Proportion of subsystems in NADPH production and consumption\n",
"L_m = ['NADPH_c', 'NADPH_h', 'NADPH_m']\n",
"NADPH_Pro = proportion_E_production(L_m, 'NADPH', save_fig)\n",
"NADPH_Con = proportion_E_consumption(L_m, 'NADPH', save_fig)"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {
"ExecuteTime": {
"end_time": "2019-05-06T13:44:15.806119Z",
"start_time": "2019-05-06T15:44:15.346557+02:00"
},
"collapsed": false
},
"outputs": [
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"linkText": "Export to plot.ly",
"plotlyServerURL": "https://plot.ly",
"showLink": false
},
"data": [
{
"labels": [
"photorespiration",
"pyruvate dehydrogenase activity",
"canonical glycolysis",
"Others"
],
"marker": {
"colors": [
"hsl(7.65957446809,50%,50%)",
"hsl(291.063829787,50%,50%)",
"hsl(298.723404255,50%,50%)",
"hsl(360.0,50%,50%)"
],
"line": {
"color": "#FFF",
"width": 1
}
},
"textfont": {
"family": "Arial",
"size": 18
},
"type": "pie",
"uid": "0bf3637a-7ff9-4cf2-a154-5d8e72264fd7",
"values": [
1.05933,
0.16111,
1.12146,
0.01114000000000015
]
}
],
"layout": {
"height": 600,
"title": {
"text": "Proportion of NADH Production"
},
"width": 750
}
},
"text/html": [
"\n",
" \n",
" \n",
"
\n",
" \n",
"
"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"linkText": "Export to plot.ly",
"plotlyServerURL": "https://plot.ly",
"showLink": false
},
"data": [
{
"labels": [
"nitrate assimilation",
"alternative respiration",
"glutamate biosynthetic process",
"glyoxylate cycle",
"Others"
],
"marker": {
"colors": [
"hsl(84.2553191489,50%,50%)",
"hsl(245.106382979,50%,50%)",
"hsl(191.489361702,50%,50%)",
"hsl(206.808510638,50%,50%)",
"hsl(360.0,50%,50%)"
],
"line": {
"color": "#FFF",
"width": 1
}
},
"textfont": {
"family": "Arial",
"size": 18
},
"type": "pie",
"uid": "6bd54ecb-aaae-4c58-9b40-2d584fd4acec",
"values": [
1.02748,
0.22658,
0.2477,
0.74616,
0.009409999999999474
]
}
],
"layout": {
"height": 600,
"title": {
"text": "Proportion of NADH Consumption"
},
"width": 750
}
},
"text/html": [
"\n",
" \n",
" \n",
"
\n",
" \n",
"
"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"#Proportion of subsystems in NADH production and consumption\n",
"L_m = ['NADH_c', 'NADH_h', 'NADH_m']\n",
"NADH_Pro = proportion_E_production(L_m, 'NADH', save_fig)\n",
"NADH_Con = proportion_E_consumption(L_m, 'NADH', save_fig)"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {
"ExecuteTime": {
"end_time": "2019-05-06T13:44:15.928338Z",
"start_time": "2019-05-06T15:44:15.807487+02:00"
},
"collapsed": false
},
"outputs": [
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"linkText": "Export to plot.ly",
"plotlyServerURL": "https://plot.ly",
"showLink": false
},
"data": [
{
"labels": [
"ATP",
"NADPH",
"NADH"
],
"marker": {
"line": {
"color": "#FFF",
"width": 1
}
},
"textfont": {
"family": "Arial",
"size": 18
},
"type": "pie",
"uid": "71360870-2ff1-4bee-89cc-de57a266799d",
"values": [
74.74335,
46.97852,
2.35304
]
}
],
"layout": {
"height": 500,
"title": {
"text": "Proportion of Energy Equivalents"
},
"width": 750
}
},
"text/html": [
"\n",
" \n",
" \n",
"
\n",
" \n",
"
"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"#Proportion of engergy eqivalents\n",
"\n",
"trace = go.Pie(\n",
" labels = ['ATP', 'NADPH', 'NADH'],\n",
" values = [ATP_Pro, NADPH_Pro, NADH_Pro],\n",
" textfont=dict(size=18,family='Arial'),\n",
" marker=dict(line=dict(color='#FFF', width=1)),\n",
")\n",
"\n",
"data = [trace]\n",
"\n",
"layout = go.Layout(\n",
" height=500, \n",
" width=750, \n",
" title = 'Proportion of Energy Equivalents'\n",
" )\n",
"\n",
"fig = go.Figure(data=data, layout=layout)\n",
"\n",
"if save_fig:\n",
" iplot(fig,filename='E_Pro_proportion',image='svg',image_height=500,image_width=750)\n",
" sleep(5)\n",
"else:\n",
" iplot(fig)"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {
"ExecuteTime": {
"end_time": "2019-05-06T13:44:16.069942Z",
"start_time": "2019-05-06T15:44:15.929688+02:00"
},
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[0.15270708327974447, 0.050349979617494885, 0.009111187245501572]\n"
]
},
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"linkText": "Export to plot.ly",
"plotlyServerURL": "https://plot.ly",
"showLink": false
},
"data": [
{
"labels": [
"NGAM_h",
"NGAM_c",
"NGAM_m",
"Others"
],
"marker": {
"line": {
"color": "#FFF",
"width": 1
}
},
"textfont": {
"family": "Arial",
"size": 18
},
"type": "pie",
"uid": "8714793b-5e9f-4e4d-8a9a-12596093c61d",
"values": [
0.15270708327974447,
0.050349979617494885,
0.009111187245501572,
0.5430984651402668
]
}
],
"layout": {
"height": 500,
"title": {
"text": "Proportion of Respiratory ATP"
},
"width": 750
}
},
"text/html": [
"\n",
" \n",
" \n",
"
\n",
" \n",
"
"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"ATP Maintainence : Respiratory ATP = 28.092%\n"
]
}
],
"source": [
"#Proportion of maintenace costs on respiratory ATP\n",
"\n",
"L_r_NGAM = ['NGAM_h','NGAM_c','NGAM_m']\n",
"L_flux = [result_pfba_c3.fluxes[r_id] for r_id in L_r_NGAM]\n",
"print(L_flux)\n",
"cplx5_m = c3_model.reactions.get_by_id('cplx5_m')\n",
"ATP_cplx5 = result_pfba_c3.fluxes['cplx5_m'] * cplx5_m.get_coefficient('ATP_m')\n",
"\n",
"trace = go.Pie(\n",
" labels = L_r_NGAM + ['Others'],\n",
" values = L_flux + [ATP_cplx5 - sum(L_flux)],\n",
" textfont=dict(size=18,family='Arial',),\n",
" marker=dict(line=dict(color='#FFF', width=1)),\n",
")\n",
"\n",
"data = [trace]\n",
"\n",
"layout = go.Layout(\n",
" title=\"Proportion of Respiratory ATP\",\n",
" height=500, \n",
" width=750,\n",
" \n",
" )\n",
"\n",
"fig = go.Figure(data=data, layout=layout)\n",
"\n",
"if save_fig:\n",
" iplot(fig,filename='maintenance_respiratory_ATP',image='svg',image_height=500,image_width=750)\n",
" sleep(5)\n",
"else:\n",
" iplot(fig)\n",
" \n",
"print('ATP Maintainence : Respiratory ATP = %s%%' %(round(sum(L_flux) / (ATP_cplx5) * 100,3)))"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {
"ExecuteTime": {
"end_time": "2019-05-06T13:44:17.059911Z",
"start_time": "2019-05-06T15:44:16.071348+02:00"
},
"collapsed": true
},
"outputs": [],
"source": [
"#save results to excel\n",
"df = pd.DataFrame(columns=['rxn','subsystem','flux'])\n",
"L_subsystem = []\n",
"L_transport = []\n",
"for r_obj in c3_model.reactions:\n",
" L_goId = r_obj.annotation['go']\n",
" if not isinstance(L_goId, list):\n",
" L_goId = [L_goId]\n",
" L_goTerm = [goDB[goId].name for goId in L_goId]\n",
" L_subsystem = L_subsystem + L_goTerm\n",
" if 'GO:0006810' in L_goId:\n",
" L_transport.append(r_obj.id)\n",
" df.loc[r_obj.id] = [r_obj.reaction,', '.join(L_goTerm),result_pfba_c3.fluxes[r_obj.id]]\n",
"\n",
"writer = pd.ExcelWriter(theNotebook+'/excel/flux_solution.xlsx')\n",
"df.to_excel(writer)\n",
"writer.save()"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {
"ExecuteTime": {
"end_time": "2019-05-06T13:44:17.068516Z",
"start_time": "2019-05-06T15:44:17.061336+02:00"
},
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Number of reactions: 572\n",
"Number of internal transporters: 139\n",
"Number of export reactions: 90\n",
"Number of import reactions: 8\n",
"Number of subsystems: 59\n",
"Number of metabolites: 413\n"
]
}
],
"source": [
"#Print characteristic numbers of model\n",
"print('Number of reactions: %s' %len(c3_model.reactions))\n",
"L_r_transport = [r_id for r_id in L_transport if r_id[:2] == 'Tr']\n",
"L_r_export = [r_id for r_id in L_transport if r_id[:2] == 'Ex']\n",
"L_r_import = [r_id for r_id in L_transport if r_id[:2] == 'Im']\n",
"print('Number of internal transporters: %s' %len(L_r_transport))\n",
"print('Number of export reactions: %s' %len(L_r_export))\n",
"print('Number of import reactions: %s' %len(L_r_import))\n",
"print('Number of subsystems: %s' %len(list(set(L_subsystem))))\n",
"print('Number of metabolites: %s' %len(c3_model.metabolites))"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {
"ExecuteTime": {
"end_time": "2019-05-06T13:44:17.097867Z",
"start_time": "2019-05-06T15:44:17.070748+02:00"
},
"collapsed": false
},
"outputs": [],
"source": [
"#Create dataframe for input and output reactions\n",
"df = pd.DataFrame(columns=['RXN','Flux'])\n",
"for r_id in L_r_export:\n",
" r_flux = result_pfba_c3.fluxes[r_id]\n",
" if round(r_flux,5) != 0:\n",
" r_obj = c3_model.reactions.get_by_id(r_id)\n",
" df.loc[r_id] = [r_obj.reaction,r_flux]\n",
"for r_id in L_r_import:\n",
" r_flux = result_pfba_c3.fluxes[r_id]\n",
" if abs(round(r_flux,5)) > 0:\n",
" r_obj = c3_model.reactions.get_by_id(r_id)\n",
" df.loc[r_id] = [r_obj.reaction,r_flux]\n",
"\n",
"max_flux = max(df['Flux'])\n",
"min_flux = min(df['Flux'])"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {
"ExecuteTime": {
"end_time": "2019-05-06T13:44:17.541929Z",
"start_time": "2019-05-06T15:44:17.099341+02:00"
},
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"This is the format of your plot grid:\n",
"[ (1,1) x1,y1 ] [ (1,2) x2,y2 ] [ (1,3) x3,y3 ]\n",
"[ (2,1) x4,y4 ] [ (2,2) x5,y5 ] [ (2,3) x6,y6 ]\n",
"[ (3,1) x7,y7 ] [ (3,2) x8,y8 ] [ (3,3) x9,y9 ]\n",
"\n"
]
},
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"linkText": "Export to plot.ly",
"plotlyServerURL": "https://plot.ly",
"showLink": false
},
"data": [
{
"marker": {
"color": "rgba(219, 64, 82, 0.7)",
"line": {
"color": "rgba(219, 64, 82, 1.0)",
"width": 2
}
},
"showlegend": false,
"text": [
"20.929"
],
"textposition": "auto",
"type": "bar",
"uid": "19bf6989-b3c0-4368-8e59-d5e66c139b2d",
"x": [
1
],
"xaxis": "x",
"y": [
20.928896483183106
],
"yaxis": "y"
},
{
"marker": {
"color": "rgba(219, 64, 82, 0.7)",
"line": {
"color": "rgba(219, 64, 82, 1.0)",
"width": 2
}
},
"showlegend": false,
"text": [
"0.767"
],
"textposition": "auto",
"type": "bar",
"uid": "7e6de242-9f56-426b-b2dd-2d6bebedf6a6",
"x": [
1
],
"xaxis": "x2",
"y": [
0.7671787003295382
],
"yaxis": "y2"
},
{
"marker": {
"color": "rgba(219, 64, 82, 0.7)",
"line": {
"color": "rgba(219, 64, 82, 1.0)",
"width": 2
}
},
"showlegend": false,
"text": [
"0.767"
],
"textposition": "auto",
"type": "bar",
"uid": "41dab6ff-408a-4acf-a23e-3a62a320552f",
"x": [
1
],
"xaxis": "x3",
"y": [
0.7671787003295382
],
"yaxis": "y3"
},
{
"marker": {
"color": "rgba(219, 64, 82, 0.7)",
"line": {
"color": "rgba(219, 64, 82, 1.0)",
"width": 2
}
},
"showlegend": false,
"text": [
"0.349"
],
"textposition": "auto",
"type": "bar",
"uid": "22dee2e3-931f-4c9e-b20a-5a9a1b6b4fd5",
"x": [
1
],
"xaxis": "x4",
"y": [
0.34871759105888095
],
"yaxis": "y4"
},
{
"marker": {
"color": "rgba(50, 171, 96, 0.7)",
"line": {
"color": "rgba(50, 171, 96, 1.0)",
"width": 2
}
},
"showlegend": false,
"text": [
"193.711"
],
"textposition": "auto",
"type": "bar",
"uid": "ae2c4411-bed8-4568-9933-a3039b06d5fa",
"x": [
1
],
"xaxis": "x5",
"y": [
193.7112116484644
],
"yaxis": "y5"
},
{
"marker": {
"color": "rgba(50, 171, 96, 0.7)",
"line": {
"color": "rgba(50, 171, 96, 1.0)",
"width": 2
}
},
"showlegend": false,
"text": [
"20.0"
],
"textposition": "auto",
"type": "bar",
"uid": "7f0d6eb5-5f93-43fc-8f8e-4aa2ee050895",
"x": [
1
],
"xaxis": "x6",
"y": [
20.000000000000007
],
"yaxis": "y6"
},
{
"marker": {
"color": "rgba(50, 171, 96, 0.7)",
"line": {
"color": "rgba(50, 171, 96, 1.0)",
"width": 2
}
},
"showlegend": false,
"text": [
"18.183"
],
"textposition": "auto",
"type": "bar",
"uid": "57dbb71a-31fd-42de-af69-ff917d41c1df",
"x": [
1
],
"xaxis": "x7",
"y": [
18.18335570937879
],
"yaxis": "y7"
},
{
"marker": {
"color": "rgba(50, 171, 96, 0.7)",
"line": {
"color": "rgba(50, 171, 96, 1.0)",
"width": 2
}
},
"showlegend": false,
"text": [
"0.528"
],
"textposition": "auto",
"type": "bar",
"uid": "6dc5bd7f-b131-42cd-b5b8-1d27da5e5cfe",
"x": [
1
],
"xaxis": "x8",
"y": [
0.527958432863151
],
"yaxis": "y8"
},
{
"marker": {
"color": "rgba(50, 171, 96, 0.7)",
"line": {
"color": "rgba(50, 171, 96, 1.0)",
"width": 2
}
},
"showlegend": false,
"text": [
"0.002"
],
"textposition": "auto",
"type": "bar",
"uid": "6a1d212d-289d-41aa-af74-760966cdf12c",
"x": [
1
],
"xaxis": "x9",
"y": [
0.0024410231374121668
],
"yaxis": "y9"
}
],
"layout": {
"annotations": [
{
"font": {
"size": 16
},
"showarrow": false,
"text": "Ex_O2",
"x": 0.14444444444444446,
"xanchor": "center",
"xref": "paper",
"y": 1,
"yanchor": "bottom",
"yref": "paper"
},
{
"font": {
"size": 16
},
"showarrow": false,
"text": "Ex_starch",
"x": 0.5,
"xanchor": "center",
"xref": "paper",
"y": 1,
"yanchor": "bottom",
"yref": "paper"
},
{
"font": {
"size": 16
},
"showarrow": false,
"text": "Ex_Suc",
"x": 0.8555555555555556,
"xanchor": "center",
"xref": "paper",
"y": 1,
"yanchor": "bottom",
"yref": "paper"
},
{
"font": {
"size": 16
},
"showarrow": false,
"text": "Ex_AA",
"x": 0.14444444444444446,
"xanchor": "center",
"xref": "paper",
"y": 0.6111111111111112,
"yanchor": "bottom",
"yref": "paper"
},
{
"font": {
"size": 16
},
"showarrow": false,
"text": "Im_hnu",
"x": 0.5,
"xanchor": "center",
"xref": "paper",
"y": 0.6111111111111112,
"yanchor": "bottom",
"yref": "paper"
},
{
"font": {
"size": 16
},
"showarrow": false,
"text": "Im_CO2",
"x": 0.8555555555555556,
"xanchor": "center",
"xref": "paper",
"y": 0.6111111111111112,
"yanchor": "bottom",
"yref": "paper"
},
{
"font": {
"size": 16
},
"showarrow": false,
"text": "Im_H2O",
"x": 0.14444444444444446,
"xanchor": "center",
"xref": "paper",
"y": 0.22222222222222224,
"yanchor": "bottom",
"yref": "paper"
},
{
"font": {
"size": 16
},
"showarrow": false,
"text": "Im_NO3",
"x": 0.5,
"xanchor": "center",
"xref": "paper",
"y": 0.22222222222222224,
"yanchor": "bottom",
"yref": "paper"
},
{
"font": {
"size": 16
},
"showarrow": false,
"text": "Im_SO4",
"x": 0.8555555555555556,
"xanchor": "center",
"xref": "paper",
"y": 0.22222222222222224,
"yanchor": "bottom",
"yref": "paper"
}
],
"height": 1000,
"width": 1000,
"xaxis": {
"anchor": "y",
"domain": [
0,
0.2888888888888889
],
"showticklabels": false
},
"xaxis2": {
"anchor": "y2",
"domain": [
0.35555555555555557,
0.6444444444444445
],
"showticklabels": false
},
"xaxis3": {
"anchor": "y3",
"domain": [
0.7111111111111111,
1
],
"showticklabels": false
},
"xaxis4": {
"anchor": "y4",
"domain": [
0,
0.2888888888888889
],
"showticklabels": false
},
"xaxis5": {
"anchor": "y5",
"domain": [
0.35555555555555557,
0.6444444444444445
],
"showticklabels": false
},
"xaxis6": {
"anchor": "y6",
"domain": [
0.7111111111111111,
1
],
"showticklabels": false
},
"xaxis7": {
"anchor": "y7",
"domain": [
0,
0.2888888888888889
],
"showticklabels": false
},
"xaxis8": {
"anchor": "y8",
"domain": [
0.35555555555555557,
0.6444444444444445
],
"showticklabels": false
},
"xaxis9": {
"anchor": "y9",
"domain": [
0.7111111111111111,
1
],
"showticklabels": false
},
"yaxis": {
"anchor": "x",
"domain": [
0.7777777777777778,
1
],
"range": [
0,
193.7112116484644
],
"title": {
"text": "Flux [µmol/s/m2]"
}
},
"yaxis2": {
"anchor": "x2",
"domain": [
0.7777777777777778,
1
],
"range": [
0,
193.7112116484644
],
"title": {
"text": "Flux [µmol/s/m2]"
}
},
"yaxis3": {
"anchor": "x3",
"domain": [
0.7777777777777778,
1
],
"range": [
0,
193.7112116484644
],
"title": {
"text": "Flux [µmol/s/m2]"
}
},
"yaxis4": {
"anchor": "x4",
"domain": [
0.3888888888888889,
0.6111111111111112
],
"range": [
0,
193.7112116484644
],
"title": {
"text": "Flux [µmol/s/m2]"
}
},
"yaxis5": {
"anchor": "x5",
"domain": [
0.3888888888888889,
0.6111111111111112
],
"range": [
0,
193.7112116484644
],
"title": {
"text": "Flux [µmol/s/m2]"
}
},
"yaxis6": {
"anchor": "x6",
"domain": [
0.3888888888888889,
0.6111111111111112
],
"range": [
0,
193.7112116484644
],
"title": {
"text": "Flux [µmol/s/m2]"
}
},
"yaxis7": {
"anchor": "x7",
"domain": [
0,
0.22222222222222224
],
"range": [
0,
193.7112116484644
],
"title": {
"text": "Flux [µmol/s/m2]"
}
},
"yaxis8": {
"anchor": "x8",
"domain": [
0,
0.22222222222222224
],
"range": [
0,
193.7112116484644
],
"title": {
"text": "Flux [µmol/s/m2]"
}
},
"yaxis9": {
"anchor": "x9",
"domain": [
0,
0.22222222222222224
],
"range": [
0,
193.7112116484644
],
"title": {
"text": "Flux [µmol/s/m2]"
}
}
}
},
"text/html": [
"\n",
" \n",
" \n",
"
\n",
" \n",
"
"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"#Create figure for input and output reactions\n",
"i_max = 3\n",
"j_max = 3\n",
"r_max = len(df.index)\n",
"trace = {}\n",
"D_r_name = {}\n",
"\n",
"for n, r_id in enumerate(df.index):\n",
" D_r_name[n+1] = r_id\n",
" r_flux = df.get_value(r_id, 'Flux')\n",
" trace[n+1] = go.Bar(\n",
" x=[1],\n",
" y=[r_flux],\n",
" text = [str(round(r_flux,3))],\n",
" textposition= 'auto',\n",
" showlegend=False,\n",
" marker=dict(\n",
" color='rgba(219, 64, 82, 0.7)' if r_id[:2] == 'Ex' else 'rgba(50, 171, 96, 0.7)',\n",
" line=dict(\n",
" color='rgba(219, 64, 82, 1.0)' if r_id[:2] == 'Ex' else 'rgba(50, 171, 96, 1.0)',\n",
" width=2)))\n",
"\n",
"fig = ply.tools.make_subplots(rows=i_max, cols=j_max, subplot_titles=D_r_name.values())\n",
"\n",
"k = 1\n",
"for i in range(1,i_max+1):\n",
" for j in range(1,j_max+1):\n",
" if k <= r_max:\n",
" fig.append_trace(trace[k], i, j)\n",
" else:\n",
" break\n",
" k += 1\n",
" \n",
"fig['layout'].update(height=1000, width=1000)\n",
"\n",
"\n",
"for k in range(1,i_max*j_max+1):\n",
" if k <= r_max:\n",
" fig['layout']['yaxis'+str(k)].update(title='Flux [µmol/s/m2]', range=[0, max_flux])\n",
" fig['layout']['xaxis'+str(k)].update(showticklabels=False)\n",
" else:\n",
" break\n",
"\n",
"if save_fig:\n",
" iplot(fig, filename='input_output_fluxes',image='svg',image_height=1000,image_width=1000)\n",
" sleep(5)\n",
"else:\n",
" iplot(fig)"
]
}
],
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
"display_name": "Python [default]",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
},
"latex_envs": {
"LaTeX_envs_menu_present": true,
"autoclose": false,
"autocomplete": true,
"bibliofile": "biblio.bib",
"cite_by": "apalike",
"current_citInitial": 1,
"eqLabelWithNumbers": true,
"eqNumInitial": 1,
"hotkeys": {
"equation": "Ctrl-E",
"itemize": "Ctrl-I"
},
"labels_anchors": false,
"latex_user_defs": false,
"report_style_numbering": false,
"user_envs_cfg": false
}
},
"nbformat": 4,
"nbformat_minor": 2
}