{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Gapfillling\n", "\n", "GrowMatch and SMILEY are gap-filling algorithms, which try to to make the minimal number of changes to a model and allow it to simulate growth. For more information, see [Kumar et al.](http://dx.doi.org/10.1371/journal.pcbi.1000308). Please note that these algorithms are Mixed-Integer Linear Programs, which need solvers such as gurobi or cplex to function correctly." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import cobra.test\n", "\n", "model = cobra.test.create_test_model(\"salmonella\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In this model D-Fructose-6-phosphate is an essential metabolite. We will remove all the reactions using it, and at them to a separate model." ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# remove some reactions and add them to the universal reactions\n", "Universal = cobra.Model(\"Universal_Reactions\")\n", "for i in [i.id for i in model.metabolites.f6p_c.reactions]:\n", " reaction = model.reactions.get_by_id(i)\n", " Universal.add_reaction(reaction.copy())\n", " reaction.remove_from_model()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now, because of these gaps, the model won't grow." ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "2.821531499799383e-12" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "model.optimize().f" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## GrowMatch\n", "\n", "We will use GrowMatch to add back the minimal number of reactions from this set of \"universal\" reactions (in this case just the ones we removed) to allow it to grow." ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "GF6PTA\n", "FBP\n", "MAN6PI_reverse\n", "TKT2_reverse\n", "PGI_reverse\n" ] } ], "source": [ "r = cobra.flux_analysis.growMatch(model, Universal)\n", "for e in r[0]:\n", " print(e.id)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can obtain multiple possible reaction sets by having the algorithm go through multiple iterations." ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "---- Run 1 ----\n", "GF6PTA\n", "FBP\n", "MAN6PI_reverse\n", "TKT2_reverse\n", "PGI_reverse\n", "---- Run 2 ----\n", "F6PP\n", "GF6PTA\n", "TALA\n", "MAN6PI_reverse\n", "F6PA_reverse\n", "---- Run 3 ----\n", "GF6PTA\n", "MAN6PI_reverse\n", "TKT2_reverse\n", "F6PA_reverse\n", "PGI_reverse\n", "---- Run 4 ----\n", "F6PP\n", "GF6PTA\n", "FBP\n", "TALA\n", "MAN6PI_reverse\n" ] } ], "source": [ "result = cobra.flux_analysis.growMatch(model, Universal,\n", " iterations=4)\n", "for i, entries in enumerate(result):\n", " print(\"---- Run %d ----\" % (i + 1))\n", " for e in entries:\n", " print(e.id)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## SMILEY\n", "\n", "SMILEY is very similar to growMatch, only instead of setting growth as the objective, it sets production of a specific metabolite" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "GF6PTA\n", "MAN6PI_reverse\n", "TKT2_reverse\n", "F6PA_reverse\n", "PGI_reverse\n" ] } ], "source": [ "r = cobra.flux_analysis.gapfilling.SMILEY(model, \"ac_e\",\n", " Universal)\n", "for e in r[0]:\n", " print(e.id)" ] } ], "metadata": { "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.3" } }, "nbformat": 4, "nbformat_minor": 0 }