{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import logging" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "logging.basicConfig(level=\"DEBUG\")" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "DEBUG:optlang.util:Gurobi python bindings not available.\n", "DEBUG:optlang.util:GLPK python bindings found at /Users/uridavidakavia/PycharmProjects/venv_cobrapy3_7/lib/python3.7/site-packages/swiglpk\n", "DEBUG:optlang.util:Mosek python bindings not available.\n", "DEBUG:optlang.util:CPLEX python bindings not available.\n", "DEBUG:optlang.util:OSQP python bindings not available.\n", "DEBUG:optlang.util:COINOR_CBC python bindings not available.\n", "DEBUG:optlang.util:Scipy linprog function found at /Users/uridavidakavia/PycharmProjects/venv_cobrapy3_7/lib/python3.7/site-packages/scipy/optimize/__init__.py\n" ] } ], "source": [ "from cobra.io import load_model" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "from cobra.flux_analysis import single_gene_deletion" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "INFO:cobra.core.model:The current solver interface glpk doesn't support setting the optimality tolerance.\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Scaling...\n", " A: min|aij| = 1.000e+00 max|aij| = 1.000e+00 ratio = 1.000e+00\n", "Problem data seem to be well scaled\n" ] } ], "source": [ "model = load_model(\"textbook\")" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "genes = ['b0008', 'b0114', 'b2276', 'b1779']" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "model.solver = \"cplex\"" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "logging.getLogger().setLevel(logging.DEBUG)" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "CPU times: user 308 ms, sys: 0 ns, total: 308 ms\n", "Wall time: 307 ms\n" ] }, { "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", "
growthstatus
ids
(b1779)5.034815e+00optimal
(b2276)5.475871e+00optimal
(b0114)1.224159e+00optimal
(b0008)3.028591e-15optimal
\n", "
" ], "text/plain": [ " growth status\n", "ids \n", "(b1779) 5.034815e+00 optimal\n", "(b2276) 5.475871e+00 optimal\n", "(b0114) 1.224159e+00 optimal\n", "(b0008) 3.028591e-15 optimal" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%time single_gene_deletion(model, method=\"linear room\", gene_list=genes, processes=1)" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "model.solver = \"gurobi\"" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "CPU times: user 271 ms, sys: 0 ns, total: 271 ms\n", "Wall time: 265 ms\n" ] }, { "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", "
growthstatus
ids
(b1779)5.034815optimal
(b2276)5.475871optimal
(b0114)1.224159optimal
(b0008)0.000000optimal
\n", "
" ], "text/plain": [ " growth status\n", "ids \n", "(b1779) 5.034815 optimal\n", "(b2276) 5.475871 optimal\n", "(b0114) 1.224159 optimal\n", "(b0008) 0.000000 optimal" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%time single_gene_deletion(model, method=\"linear room\", gene_list=genes, processes=1)" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [], "source": [ "model.solver = \"glpk\"" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [], "source": [ "model.solver.configuration.timeout = 20" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "DEBUG:optlang.glpk_interface:Status undefined. GLPK status code returned by glp_simplex was 1\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "CPU times: user 205 ms, sys: 4.99 ms, total: 210 ms\n", "Wall time: 203 ms\n" ] }, { "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", "
growthstatus
ids
(b1779)5.034815e+00optimal
(b2276)5.475871e+00optimal
(b0114)1.224159e+00optimal
(b0008)-5.857507e-17optimal
\n", "
" ], "text/plain": [ " growth status\n", "ids \n", "(b1779) 5.034815e+00 optimal\n", "(b2276) 5.475871e+00 optimal\n", "(b0114) 1.224159e+00 optimal\n", "(b0008) -5.857507e-17 optimal" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%time single_gene_deletion(model, method=\"linear room\", gene_list=genes, processes=1)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.7.1" } }, "nbformat": 4, "nbformat_minor": 2 }