{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Getting started with cameo " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**cameo** reuses and extends model data structures defined by [cobrapy](https://opencobra.github.io/cobrapy/) (**CO**nstraints-**B**ased **R**econstruction and **A**nalysis tool for **Py**thon). So, in addition to following this quick start guide and other **cameo** tutorials, we encourage you to explore cobrapy's [documentation](https://cobrapy.readthedocs.org/en/latest/cobra.core.html) as well." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Step 1: Load a model\n", "-------------------\n", "\n", "Loading a model is easy. Just import the `~cameo.io.load_model` function." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from cameo import load_model" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For example, load a genome-scale metabolic reconstruction of _Escherichia coli_." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "model = load_model(\"iJO1366\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Models, reactions, metabolites, etc., return HTML when evaluated in Jupyter notebooks and can be easily inspected." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
NameiJO1366
Memory address0x01120756d8
Number of metabolites1805
Number of reactions2583
Objective expression-1.0*BIOMASS_Ec_iJO1366_core_53p95M_reverse_5c8b1 + 1.0*BIOMASS_Ec_iJO1366_core_53p95M
Compartmentsextracellular space, cytosol, periplasm
" ], "text/plain": [ "" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "model" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Step 2: Simulate a model\n", "\n", "The model can be simulated by executing `optimize`." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "solution = model.optimize()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A quick overview of the solution can be obtained in inspecting it." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "Optimal solution with objective value 0.982
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
fluxesreduced_costs
12DGR120tipp0.0000000.000000
12DGR140tipp0.0000000.000000
12DGR141tipp0.0000000.000000
12DGR160tipp0.0000000.000000
12DGR161tipp0.000000-0.008295
.........
ZN2abcpp0.000000-0.008295
ZN2t3pp0.000000-0.002074
ZN2tpp0.0003350.000000
ZNabcpp0.000000-0.008295
Zn2tex0.000335-0.000000
\n", "

2583 rows × 2 columns

\n", "
" ], "text/plain": [ "" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "solution" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A data frame representation of the solution is accessible via `solution.to_frame()`." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
fluxesreduced_costs
12DGR120tipp0.0000000.000000e+00
12DGR140tipp0.0000000.000000e+00
12DGR141tipp0.0000000.000000e+00
12DGR160tipp0.0000000.000000e+00
12DGR161tipp0.000000-8.295308e-03
12DGR180tipp0.0000000.000000e+00
12DGR181tipp0.0000000.000000e+00
12PPDRtex0.0000000.000000e+00
12PPDRtpp0.0000000.000000e+00
12PPDStex0.0000000.000000e+00
12PPDStpp0.0000000.000000e+00
14GLUCANabcpp0.000000-5.551115e-17
14GLUCANtexi0.0000000.000000e+00
23CAMPtex0.0000000.000000e+00
23CCMPtex0.0000000.000000e+00
23CGMPtex0.0000000.000000e+00
23CUMPtex0.0000000.000000e+00
23DAPPAt2pp0.0000001.517883e-18
23DAPPAtex0.0000000.000000e+00
23PDE2pp0.0000000.000000e+00
23PDE4pp0.0000000.000000e+00
23PDE7pp0.0000000.000000e+00
23PDE9pp0.0000000.000000e+00
26DAHtex0.0000000.000000e+00
2AGPA120tipp0.0000000.000000e+00
2AGPA140tipp0.0000000.000000e+00
2AGPA141tipp0.0000000.000000e+00
2AGPA160tipp0.0000000.000000e+00
2AGPA161tipp0.0000000.000000e+00
2AGPA180tipp0.0000000.000000e+00
.........
VALTRS0.0000000.000000e+00
VALabcpp0.000000-6.221481e-03
VALt2rpp0.0000000.000000e+00
VALtex0.0000000.000000e+00
VPAMTr0.0000000.000000e+00
WCOS0.0000000.000000e+00
X5PL3E0.0000000.000000e+00
XAND0.0000000.000000e+00
XANt2pp0.000000-2.073827e-03
XANtex0.0000000.000000e+00
XANtpp0.0000000.000000e+00
XMPtex0.0000000.000000e+00
XPPT0.0000000.000000e+00
XTSNH0.000000-8.295308e-03
XTSNt2rpp0.0000000.000000e+00
XTSNtex0.0000000.000000e+00
XYLI10.0000000.000000e+00
XYLI20.0000000.000000e+00
XYLK0.000000-1.387779e-17
XYLK20.000000-1.387779e-17
XYLUt2pp0.0000000.000000e+00
XYLUtex0.0000000.000000e+00
XYLabcpp0.000000-6.221481e-03
XYLt2pp0.0000000.000000e+00
XYLtex0.0000000.000000e+00
ZN2abcpp0.000000-8.295308e-03
ZN2t3pp0.000000-2.073827e-03
ZN2tpp0.0003350.000000e+00
ZNabcpp0.000000-8.295308e-03
Zn2tex0.000335-0.000000e+00
\n", "

2583 rows × 2 columns

\n", "
" ], "text/plain": [ " fluxes reduced_costs\n", "12DGR120tipp 0.000000 0.000000e+00\n", "12DGR140tipp 0.000000 0.000000e+00\n", "12DGR141tipp 0.000000 0.000000e+00\n", "12DGR160tipp 0.000000 0.000000e+00\n", "12DGR161tipp 0.000000 -8.295308e-03\n", "12DGR180tipp 0.000000 0.000000e+00\n", "12DGR181tipp 0.000000 0.000000e+00\n", "12PPDRtex 0.000000 0.000000e+00\n", "12PPDRtpp 0.000000 0.000000e+00\n", "12PPDStex 0.000000 0.000000e+00\n", "12PPDStpp 0.000000 0.000000e+00\n", "14GLUCANabcpp 0.000000 -5.551115e-17\n", "14GLUCANtexi 0.000000 0.000000e+00\n", "23CAMPtex 0.000000 0.000000e+00\n", "23CCMPtex 0.000000 0.000000e+00\n", "23CGMPtex 0.000000 0.000000e+00\n", "23CUMPtex 0.000000 0.000000e+00\n", "23DAPPAt2pp 0.000000 1.517883e-18\n", "23DAPPAtex 0.000000 0.000000e+00\n", "23PDE2pp 0.000000 0.000000e+00\n", "23PDE4pp 0.000000 0.000000e+00\n", "23PDE7pp 0.000000 0.000000e+00\n", "23PDE9pp 0.000000 0.000000e+00\n", "26DAHtex 0.000000 0.000000e+00\n", "2AGPA120tipp 0.000000 0.000000e+00\n", "2AGPA140tipp 0.000000 0.000000e+00\n", "2AGPA141tipp 0.000000 0.000000e+00\n", "2AGPA160tipp 0.000000 0.000000e+00\n", "2AGPA161tipp 0.000000 0.000000e+00\n", "2AGPA180tipp 0.000000 0.000000e+00\n", "... ... ...\n", "VALTRS 0.000000 0.000000e+00\n", "VALabcpp 0.000000 -6.221481e-03\n", "VALt2rpp 0.000000 0.000000e+00\n", "VALtex 0.000000 0.000000e+00\n", "VPAMTr 0.000000 0.000000e+00\n", "WCOS 0.000000 0.000000e+00\n", "X5PL3E 0.000000 0.000000e+00\n", "XAND 0.000000 0.000000e+00\n", "XANt2pp 0.000000 -2.073827e-03\n", "XANtex 0.000000 0.000000e+00\n", "XANtpp 0.000000 0.000000e+00\n", "XMPtex 0.000000 0.000000e+00\n", "XPPT 0.000000 0.000000e+00\n", "XTSNH 0.000000 -8.295308e-03\n", "XTSNt2rpp 0.000000 0.000000e+00\n", "XTSNtex 0.000000 0.000000e+00\n", "XYLI1 0.000000 0.000000e+00\n", "XYLI2 0.000000 0.000000e+00\n", "XYLK 0.000000 -1.387779e-17\n", "XYLK2 0.000000 -1.387779e-17\n", "XYLUt2pp 0.000000 0.000000e+00\n", "XYLUtex 0.000000 0.000000e+00\n", "XYLabcpp 0.000000 -6.221481e-03\n", "XYLt2pp 0.000000 0.000000e+00\n", "XYLtex 0.000000 0.000000e+00\n", "ZN2abcpp 0.000000 -8.295308e-03\n", "ZN2t3pp 0.000000 -2.073827e-03\n", "ZN2tpp 0.000335 0.000000e+00\n", "ZNabcpp 0.000000 -8.295308e-03\n", "Zn2tex 0.000335 -0.000000e+00\n", "\n", "[2583 rows x 2 columns]" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "solution.to_frame()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Data frames make it very easy to process results. For example, let's take a look at reactions with flux != 0" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
fluxesreduced_costs
3OAR1400.0764520.000000e+00
3OAS1400.0764520.000000e+00
5DOAN0.0002210.000000e+00
A5PISO0.0382260.000000e+00
AACPS30.125378-1.387779e-16
AACPS40.147776-2.775558e-17
AACPS70.076452-2.775558e-17
ACACT1r0.3496060.000000e+00
ACACT2r0.3496060.000000e+00
ACACT3r0.3496060.000000e+00
ACACT4r0.3496060.000000e+00
ACACT5r0.3496060.000000e+00
ACACT6r0.2731540.000000e+00
ACACT7r0.2731540.000000e+00
ACCOAC0.076458-7.090682e-17
ACGK0.2905780.000000e+00
ACGS0.2905782.927346e-17
ACHBS0.285408-6.938894e-18
ACLS0.8588570.000000e+00
ACOAD1f-0.3496060.000000e+00
ACOAD2f-0.3496060.000000e+00
ACOAD3f-0.3496060.000000e+00
ACOAD4f-0.3496060.000000e+00
ACOAD5f-0.3496060.000000e+00
ACOAD6f-0.2731540.000000e+00
ACOAD7f-0.1253780.000000e+00
ACODA0.2905780.000000e+00
ACONTa4.8577770.000000e+00
ACONTb4.8577770.000000e+00
ACOTA-0.2905780.000000e+00
.........
TMDS0.025705-5.551115e-17
TMPK0.0002190.000000e+00
TMPPP0.0002190.000000e+00
TPI7.6453710.000000e+00
TRDR0.2435020.000000e+00
TRPAS2-0.0558410.000000e+00
TRPS30.0558412.775558e-17
TYRL0.0002190.000000e+00
TYRTA-0.1356840.000000e+00
U23GAAT0.0382260.000000e+00
UAAGDS0.0272980.000000e+00
UAGAAT0.0382260.000000e+00
UAGCVT0.0272980.000000e+00
UAGDP0.0928220.000000e+00
UAGPT30.027298-5.551115e-17
UAMAGS0.0272980.000000e+00
UAMAS0.0272985.551115e-17
UAPGR0.0272980.000000e+00
UDCPDP0.0272980.000000e+00
UDCPDPS0.0000540.000000e+00
UGMDDS0.0272981.110223e-16
UHGADA0.0382260.000000e+00
UMPK0.3713750.000000e+00
UPP3MT0.0002191.110223e-16
UPP3S0.0004380.000000e+00
UPPDC10.0002190.000000e+00
USHD0.0191130.000000e+00
VALTA-0.4157020.000000e+00
ZN2tpp0.0003350.000000e+00
Zn2tex0.000335-0.000000e+00
\n", "

436 rows × 2 columns

\n", "
" ], "text/plain": [ " fluxes reduced_costs\n", "3OAR140 0.076452 0.000000e+00\n", "3OAS140 0.076452 0.000000e+00\n", "5DOAN 0.000221 0.000000e+00\n", "A5PISO 0.038226 0.000000e+00\n", "AACPS3 0.125378 -1.387779e-16\n", "AACPS4 0.147776 -2.775558e-17\n", "AACPS7 0.076452 -2.775558e-17\n", "ACACT1r 0.349606 0.000000e+00\n", "ACACT2r 0.349606 0.000000e+00\n", "ACACT3r 0.349606 0.000000e+00\n", "ACACT4r 0.349606 0.000000e+00\n", "ACACT5r 0.349606 0.000000e+00\n", "ACACT6r 0.273154 0.000000e+00\n", "ACACT7r 0.273154 0.000000e+00\n", "ACCOAC 0.076458 -7.090682e-17\n", "ACGK 0.290578 0.000000e+00\n", "ACGS 0.290578 2.927346e-17\n", "ACHBS 0.285408 -6.938894e-18\n", "ACLS 0.858857 0.000000e+00\n", "ACOAD1f -0.349606 0.000000e+00\n", "ACOAD2f -0.349606 0.000000e+00\n", "ACOAD3f -0.349606 0.000000e+00\n", "ACOAD4f -0.349606 0.000000e+00\n", "ACOAD5f -0.349606 0.000000e+00\n", "ACOAD6f -0.273154 0.000000e+00\n", "ACOAD7f -0.125378 0.000000e+00\n", "ACODA 0.290578 0.000000e+00\n", "ACONTa 4.857777 0.000000e+00\n", "ACONTb 4.857777 0.000000e+00\n", "ACOTA -0.290578 0.000000e+00\n", "... ... ...\n", "TMDS 0.025705 -5.551115e-17\n", "TMPK 0.000219 0.000000e+00\n", "TMPPP 0.000219 0.000000e+00\n", "TPI 7.645371 0.000000e+00\n", "TRDR 0.243502 0.000000e+00\n", "TRPAS2 -0.055841 0.000000e+00\n", "TRPS3 0.055841 2.775558e-17\n", "TYRL 0.000219 0.000000e+00\n", "TYRTA -0.135684 0.000000e+00\n", "U23GAAT 0.038226 0.000000e+00\n", "UAAGDS 0.027298 0.000000e+00\n", "UAGAAT 0.038226 0.000000e+00\n", "UAGCVT 0.027298 0.000000e+00\n", "UAGDP 0.092822 0.000000e+00\n", "UAGPT3 0.027298 -5.551115e-17\n", "UAMAGS 0.027298 0.000000e+00\n", "UAMAS 0.027298 5.551115e-17\n", "UAPGR 0.027298 0.000000e+00\n", "UDCPDP 0.027298 0.000000e+00\n", "UDCPDPS 0.000054 0.000000e+00\n", "UGMDDS 0.027298 1.110223e-16\n", "UHGADA 0.038226 0.000000e+00\n", "UMPK 0.371375 0.000000e+00\n", "UPP3MT 0.000219 1.110223e-16\n", "UPP3S 0.000438 0.000000e+00\n", "UPPDC1 0.000219 0.000000e+00\n", "USHD 0.019113 0.000000e+00\n", "VALTA -0.415702 0.000000e+00\n", "ZN2tpp 0.000335 0.000000e+00\n", "Zn2tex 0.000335 -0.000000e+00\n", "\n", "[436 rows x 2 columns]" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "solution.to_frame().query('fluxes != 0')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Step 3: Exploring a model\n", "\n", "Objects—models, reactions, metabolites, genes—can easily be explored in the Jupyter notebook, taking advantage of tab completion. For example, place your cursor after the period in `model.reactions.` and press the TAB key. A dialog will appear that allows you to navigate the list of reactions encoded in the model. " ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Reaction identifierPGK
NamePhosphoglycerate kinase
Memory address0x01129829b0
Stoichiometry\n", "

3pg_c + atp_c <=> 13dpg_c + adp_c

\n", "

3-Phospho-D-glycerate + ATP C10H12N5O13P3 <=> 3-Phospho-D-glyceroyl phosphate + ADP C10H12N5O10P2

\n", "
GPRb2926
Lower bound-1000.0
Upper bound1000.0
\n", " " ], "text/plain": [ "" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "model.reactions.PGK # delete PGK, place your cursor after the period and press the TAB key." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For example, you can access the E4PD (_Erythrose 4-phosphate dehydrogenase_) reaction in the model." ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Reaction identifierE4PD
NameErythrose 4-phosphate dehydrogenase
Memory address0x0112606160
Stoichiometry\n", "

e4p_c + h2o_c + nad_c <=> 4per_c + 2.0 h_c + nadh_c

\n", "

D-Erythrose 4-phosphate + H2O H2O + Nicotinamide adenine dinucleotide <=> 4-Phospho-D-erythronate + 2.0 H+ + Nicotinamide adenine dinucleotide - reduced

\n", "
GPRb2927 or b1779
Lower bound-1000.0
Upper bound1000.0
\n", " " ], "text/plain": [ "" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "model.reactions.E4PD" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Be aware that, due to variable naming restrictions in Python, dot notation access to reactions (and other objects) might not work in some cases." ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "# model.reactions.12DGR120tipp # uncommenting and running this cell will produce a syntax error" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In those cases you need to use the `model.reactions.get_by_id`." ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Reaction identifier12DGR120tipp
Name1,2 diacylglycerol transport via flipping (periplasm to cytoplasm, n-C12:0)
Memory address0x0112506ba8
Stoichiometry\n", "

12dgr120_p --> 12dgr120_c

\n", "

1,2-Diacyl-sn-glycerol (didodecanoyl, n-C12:0) --> 1,2-Diacyl-sn-glycerol (didodecanoyl, n-C12:0)

\n", "
GPR
Lower bound0.0
Upper bound1000.0
\n", " " ], "text/plain": [ "" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "model.reactions.get_by_id('12DGR120tipp')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Metabolites are accessible through `model.metabolites`. For example, D-glucose in the cytosol compartment." ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Metabolite identifierglc__D_c
NameD-Glucose
Memory address0x01120db4a8
FormulaC6H12O6
Compartmentc
In 19 reaction(s)\n", " GLCt2pp, GLCATr, TRE6PH, MLTG2, G6PP, LACZ, MLTG3, AMALT1, HEX1, XYLI2, MLTG4, GALS3, GLCabcpp, AMALT2, MLTG5, AMALT3, AMALT4, TREH, MLTG1
" ], "text/plain": [ "" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "model.metabolites.glc__D_c" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "And it is easy to find the associated reactions" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "frozenset({,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " })" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "model.metabolites.glc__D_c.reactions" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A list of the genes encoded in the model can be accessed via `model.genes`." ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "scrolled": true }, "outputs": [ { "data": { "text/plain": [ "[,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ]" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "model.genes[0:10]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Other additional attributes can be accessed to explore the model. For example, exchange reactions that allow certain metabolites to enter or leave the model can be accessed through `model.exchanges`." ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ]" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "model.exchanges[0:10]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Or, the current medium can be accessed through `model.medium`." ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'EX_ca2_e': 1000.0,\n", " 'EX_cbl1_e': 0.01,\n", " 'EX_cl_e': 1000.0,\n", " 'EX_co2_e': 1000.0,\n", " 'EX_cobalt2_e': 1000.0,\n", " 'EX_cu2_e': 1000.0,\n", " 'EX_fe2_e': 1000.0,\n", " 'EX_fe3_e': 1000.0,\n", " 'EX_glc__D_e': 10.0,\n", " 'EX_h2o_e': 1000.0,\n", " 'EX_h_e': 1000.0,\n", " 'EX_k_e': 1000.0,\n", " 'EX_mg2_e': 1000.0,\n", " 'EX_mn2_e': 1000.0,\n", " 'EX_mobd_e': 1000.0,\n", " 'EX_na1_e': 1000.0,\n", " 'EX_nh4_e': 1000.0,\n", " 'EX_ni2_e': 1000.0,\n", " 'EX_o2_e': 1000.0,\n", " 'EX_pi_e': 1000.0,\n", " 'EX_sel_e': 1000.0,\n", " 'EX_slnt_e': 1000.0,\n", " 'EX_so4_e': 1000.0,\n", " 'EX_tungs_e': 1000.0,\n", " 'EX_zn2_e': 1000.0}" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "model.medium" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "It is also possible to get a list of essential reactions ..." ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ]" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from cobra.flux_analysis import find_essential_reactions\n", "list(find_essential_reactions(model))[0:10]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "... and essential genes." ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ]" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from cobra.flux_analysis import find_essential_genes\n", "list(find_essential_genes(model))[0:10]" ] } ], "metadata": { "anaconda-cloud": {}, "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.4.5" } }, "nbformat": 4, "nbformat_minor": 1 }