{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Creates the following SBML models needed for the Sub-SBML notebook\n", "\n", "1. Transcription SBML model\n", "1. Translation SBML model\n", "1. Signal in mixture model\n", "1. Inducer molecule in abundance in mixture (external)\n", "1. Simple membrane model - One step diffusion\n", "1. Advanced membrane model - Two step diffusion \n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Transcription Model:\n", "\n", "Consider the following simple transcription-only model where $G$ is a gene, $T$ is a transcript, and $S$ is the signaling molecule.\n", "\n", "We can write the following reduced order dynamics:\n", "1. $G \\xrightarrow[]{\\rho_{tx}(G, S)} G + T$; \n", "\\begin{align} \n", "\\rho_{tx}(G, S) = G K_{X}\\frac{S^{2}}{K_{S}^{2}+S^{2}}\n", "\\\\\n", "\\end{align}\n", "Here, $S$ is the inducer signal that cooperatively activates the transcription of the gene $G$. Since, this is a positive activation of the gene by the inducer, we have a positive proportional Hill function.\n", "\n", "1. $T \\xrightarrow[]{\\delta} \\varnothing$; massaction kinetics at rate $\\delta$." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Model written to a SBML file successfully\n" ] } ], "source": [ "from bioscrape.types import Model\n", "import numpy as np\n", "import pylab as plt\n", "#Create a list of species names (strings)\n", "species = [\"G\", \"mRNA_T\", \"S\"]\n", "\n", "#create a list of parameters in the form (param_name[string], param_val[number])\n", "params = [(\"KX\", 2), (\"KI\", 10), (\"n\", 2.0), (\"delta\", .1)]\n", "\n", "#create reaction tuples in the form:\n", "#(Inputs[string list], Outputs[string list], propensity_type[string], propensity_dict {propensity_param:model_param})\n", "rxn1 = ([\"G\"], [\"G\", \"mRNA_T\"], \"proportionalhillpositive\", {\"d\":\"G\", \"s1\":\"S\", \"k\":\"KX\", \"K\":\"KI\", \"n\":\"n\"})\n", "\n", "# Or alternatively, use general propensity (simulation will be slower):\n", "# rxn2 = ([\"T\"], [\"T\", \"X\"], \"general\", {\"rate\":\"ktl * T/(KR + T)\"})\n", "\n", "#Notice that parameters can also take numerical values instead of being named directly\n", "rxn2 = ([\"mRNA_T\"], [], \"massaction\", {\"k\":\"delta\"})\n", " \n", "#Create a list of all reactions\n", "rxns = [rxn1, rxn2]\n", "\n", "#create an initial condition dictionary species not included in the dictionary will default to 0\n", "x0 = {\"G\":1, \"S\":0, \"mRNA_T\":0}\n", "\n", "#Instaniate the Model object\n", "M = Model(species = species, parameters = params, reactions = rxns, initial_condition_dict = x0)\n", "_ = M.write_sbml_model('transcription_SBML_model.xml')\n", "print('Model written to a SBML file successfully')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Translation model:\n", "\n", "1. $T \\xrightarrow[]{\\rho_{tl}(T)} T+X$; \n", "\\begin{align} \n", "\\rho_{tl}(T) = K_{TR} \\frac{T}{K_{R} + T}\n", "\\\\\n", "\\end{align}\n", "Here $X$ is the protein species.\n", "The lumped parameters $K_{TR}$ and $K_R$ model effects due to ribosome saturation. This is the similar Hill function as derived in the enzymatic reaction example. \n", "\n", "1. $X \\xrightarrow[]{\\delta} \\varnothing$; massaction kinetics at rate $\\delta$.\n" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Model written to a SBML file successfully\n" ] } ], "source": [ "from bioscrape.types import Model\n", "import numpy as np\n", "import pylab as plt\n", "#Create a list of species names (strings)\n", "species = [\"T\", \"X\"]\n", "\n", "#create a list of parameters in the form (param_name[string], param_val[number])\n", "params = [(\"KTR\", 5), (\"n\", 2.0), (\"KR\", 20), (\"delta\", .1)]\n", "\n", "#create reaction tuples in the form:\n", "#(Inputs[string list], Outputs[string list], propensity_type[string], propensity_dict {propensity_param:model_param})\n", "rxn1 = ([\"T\"], [\"T\", \"X\"], \"hillpositive\", {\"s1\":\"T\", \"k\":\"KTR\", \"K\":\"KR\", \"n\":1}) \n", "\n", "#Notice that parameters can also take numerical values instead of being named directly\n", "rxn2 = ([\"X\"], [], \"massaction\", {\"k\":\"delta\"})\n", " \n", "#Create a list of all reactions\n", "rxns = [rxn1, rxn2]\n", "x0 = {\"X\":0,\"T\":0}\n", "#Instaniate the Model object\n", "M = Model(species = species, parameters = params, reactions = rxns, initial_condition_dict = x0)\n", "_ = M.write_sbml_model('translation_SBML_model.xml')\n", "print('Model written to a SBML file successfully')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Signal induction model:\n", "\n", "1. $\\varnothing \\xrightarrow[]{\\rho(I)} S$; \n", "\\begin{align} \n", "\\rho(S) = K_{0} \\frac{I^2}{K_{I} + I^2}\n", "\\\\\n", "\\end{align}\n", "Here $S$ is the signal produced on induction by an inducer $I$.\n", "The lumped parameters $K_{0}$ and $K_S$ model effects of cooperative production of the signal by the inducer. This is the similar Hill function as derived in the enzymatic reaction example. " ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Model written to a SBML file successfully\n" ] } ], "source": [ "from bioscrape.types import Model\n", "import numpy as np\n", "import pylab as plt\n", "#Create a list of species names (strings)\n", "species = [\"I\", \"S\"]\n", "\n", "#create a list of parameters in the form (param_name[string], param_val[number])\n", "params = [(\"KI\", 25), (\"n\", 2.0), (\"K0\", 20)]\n", "\n", "#create reaction tuples in the form:\n", "#(Inputs[string list], Outputs[string list], propensity_type[string], propensity_dict {propensity_param:model_param})\n", "rxn1 = ([], [\"S\"], \"hillpositive\", {\"s1\":\"I\", \"k\":\"K0\", \"K\":\"KI\", \"n\":\"n\"}) \n", " \n", "#Create a list of all reactions\n", "rxns = [rxn1]\n", "x0 = {\"I\":100, \"S\":0}\n", "#Instaniate the Model object\n", "M = Model(species = species, parameters = params, reactions = rxns,initial_condition_dict = x0)\n", "_ = M.write_sbml_model('signal_in_mixture.xml')\n", "print('Model written to a SBML file successfully')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Inducer reservoir in mixture:\n", "\n", "A simple model with only one species - \"IPTG\" - the inducer. This species is present in abundance in the \"external\" compartment in this model. Hence, this model represents the exterior of a cell system." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Model written to a SBML file successfully\n" ] } ], "source": [ "##### Creating a IPTG reservoir model####\n", "\n", "from subsbml import createBasicSubsystem, SimpleModel\n", "import libsbml\n", "\n", "IPTG_ss, IPTG_model = createBasicSubsystem('reservoir')\n", "\n", "per_second = IPTG_model.createNewUnitDefinition('per_second',libsbml.UNIT_KIND_SECOND,-1,0,1)\n", "substance = IPTG_model.createNewUnitDefinition('substance',libsbml.UNIT_KIND_DIMENSIONLESS, 1, 0, 1)\n", "\n", "\n", "IPTG_model.createNewSpecies('IPTG',sComp = 'reservoir', ListOfAmounts = 1e4, \n", " sConstant = False, sSubstance = 'substance')\n", "\n", "# Write to SBML file \n", "_ = IPTG_ss.writeSBML('IPTG_reservoir.xml')\n", "print('Model written to a SBML file successfully')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## IPTG simple membrane model\n", "\n", "IPTG_internal $\\leftrightarrow$ IPTG_external " ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Model written to a SBML file successfully\n" ] } ], "source": [ "##### Creating a basic membrane model for IPTG transport####\n", "\n", "from subsbml import createNewSubsystem, SimpleModel, SimpleReaction\n", "\n", "IPTG_mb_ss = createNewSubsystem()\n", "model = IPTG_mb_ss.createNewModel('IPTG_membrane','second','mole','substance')\n", "\n", "IPTG_mb = SimpleModel(model)\n", "\n", "per_second = IPTG_mb.createNewUnitDefinition('per_second',libsbml.UNIT_KIND_SECOND,-1,0,1)\n", "substance = IPTG_mb.createNewUnitDefinition('substance',libsbml.UNIT_KIND_DIMENSIONLESS, 1, 0, 1)\n", "\n", "################# Two important lines of code when creating membrane #########################\n", "IPTG_mb.createNewCompartment('internal','internal',2e-6,'litre',True)\n", "IPTG_mb.createNewCompartment('external','external',1e-6,'litre',True)\n", "##############################################################################################\n", "\n", "IPTG_mb.createNewSpecies('IPTG','external',0,False,'substance')\n", "IPTG_mb.createNewSpecies('IPTG','internal',0,False,'substance')\n", "\n", "IPTG_mb.createNewParameter('kb',0.01,False,'per_second')\n", "IPTG_mb.createNewParameter('kd',0.2,False,'per_second')\n", "\n", "# model = IPTG_mb_ss.getSBMLDocument().getModel()\n", "r1_sbml = model.createReaction()\n", "r1 = SimpleReaction(r1_sbml)\n", "r1.setId('r1')\n", "r1.setReversible(True)\n", "r1.createNewReactant('IPTG',False,1)\n", "r1.createNewProduct('IPTG_1', False, 1)\n", "math_r1 = r1.createMath('kb * IPTG - kd * IPTG_1')\n", "r1.createRate(math_r1)\n", "\n", "# Write to SBML file \n", "_ = IPTG_mb_ss.writeSBML('membrane_IPTG.xml')\n", "print('Model written to a SBML file successfully')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## IPTG advanced membrane model\n", "\n", "1. IPTG_external + transport_protein $\\leftrightarrow$ IPTG_transport_protein \n", "1. IPTG_transport_protein $\\leftrightarrow$ IPTG_internal" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Model written to a SBML file successfully\n" ] } ], "source": [ "##### Creating a advanced membrane model for IPTG transport####\n", "\n", "from subsbml import createNewSubsystem, SimpleModel, SimpleReaction\n", "\n", "IPTG_mb_ss = createNewSubsystem()\n", "model = IPTG_mb_ss.createNewModel('IPTG_membrane','second','mole','substance')\n", "\n", "IPTG_mb = SimpleModel(model)\n", "\n", "per_second = IPTG_mb.createNewUnitDefinition('per_second',libsbml.UNIT_KIND_SECOND,-1,0,1)\n", "substance = IPTG_mb.createNewUnitDefinition('substance',libsbml.UNIT_KIND_DIMENSIONLESS, 1, 0, 1)\n", "\n", "################# Two important lines of code when creating membrane #########################\n", "IPTG_mb.createNewCompartment('internal','internal',1e-6,'litre',True)\n", "IPTG_mb.createNewCompartment('external','external',1e-6,'litre',True)\n", "##############################################################################################\n", "\n", "IPTG_mb.createNewSpecies( 'IPTG','external',0,False,'substance')\n", "IPTG_mb.createNewSpecies( 'IPTG','internal',0,False,'substance')\n", "IPTG_mb.createNewSpecies( 'transport_protein','internal',1,False,'substance')\n", "IPTG_mb.createNewSpecies( 'IPTG_transport_protein','internal',0,False,'substance')\n", "\n", "IPTG_mb.createNewParameter( 'kb',0.01,False,'per_second')\n", "IPTG_mb.createNewParameter( 'kd',0.2,False,'per_second')\n", "\n", "model = IPTG_mb_ss.getSBMLDocument().getModel()\n", "\n", "r1 = SimpleReaction(model.createReaction())\n", "r1.setId('r1')\n", "r1.setReversible(True)\n", "r1.createNewReactant('IPTG',False,1)\n", "r1.createNewReactant('transport_protein', False, 1)\n", "r1.createNewProduct('IPTG_transport_protein', False, 1)\n", "math_r1 = r1.createMath('kb * IPTG * transport_protein - kd * IPTG_transport_protein')\n", "r1.createRate(math_r1)\n", "\n", "r2 = SimpleReaction(model.createReaction())\n", "r2.setId('r2')\n", "r2.setReversible(True)\n", "r2.createNewReactant('IPTG_transport_protein',False,1)\n", "r2.createNewProduct('IPTG_1',False,1)\n", "r2.createNewProduct('transport_protein',False,1)\n", "math_r2 = r2.createMath('kd * IPTG_transport_protein - kb * IPTG_1 * transport_protein')\n", "r2.createRate(math_r2)\n", "\n", "# Write to SBML file \n", "_ = IPTG_mb_ss.writeSBML('membrane_IPTG_detailed.xml')\n", "print('Model written to a SBML file successfully')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "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.7.7" } }, "nbformat": 4, "nbformat_minor": 2 }