{
"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 found at /home/moritz/.virtualenvs/cobra/lib/python3.5/site-packages/gurobipy\n",
"DEBUG:optlang.util:GLPK python bindings found at /home/moritz/.virtualenvs/cobra/lib/python3.5/site-packages/swiglpk\n",
"DEBUG:optlang.util:Mosek python bindings not available.\n",
"DEBUG:optlang.util:CPLEX python bindings found at /home/moritz/.virtualenvs/cobra/lib/python3.5/site-packages/cplex\n",
"DEBUG:optlang.util:Scipy solver not available\n",
"DEBUG:pip._internal.utils.misc:lzma module is not available\n",
"DEBUG:pip._internal.vcs:Registered VCS backend: git\n",
"DEBUG:pip._internal.vcs:Registered VCS backend: hg\n",
"DEBUG:pip._internal.vcs:Registered VCS backend: svn\n",
"DEBUG:pip._internal.vcs:Registered VCS backend: bzr\n"
]
}
],
"source": [
"from cobra.test import create_test_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": [],
"source": [
"model = create_test_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": "stderr",
"output_type": "stream",
"text": [
"WARNING:root:Warning: No solution found from 6 MIP starts.\n",
"\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"CPU times: user 21.4 s, sys: 84.2 ms, total: 21.5 s\n",
"Wall time: 3.23 s\n"
]
},
{
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" growth | \n",
" status | \n",
"
\n",
" \n",
" ids | \n",
" | \n",
" | \n",
"
\n",
" \n",
" \n",
" \n",
" (b1779) | \n",
" 45.0 | \n",
" optimal | \n",
"
\n",
" \n",
" (b0008) | \n",
" 0.0 | \n",
" optimal | \n",
"
\n",
" \n",
" (b0114) | \n",
" 27.0 | \n",
" optimal | \n",
"
\n",
" \n",
" (b2276) | \n",
" 46.0 | \n",
" optimal | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" growth status\n",
"ids \n",
"(b1779) 45.0 optimal\n",
"(b0008) 0.0 optimal\n",
"(b0114) 27.0 optimal\n",
"(b2276) 46.0 optimal"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"%time single_gene_deletion(model, method=\"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 1.97 s, sys: 4.23 ms, total: 1.98 s\n",
"Wall time: 1.97 s\n"
]
},
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" growth | \n",
" status | \n",
"
\n",
" \n",
" ids | \n",
" | \n",
" | \n",
"
\n",
" \n",
" \n",
" \n",
" (b1779) | \n",
" 45.0 | \n",
" optimal | \n",
"
\n",
" \n",
" (b0008) | \n",
" 0.0 | \n",
" optimal | \n",
"
\n",
" \n",
" (b0114) | \n",
" 27.0 | \n",
" optimal | \n",
"
\n",
" \n",
" (b2276) | \n",
" 46.0 | \n",
" optimal | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" growth status\n",
"ids \n",
"(b1779) 45.0 optimal\n",
"(b0008) 0.0 optimal\n",
"(b0114) 27.0 optimal\n",
"(b2276) 46.0 optimal"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"%time single_gene_deletion(model, method=\"room\", gene_list=genes, processes=1)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"model.solver = \"glpk\""
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"model.solver.configuration.timeout = 20"
]
},
{
"cell_type": "code",
"execution_count": 15,
"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 1min 21s, sys: 53.1 ms, total: 1min 21s\n",
"Wall time: 1min 21s\n"
]
},
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" growth | \n",
" status | \n",
"
\n",
" \n",
" ids | \n",
" | \n",
" | \n",
"
\n",
" \n",
" \n",
" \n",
" (b1779) | \n",
" 45.0 | \n",
" optimal | \n",
"
\n",
" \n",
" (b0008) | \n",
" 0.0 | \n",
" optimal | \n",
"
\n",
" \n",
" (b0114) | \n",
" NaN | \n",
" time_limit | \n",
"
\n",
" \n",
" (b2276) | \n",
" NaN | \n",
" time_limit | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" growth status\n",
"ids \n",
"(b1779) 45.0 optimal\n",
"(b0008) 0.0 optimal\n",
"(b0114) NaN time_limit\n",
"(b2276) NaN time_limit"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"%time single_gene_deletion(model, method=\"room\", gene_list=genes, processes=1)"
]
}
],
"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.5.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}