{ "cells": [ { "cell_type": "markdown", "id": "c6194f89", "metadata": {}, "source": [ "Create the repressilator step by step.\n", "\n", "See on biomodels.\n", "\n", "https://github.com/sbmlteam/libsbml" ] }, { "cell_type": "code", "execution_count": 1, "id": "02e33d32", "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false } }, "outputs": [], "source": [ "from pathlib import Path\n", "\n", "import libsbml\n", "\n", "from combine_notebooks.validation.validation_sbml import validate_sbml" ] }, { "cell_type": "code", "execution_count": 2, "id": "87a15b98", "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false } }, "outputs": [], "source": [ "def create_repressilator(sbml_path: Path) -> libsbml.SBMLDocument:\n", " \"\"\"Create repressilator.\"\"\"\n", " print(\"Create SBML model\")\n", " # create a new document\n", "\n", " doc: libsbml.SBMLDocument = libsbml.SBMLDocument(3, 2)\n", " model: libsbml.Model = doc.createModel()\n", "\n", " # --- compartments ---\n", " # add compartment\n", " c1: libsbml.Compartment = model.createCompartment()\n", " c1.setId(\"cell\")\n", " c1.setSize(1.0)\n", " c1.setMetaId(\"meta_cell\")\n", " c1.setSBOTerm(\"SBO:0000290\")\n", " # set annotation\n", " c1_cv: libsbml.CVTerm = libsbml.CVTerm()\n", " c1_cv.setQualifierType(libsbml.BIOLOGICAL_QUALIFIER)\n", " c1_cv.setBiologicalQualifierType(libsbml.BQB_IS)\n", " c1_cv.addResource(\"http://identifiers.org/GO:0005623\")\n", " c1.addCVTerm(c1_cv)\n", "\n", " # --- species ---\n", " # add species for the 3 mRNAs and 3 Proteins\n", " s1: libsbml.Species = model.createSpecies()\n", " s1.setId(\"PX\")\n", " s1.setMetaId(\"PX\")\n", " s1.setCompartment(\"cell\")\n", " s1.setName(\"LacI protein\")\n", " s1.setSBOTerm(\"SBO:0000252\")\n", " s1.setInitialAmount(0)\n", " s1.setHasOnlySubstanceUnits(True)\n", " # set annotation\n", " s1_cv: libsbml.CVTerm = libsbml.CVTerm()\n", " s1_cv.setQualifierType(libsbml.BIOLOGICAL_QUALIFIER)\n", " s1_cv.setBiologicalQualifierType(libsbml.BQB_IS)\n", " s1_cv.addResource(\"http://identifiers.org/uniprot/P03023\")\n", " s1.addCVTerm(s1_cv)\n", "\n", " s2: libsbml.Species = model.createSpecies()\n", " s2.setId(\"PY\")\n", " s2.setMetaId(\"PY\")\n", " s2.setCompartment(\"cell\")\n", " s2.setName(\"TetR protein\")\n", " s2.setSBOTerm(\"SBO:0000252\")\n", " s2.setInitialAmount(0)\n", " s2.setHasOnlySubstanceUnits(True)\n", " # set annotation\n", " s2_cv: libsbml.CVTerm = libsbml.CVTerm()\n", " s2_cv.setQualifierType(libsbml.BIOLOGICAL_QUALIFIER)\n", " s2_cv.setBiologicalQualifierType(libsbml.BQB_IS)\n", " s2_cv.addResource(\"http://identifiers.org/uniprot/P04483\")\n", " s2.addCVTerm(s2_cv)\n", "\n", " s3: libsbml.Species = model.createSpecies()\n", " s3.setId(\"PZ\")\n", " s3.setMetaId(\"PZ\")\n", " s3.setCompartment(\"cell\")\n", " s3.setName(\"cI protein\")\n", " s3.setSBOTerm(\"SBO:0000252\")\n", " s3.setInitialAmount(0)\n", " s3.setHasOnlySubstanceUnits(True)\n", " # set annotation\n", " s3_cv: libsbml.CVTerm = libsbml.CVTerm()\n", " s3_cv.setQualifierType(libsbml.BIOLOGICAL_QUALIFIER)\n", " s3_cv.setBiologicalQualifierType(libsbml.BQB_IS)\n", " # example setting a model qualifier\n", " # s3_cv.setQualifierType(libsbml.MODEL_QUALIFIER)\n", " # s3_cv.setBiologicalQualifierType(libsbml.BQM_IS)\n", " s3_cv.addResource(\"http://identifiers.org/uniprot/P03034\")\n", " s3.addCVTerm(s3_cv)\n", "\n", " s4: libsbml.Species = model.createSpecies()\n", " s4.setId(\"X\")\n", " s4.setMetaId(\"meta_X\")\n", " s4.setCompartment(\"cell\")\n", " s4.setName(\"LacI mRNA\")\n", " s4.setSBOTerm(\"SBO:0000250\")\n", " s4.setInitialAmount(0)\n", " s4.setHasOnlySubstanceUnits(True)\n", " # set annotation\n", " s4_cv: libsbml.CVTerm = libsbml.CVTerm()\n", " s4_cv.setQualifierType(libsbml.BIOLOGICAL_QUALIFIER)\n", " s4_cv.setBiologicalQualifierType(libsbml.BQB_IS_VERSION_OF)\n", " s4_cv.addResource(\"http://identifiers.org/CHEBI:33699\")\n", " s4_cv.setBiologicalQualifierType(libsbml.BQB_IS_VERSION_OF)\n", " s4_cv.addResource(\"http://identifiers.org/kegg.compound/C00046\")\n", " s4.addCVTerm(s4_cv)\n", " s4_cv.setBiologicalQualifierType(libsbml.BQB_ENCODES)\n", " s4_cv.addResource(\"http://identifiers.org/uniprot/P03023\")\n", " s4.addCVTerm(s4_cv)\n", "\n", " s5: libsbml.Species = model.createSpecies()\n", " s5.setId(\"Y\")\n", " s5.setMetaId(\"meta_Y\")\n", " s5.setCompartment(\"cell\")\n", " s5.setName(\"TetR mRNA\")\n", " s5.setSBOTerm(\"SBO:0000250\")\n", " s5.setInitialAmount(20)\n", " s5.setHasOnlySubstanceUnits(True)\n", " # set annotation\n", " s5_cv: libsbml.CVTerm = libsbml.CVTerm()\n", " s5_cv.setQualifierType(libsbml.BIOLOGICAL_QUALIFIER)\n", " s5_cv.setBiologicalQualifierType(libsbml.BQB_IS_VERSION_OF)\n", " s5_cv.addResource(\"http://identifiers.org/CHEBI:33699\")\n", " s5_cv.setBiologicalQualifierType(libsbml.BQB_IS_VERSION_OF)\n", " s5_cv.addResource(\"http://identifiers.org/kegg.compound/C00046\")\n", " s5.addCVTerm(s5_cv)\n", " s5_cv.setBiologicalQualifierType(libsbml.BQB_ENCODES)\n", " s5_cv.addResource(\"http://identifiers.org/uniprot/P04483\")\n", " s5.addCVTerm(s5_cv)\n", "\n", " s6: libsbml.Species = model.createSpecies()\n", " s6.setId(\"Z\")\n", " s6.setMetaId(\"meta_Z\")\n", " s6.setCompartment(\"cell\")\n", " s6.setName(\"cl mRNA\")\n", " s6.setSBOTerm(\"SBO:0000250\")\n", " s6.setInitialAmount(0)\n", " s6.setHasOnlySubstanceUnits(True)\n", " # set annotation\n", " s6_cv: libsbml.CVTerm = libsbml.CVTerm()\n", " s6_cv.setQualifierType(libsbml.BIOLOGICAL_QUALIFIER)\n", " s6_cv.setBiologicalQualifierType(libsbml.BQB_IS_VERSION_OF)\n", " s6_cv.addResource(\"http://identifiers.org/CHEBI:33699\")\n", " s6_cv.setBiologicalQualifierType(libsbml.BQB_IS_VERSION_OF)\n", " s6_cv.addResource(\"http://identifiers.org/kegg.compound/C00046\")\n", " s6.addCVTerm(s6_cv)\n", " s6_cv.setBiologicalQualifierType(libsbml.BQB_ENCODES)\n", " s6_cv.addResource(\"http://identifiers.org/uniprot/P03034\")\n", " s6.addCVTerm(s6_cv)\n", "\n", " # --- parameters ---\n", " # \n", " p1: libsbml.Parameter = model.createParameter()\n", " p1.setId(\"tau_mRNA\")\n", " p1.setName(\"mRNA half life\")\n", " p1.setConstant(True)\n", " p1.setValue(2.0)\n", "\n", " # \n", " p2: libsbml.Parameter = model.createParameter()\n", " p2.setId(\"kd_mRNA\")\n", " p2.setName(\"kd_mRNA\")\n", " p2.setSBOTerm(\"SBO:0000356\")\n", " p2.setConstant(False)\n", "\n", " # \n", " p3: libsbml.Parameter = model.createParameter()\n", " p3.setId(\"k_tl\")\n", " p3.setName(\"k_tl\")\n", " p3.setSBOTerm(\"SBO:0000016\")\n", " p3.setConstant(False)\n", "\n", " # \n", " p4: libsbml.Parameter = model.createParameter()\n", " p4.setId(\"eff\")\n", " p4.setName(\"translation efficiency\")\n", " p4.setConstant(True)\n", " p4.setValue(20)\n", "\n", " # \n", " p5: libsbml.Parameter = model.createParameter()\n", " p5.setId(\"t_ave\")\n", " p5.setName(\"average mRNA life time\")\n", " p5.setSBOTerm(\"SBO:0000348\")\n", " p5.setConstant(False)\n", "\n", " # \n", " p6: libsbml.Parameter = model.createParameter()\n", " p6.setId(\"kd_prot\")\n", " p6.setName(\"kd_prot\")\n", " p6.setSBOTerm(\"SBO:0000356\")\n", " p6.setConstant(False)\n", "\n", " # \n", " p7: libsbml.Parameter = model.createParameter()\n", " p7.setId(\"tau_prot\")\n", " p7.setName(\"protien half life\")\n", " p7.setConstant(True)\n", " p7.setValue(10)\n", "\n", " # \n", " p8: libsbml.Parameter = model.createParameter()\n", " p8.setId(\"a0_tr\")\n", " p8.setName(\"a0_tr\")\n", " p8.setSBOTerm(\"SBO:0000485\")\n", " p8.setConstant(False)\n", "\n", " # \n", " p9: libsbml.Parameter = model.createParameter()\n", " p9.setId(\"ps_0\")\n", " p9.setName(\"tps_repr\")\n", " p9.setConstant(True)\n", " p9.setValue(0.0005)\n", "\n", " # \n", " p10: libsbml.Parameter = model.createParameter()\n", " p10.setId(\"a_tr\")\n", " p10.setName(\"a_tr\")\n", " p10.setSBOTerm(\"SBO:0000186\")\n", " p10.setConstant(False)\n", "\n", " # \n", " p11: libsbml.Parameter = model.createParameter()\n", " p11.setId(\"ps_a\")\n", " p11.setName(\"tps_active\")\n", " p11.setConstant(True)\n", " p11.setValue(0.5)\n", "\n", " # \n", " p12: libsbml.Parameter = model.createParameter()\n", " p12.setId(\"KM\")\n", " p12.setName(\"KM\")\n", " p12.setConstant(True)\n", " p12.setValue(40)\n", "\n", " # \n", " p13: libsbml.Parameter = model.createParameter()\n", " p13.setId(\"n\")\n", " p13.setName(\"n\")\n", " p13.setConstant(True)\n", " p13.setValue(2.0)\n", "\n", " # TODO: a0_tr, a_tr, n, KM\n", "\n", " # --- rules ---\n", " a1: libsbml.AssignmentRule = model.createAssignmentRule()\n", " a1.setVariable(\"kd_mRNA\")\n", " math_ast1: libsbml.ASTNode = libsbml.parseL3FormulaWithModel(\n", " \"ln(2) / tau_mRNA\", model\n", " )\n", " a1.setMath(math_ast1)\n", "\n", " a2: libsbml.AssignmentRule = model.createAssignmentRule()\n", " a2.setVariable(\"t_ave\")\n", " math_ast2: libsbml.ASTNode = libsbml.parseL3FormulaWithModel(\n", " \"tau_mRNA / ln(2)\", model\n", " )\n", " a2.setMath(math_ast2)\n", "\n", " a3: libsbml.AssignmentRule = model.createAssignmentRule()\n", " a3.setVariable(\"k_tl\")\n", " math_ast3: libsbml.ASTNode = libsbml.parseL3FormulaWithModel(\"eff / t_ave\", model)\n", " a3.setMath(math_ast3)\n", "\n", " a4: libsbml.AssignmentRule = model.createAssignmentRule()\n", " a4.setVariable(\"kd_prot\")\n", " math_ast4: libsbml.ASTNode = libsbml.parseL3FormulaWithModel(\n", " \"ln(2) / tau_prot\", model\n", " )\n", " a4.setMath(math_ast4)\n", "\n", " a5: libsbml.AssignmentRule = model.createAssignmentRule()\n", " a5.setVariable(\"a0_tr\")\n", " math_ast5: libsbml.ASTNode = libsbml.parseL3FormulaWithModel(\"ps_0 * 60\", model)\n", " a5.setMath(math_ast5)\n", "\n", " a6: libsbml.AssignmentRule = model.createAssignmentRule()\n", " a6.setVariable(\"a_tr\")\n", " math_ast6: libsbml.ASTNode = libsbml.parseL3FormulaWithModel(\n", " \"(ps_a - ps_0) * 60\", model\n", " )\n", " a6.setMath(math_ast6)\n", "\n", " # --- reaction ---\n", " # X -> None\n", " r1: libsbml.Reaction = model.createReaction()\n", " r1.setId(\"Reaction1\"), # set reaction id\n", " r1.setMetaId(\"meta_Reaction1\")\n", " r1.setSBOTerm(\"SBO:0000179\")\n", " r1.setName(\"degradation of LacI transcripts\")\n", " r1.setReversible(False)\n", " # set annotation\n", " r1_cv: libsbml.CVTerm = libsbml.CVTerm()\n", " r1_cv.setQualifierType(libsbml.BIOLOGICAL_QUALIFIER)\n", " r1_cv.setBiologicalQualifierType(libsbml.BQB_IS_VERSION_OF)\n", " r1_cv.addResource(\"http://identifiers.org/GO:0006402\")\n", " r1.addCVTerm(r1_cv)\n", "\n", " species_ref1: libsbml.SpeciesReference = r1.createReactant()\n", " species_ref1.setSpecies(\"X\") # assign reactant species\n", "\n", " math_ast7: libsbml.ASTNode = libsbml.parseL3FormulaWithModel(\"kd_mRNA * X\", model)\n", " kinetic_law = r1.createKineticLaw()\n", " kinetic_law.setSBOTerm(\"SBO:0000049\")\n", " kinetic_law.setMath(math_ast7)\n", "\n", " r2 = model.createReaction()\n", " r2.setId(\"Reaction2\"), # set reaction id\n", " r2.setMetaId(\"meta_Reaction2\")\n", " r2.setSBOTerm(\"SBO:0000179\")\n", " r2.setName(\"degradation of TetR transcripts\")\n", " r2.setReversible(False)\n", "\n", " r2_cv: libsbml.CVTerm = libsbml.CVTerm()\n", " r2_cv.setQualifierType(libsbml.BIOLOGICAL_QUALIFIER)\n", " r2_cv.setBiologicalQualifierType(libsbml.BQB_IS_VERSION_OF)\n", " r2_cv.addResource(\"http://identifiers.org/GO:0006402\")\n", " r2.addCVTerm(r1_cv)\n", "\n", " species_ref2 = r2.createReactant()\n", " species_ref2.setSpecies(\"Y\") # assign reactant species\n", "\n", " math_ast8: libsbml.ASTNode = libsbml.parseL3FormulaWithModel(\"kd_mRNA * Y\", model)\n", " kinetic_law = r2.createKineticLaw()\n", " kinetic_law.setSBOTerm(\"SBO:0000049\")\n", " kinetic_law.setMath(math_ast8)\n", "\n", " r3 = model.createReaction()\n", " r3.setId(\"Reaction3\"), # set reaction id\n", " r3.setMetaId(\"meta_Reaction3\")\n", " r3.setSBOTerm(\"SBO:0000179\")\n", " r3.setName(\"degradation of CI transcripts\")\n", " r3.setReversible(False)\n", " # set annotation\n", " r3_cv: libsbml.CVTerm = libsbml.CVTerm()\n", " r3_cv.setQualifierType(libsbml.BIOLOGICAL_QUALIFIER)\n", " r3_cv.setBiologicalQualifierType(libsbml.BQB_IS_VERSION_OF)\n", " r3_cv.addResource(\"http://identifiers.org/GO:0006402\")\n", " r3.addCVTerm(r3_cv)\n", "\n", " species_ref3 = r3.createReactant()\n", " species_ref3.setSpecies(\"Z\") # assign reactant species\n", "\n", " math_ast9: libsbml.ASTNode = libsbml.parseL3FormulaWithModel(\"kd_mRNA * Z\", model)\n", " kinetic_law = r3.createKineticLaw()\n", " kinetic_law.setSBOTerm(\"SBO:0000049\")\n", " kinetic_law.setMath(math_ast9)\n", "\n", " r4 = model.createReaction()\n", " r4.setId(\"Reaction4\"), # set reaction id\n", " r4.setMetaId(\"meta_Reaction4\")\n", " r4.setSBOTerm(\"SBO:0000184\")\n", " r4.setName(\"translation of LacI\")\n", " r4.setReversible(False)\n", " # set annotation\n", " r4_cv: libsbml.CVTerm = libsbml.CVTerm()\n", " r4_cv.setQualifierType(libsbml.BIOLOGICAL_QUALIFIER)\n", " r4_cv.setBiologicalQualifierType(libsbml.BQB_IS_VERSION_OF)\n", " r4_cv.addResource(\"http://identifiers.org/GO:0006412\")\n", " r4.addCVTerm(r4_cv)\n", "\n", " species_ref4 = r4.createProduct()\n", " species_ref4.setSpecies(\"PX\") # assign product species\n", "\n", " species_ref_4 = r4.createModifier()\n", " species_ref_4.setSpecies(\"X\")\n", " species_ref_4.setSBOTerm(\"SBO:0000461\")\n", "\n", " math_ast10: libsbml.ASTNode = libsbml.parseL3FormulaWithModel(\"k_tl * X\", model)\n", " kinetic_law = r4.createKineticLaw()\n", " kinetic_law.setSBOTerm(\"SBO:0000049\")\n", " kinetic_law.setMath(math_ast10)\n", "\n", " r5 = model.createReaction()\n", " r5.setId(\"Reaction5\"), # set reaction id\n", " r5.setMetaId(\"meta_Reaction5\")\n", " r5.setSBOTerm(\"SBO:0000184\")\n", " r5.setName(\"translation of TetR\")\n", " r5.setReversible(False)\n", " s3_cv = libsbml.CVTerm()\n", " # set annotation\n", " r5_cv: libsbml.CVTerm = libsbml.CVTerm()\n", " r5_cv.setQualifierType(libsbml.BIOLOGICAL_QUALIFIER)\n", " r5_cv.setBiologicalQualifierType(libsbml.BQB_IS_VERSION_OF)\n", " r5_cv.addResource(\"http://identifiers.org/GO:0006412\")\n", " r5.addCVTerm(r5_cv)\n", "\n", " species_ref5 = r5.createProduct()\n", " species_ref5.setSpecies(\"PY\") # assign product species\n", " species_ref_5 = r5.createModifier()\n", " species_ref_5.setSpecies(\"Y\")\n", " species_ref_5.setSBOTerm(\"SBO:0000461\")\n", "\n", " math_ast11: libsbml.ASTNode = libsbml.parseL3FormulaWithModel(\"k_tl * Y\", model)\n", " kinetic_law = r5.createKineticLaw()\n", " kinetic_law.setSBOTerm(\"SBO:0000049\")\n", " kinetic_law.setMath(math_ast11)\n", "\n", " r6 = model.createReaction()\n", " r6.setId(\"Reaction6\"), # set reaction id\n", " r6.setMetaId(\"meta_Reaction6\")\n", " r6.setSBOTerm(\"SBO:0000184\")\n", " r6.setName(\"translation of CI\")\n", " r6.setReversible(False)\n", " # set annotation\n", " r6_cv: libsbml.CVTerm = libsbml.CVTerm()\n", " r6_cv.setQualifierType(libsbml.BIOLOGICAL_QUALIFIER)\n", " r6_cv.setBiologicalQualifierType(libsbml.BQB_IS_VERSION_OF)\n", " r6_cv.addResource(\"http://identifiers.org/GO:0006412\")\n", " r6.addCVTerm(r6_cv)\n", "\n", " species_ref6 = r6.createProduct()\n", " species_ref6.setSpecies(\"PZ\") # assign product species\n", " species_ref_6 = r6.createModifier()\n", " species_ref_6.setSpecies(\"Z\")\n", " species_ref_6.setSBOTerm(\"SBO:0000461\")\n", "\n", " math_ast12: libsbml.ASTNode = libsbml.parseL3FormulaWithModel(\"k_tl * Z\", model)\n", " kinetic_law = r6.createKineticLaw()\n", " kinetic_law.setSBOTerm(\"SBO:0000049\")\n", " kinetic_law.setMath(math_ast12)\n", "\n", " r7 = model.createReaction()\n", " r7.setId(\"Reaction7\"), # set reaction id\n", " r7.setMetaId(\"meta_Reaction7\")\n", " r7.setSBOTerm(\"SBO:0000179\")\n", " r7.setName(\"degradation of LacI\")\n", " r7.setReversible(False)\n", " # set annotation\n", " r7_cv: libsbml.CVTerm = libsbml.CVTerm()\n", " r7_cv.setQualifierType(libsbml.BIOLOGICAL_QUALIFIER)\n", " r7_cv.setBiologicalQualifierType(libsbml.BQB_IS_VERSION_OF)\n", " r7_cv.addResource(\"http://identifiers.org/GO:0030163\")\n", " r7.addCVTerm(r7_cv)\n", "\n", " species_ref7 = r7.createReactant()\n", " species_ref7.setSpecies(\"PX\") # assign reactant species\n", "\n", " math_ast13: libsbml.ASTNode = libsbml.parseL3FormulaWithModel(\"kd_prot * PX\", model)\n", " kinetic_law = r7.createKineticLaw()\n", " kinetic_law.setSBOTerm(\"SBO:0000049\")\n", " kinetic_law.setMath(math_ast13)\n", "\n", " r8 = model.createReaction()\n", " r8.setId(\"Reaction8\"), # set reaction id\n", " r8.setMetaId(\"meta_Reaction8\")\n", " r8.setSBOTerm(\"SBO:0000179\")\n", " r8.setName(\"degradation of TetR\")\n", " r8.setReversible(False)\n", " # set annotation\n", " r8_cv: libsbml.CVTerm = libsbml.CVTerm()\n", " r8_cv.setQualifierType(libsbml.BIOLOGICAL_QUALIFIER)\n", " r8_cv.setBiologicalQualifierType(libsbml.BQB_IS_VERSION_OF)\n", " r8_cv.addResource(\"http://identifiers.org/GO:0030163\")\n", " r8.addCVTerm(r8_cv)\n", "\n", " species_ref8 = r8.createReactant()\n", " species_ref8.setSpecies(\"PY\") # assign reactant species\n", "\n", " math_ast14: libsbml.ASTNode = libsbml.parseL3FormulaWithModel(\"kd_prot * PY\", model)\n", " kinetic_law = r8.createKineticLaw()\n", " kinetic_law.setSBOTerm(\"SBO:0000049\")\n", " kinetic_law.setMath(math_ast14)\n", "\n", " r9 = model.createReaction()\n", " r9.setId(\"Reaction9\"), # set reaction id\n", " r9.setMetaId(\"meta_Reaction9\")\n", " r9.setSBOTerm(\"SBO:0000179\")\n", " r9.setName(\"degradation of CI\")\n", " r9.setReversible(False)\n", " # set annotation\n", " r9_cv: libsbml.CVTerm = libsbml.CVTerm()\n", " r9_cv.setQualifierType(libsbml.BIOLOGICAL_QUALIFIER)\n", " r9_cv.setBiologicalQualifierType(libsbml.BQB_IS_VERSION_OF)\n", " r9_cv.addResource(\"http://identifiers.org/GO:0030163\")\n", " r9.addCVTerm(r9_cv)\n", "\n", " species_ref9 = r9.createReactant()\n", " species_ref9.setSpecies(\"PZ\") # assign reactant species\n", "\n", " math_ast15: libsbml.ASTNode = libsbml.parseL3FormulaWithModel(\"kd_prot * PZ\", model)\n", " kinetic_law = r9.createKineticLaw()\n", " kinetic_law.setSBOTerm(\"SBO:0000049\")\n", " kinetic_law.setMath(math_ast15)\n", "\n", " r10 = model.createReaction()\n", " r10.setId(\"Reaction10\"), # set reaction id\n", " r10.setMetaId(\"meta_Reaction10\")\n", " r10.setSBOTerm(\"SBO:0000183\")\n", " r10.setName(\"transcription of LacI\")\n", " r10.setReversible(False)\n", " # set annotation\n", " r10_cv: libsbml.CVTerm = libsbml.CVTerm()\n", " r10_cv.setQualifierType(libsbml.BIOLOGICAL_QUALIFIER)\n", " r10_cv.setBiologicalQualifierType(libsbml.BQB_IS_VERSION_OF)\n", " r10_cv.addResource(\"http://identifiers.org/GO:0006351\")\n", " r10.addCVTerm(r10_cv)\n", "\n", " species_ref10 = r10.createProduct()\n", " species_ref10.setSpecies(\"X\") # assign product species\n", " species_ref_10 = r10.createModifier()\n", " species_ref_10.setSpecies(\"PZ\")\n", " species_ref_10.setSBOTerm(\"SBO:0000536\")\n", "\n", " math_ast16: libsbml.ASTNode = libsbml.parseL3FormulaWithModel(\n", " \"a0_tr + (a_tr * power(KM, n)) / (power(KM, n) + power(PZ, n))\", model\n", " )\n", " kinetic_law = r10.createKineticLaw()\n", " kinetic_law.setMath(math_ast16)\n", "\n", " r11 = model.createReaction()\n", " r11.setId(\"Reaction11\"), # set reaction id\n", " r11.setMetaId(\"meta_Reaction11\")\n", " r11.setSBOTerm(\"SBO:0000183\")\n", " r11.setName(\"transcription of TetR\")\n", " r11.setReversible(False)\n", " # set annotation\n", " r11_cv: libsbml.CVTerm = libsbml.CVTerm()\n", " r11_cv.setQualifierType(libsbml.BIOLOGICAL_QUALIFIER)\n", " r11_cv.setBiologicalQualifierType(libsbml.BQB_IS_VERSION_OF)\n", " r11_cv.addResource(\"http://identifiers.org/GO:0006351\")\n", " r11.addCVTerm(r11_cv)\n", "\n", " species_ref11 = r11.createProduct()\n", " species_ref11.setSpecies(\"Y\") # assign product species\n", " species_ref_11 = r11.createModifier()\n", " species_ref_11.setSpecies(\"PX\")\n", " species_ref_11.setSBOTerm(\"SBO:0000536\")\n", "\n", " math_ast17: libsbml.ASTNode = libsbml.parseL3FormulaWithModel(\n", " \"a0_tr + (a_tr * power(KM, n)) / (power(KM, n) + power(PX, n))\", model\n", " )\n", " kinetic_law = r11.createKineticLaw()\n", " kinetic_law.setMath(math_ast17)\n", "\n", " r12 = model.createReaction()\n", " r12.setId(\"Reaction12\"), # set reaction id\n", " r12.setMetaId(\"meta_Reaction12\")\n", " r12.setSBOTerm(\"SBO:0000183\")\n", " r12.setName(\"transcription of CI\")\n", " r12.setReversible(False)\n", " # set annotation\n", " r12_cv: libsbml.CVTerm = libsbml.CVTerm()\n", " r12_cv.setQualifierType(libsbml.BIOLOGICAL_QUALIFIER)\n", " r12_cv.setBiologicalQualifierType(libsbml.BQB_IS_VERSION_OF)\n", " r12_cv.addResource(\"http://identifiers.org/GO:0006351\")\n", " r12.addCVTerm(r12_cv)\n", "\n", " species_ref12 = r12.createProduct()\n", " species_ref12.setSpecies(\"Z\") # assign product species\n", " species_ref_12 = r12.createModifier()\n", " species_ref_12.setSpecies(\"PY\")\n", " species_ref_12.setSBOTerm(\"SBO:0000536\")\n", "\n", " math_ast18: libsbml.ASTNode = libsbml.parseL3FormulaWithModel(\n", " \"a0_tr + (a_tr * power(KM, n)) / (power(KM, n) + power(PY, n))\", model\n", " )\n", " kinetic_law = r12.createKineticLaw()\n", " kinetic_law.setMath(math_ast18)\n", "\n", " print(\"-\" * 80)\n", " print(libsbml.writeSBMLToString(doc))\n", " print(\"-\" * 80)\n", "\n", " # write to file\n", " libsbml.writeSBMLToFile(doc, str(sbml_path))\n", "\n", " # validate file\n", " validate_sbml(doc, units_consistency=False)\n", "\n", " return doc" ] }, { "cell_type": "code", "execution_count": 3, "id": "0a18aa9a", "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Create SBML model\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", " \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", " \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", " \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", " 2 \n", " \n", " tau_mRNA \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " tau_mRNA \n", " \n", " \n", " 2 \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " eff \n", " t_ave \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 2 \n", " \n", " tau_prot \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " ps_0 \n", " 60 \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " ps_a \n", " ps_0 \n", " \n", " 60 \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", " kd_mRNA \n", " X \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " kd_mRNA \n", " Y \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " kd_mRNA \n", " Z \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", " k_tl \n", " X \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", " k_tl \n", " Y \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", " k_tl \n", " Z \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " kd_prot \n", " PX \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " kd_prot \n", " PY \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " kd_prot \n", " PZ \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", " a0_tr \n", " \n", " \n", " \n", " \n", " a_tr \n", " \n", " \n", " KM \n", " n \n", " \n", " \n", " \n", " \n", " \n", " \n", " KM \n", " n \n", " \n", " \n", " \n", " PZ \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", " a0_tr \n", " \n", " \n", " \n", " \n", " a_tr \n", " \n", " \n", " KM \n", " n \n", " \n", " \n", " \n", " \n", " \n", " \n", " KM \n", " n \n", " \n", " \n", " \n", " PX \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", " a0_tr \n", " \n", " \n", " \n", " \n", " a_tr \n", " \n", " \n", " KM \n", " n \n", " \n", " \n", " \n", " \n", " \n", " \n", " KM \n", " n \n", " \n", " \n", " \n", " PY \n", " n \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", "--------------------------------------------------------------------------------\n", "--------------------------------------------------------------------------------\n", "validation error(s) : 0\n", "validation warning(s) : 0\n", "--------------------------------------------------------------------------------\n" ] } ], "source": [ "if __name__ == \"__main__\":\n", " from combine_notebooks import RESULTS_DIR\n", "\n", " # RESOURCES_DIR: Path = Path(__file__).parent / \"resources\"\n", " # RESULTS_DIR: Path = RESOURCES_DIR / \"results\"\n", " doc: libsbml.SBMLDocument = create_repressilator(\n", " sbml_path=RESULTS_DIR / \"repressilator_libsbml.xml\"\n", " )\n", "\n", " # \n", " " ] } ], "metadata": { "kernelspec": { "display_name": "combine_notebooks", "language": "python", "name": "combine_notebooks" }, "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.10.6" } }, "nbformat": 4, "nbformat_minor": 5 }