{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Global Configuration" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "With cobra > 0.13.4, we introduce a global configuration object. For now, you can configure default reaction bounds and optimization solver which will be respected by newly created reactions and models." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## The configuration object" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can get a configuration object[1](#f1) in the following way:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import cobra" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "cobra_config = cobra.Configuration()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "1The configuration object is a [singleton](https://en.wikipedia.org/wiki/Singleton_pattern). That means only one instance can exist and it is respected everywhere in COBRApy." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Reaction bounds" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The object has the following attributes which you can inspect but also change as desired." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "-1000.0" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "cobra_config.lower_bound" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1000.0" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "cobra_config.upper_bound" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(-1000.0, 1000.0)" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "cobra_config.bounds" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Changing bounds" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If you modify the above values before creating a reaction they will be used." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "cobra_config.bounds = -10, 20" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
Reaction identifier | R1 | \n", "
Name | \n", " |
Memory address | \n", "0x7f8642e5bba8 | \n", "
Stoichiometry | \n", "\n",
" --> \n", "--> \n", " | \n",
"
GPR | \n", " |
Lower bound | 0.0 | \n", "
Upper bound | 20 | \n", "
Reaction identifier | R2 | \n", "
Name | \n", " |
Memory address | \n", "0x7f8642e5bda0 | \n", "
Stoichiometry | \n", "\n",
" <=> \n", "<=> \n", " | \n",
"
GPR | \n", " |
Lower bound | -10 | \n", "
Upper bound | 20 | \n", "
Reaction identifier | ACt2r | \n", "
Name | R acetate reversible transport via proton - symport | \n", "
Memory address | \n", "0x7f8642f174e0 | \n", "
Stoichiometry | \n", "\n",
" ac_e + h_e <=> ac_c + h_c \n", "Acetate + H+ <=> Acetate + H+ \n", " | \n",
"
GPR | \n", " |
Lower bound | -1000.0 | \n", "
Upper bound | 1000.0 | \n", "