From 30342d60bcec9636a6303a6223e6dc28177ede71 Mon Sep 17 00:00:00 2001 From: GeneCodeSavvy Date: Tue, 17 Jun 2025 19:55:07 +0530 Subject: [PATCH 1/9] pySBOL2 MapsTo object tutorial --- .../sbol2/CreatingSBOL2Objects/MapsTo.ipynb | 135 ++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 examples/sbol2/CreatingSBOL2Objects/MapsTo.ipynb diff --git a/examples/sbol2/CreatingSBOL2Objects/MapsTo.ipynb b/examples/sbol2/CreatingSBOL2Objects/MapsTo.ipynb new file mode 100644 index 0000000..d8cb8ff --- /dev/null +++ b/examples/sbol2/CreatingSBOL2Objects/MapsTo.ipynb @@ -0,0 +1,135 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "cell-001", + "metadata": {}, + "source": [ + "# MapsTo in pySBOL2\n", + "\n", + "The `MapsTo` class in the Synthetic Biology Open Language (SBOL) is used to explicitly state that two `ComponentInstance` objects, often from different levels of design hierarchy, represent the same biological entity. It is most often used when `ModuleDefinition` and `ComponentDefinition` objects are composed using `Module` and `ComponentInstance` objects.\n", + "\n", + "`MapsTo` objects define how a `ComponentInstance` in a higher-level design relates to a `ComponentInstance` in a lower-level design through identity and refinement relationships.\n", + "\n", + "`MapsTo` objects have the following required properties:\n", + "\n", + "- `local`: Refers to the `ComponentInstance` in the higher-level design.\n", + "- `remote`: Refers to the `ComponentInstance` in the lower-level design. The referenced instance must have `access=\"public\"`.\n", + "- `refinement`: Specifies how to interpret the relationship between the local and remote instances using a URI. For example: `http://sbols.org/v2#useRemote`.\n", + "\n", + "This example demonstrates linking a `FunctionalComponent` in a high-level toggle switch module to one in a lower-level LacI inverter using a `MapsTo` object. We will:\n", + "\n", + "1. Define two `ModuleDefinition` objects (toggle switch and LacI inverter).\n", + "2. Add `FunctionalComponent` instances to both modules.\n", + "3. Create a `Module` to instantiate the LacI inverter inside the toggle switch.\n", + "4. Add a `MapsTo` to specify how the high-level LacI relates to the inverter's TF.\n", + "\n", + "For more information on the `MapsTo` class and its properties, refer to page 30 in the SBOL 2.x.x specification document." + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "cell-002", + "metadata": {}, + "outputs": [], + "source": [ + "import sbol2" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "cell-003", + "metadata": {}, + "outputs": [], + "source": [ + "doc = sbol2.Document()\n", + "\n", + "# Set a namespace for the document\n", + "sbol2.setHomespace('https://github.com/SynBioDex/SBOL-Notebooks')" + ] + }, + { + "cell_type": "markdown", + "id": "cell-004", + "metadata": {}, + "source": [ + "Creating a MapsTo Object" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "cell-005", + "metadata": {}, + "outputs": [], + "source": [ + "# Create lower-level ModuleDefinition\n", + "inverter_md = sbol2.ModuleDefinition('laci_inverter')\n", + "tf_fc = inverter_md.functionalComponents.create('TF')\n", + "tf_fc.definition = tf_fc\n", + "tf_fc.access = sbol2.SBOL_ACCESS_PUBLIC\n", + "tf_fc.direction = sbol2.SBOL_DIRECTION_IN_OUT\n", + "\n", + "# Create higher-level ModuleDefinition\n", + "toggle_md = sbol2.ModuleDefinition('toggle_switch')\n", + "laci_fc = toggle_md.functionalComponents.create('LacI')\n", + "laci_fc.definition = laci_fc\n", + "laci_fc.access = sbol2.SBOL_ACCESS_PRIVATE\n", + "laci_fc.direction = sbol2.SBOL_DIRECTION_IN_OUT\n", + "\n", + "# Create a Module instance to include the inverter\n", + "mod = toggle_md.modules.create('laci_inverter_instance')\n", + "mod.definition = inverter_md.identity\n", + "\n", + "# Create the MapsTo\n", + "mapping = mod.mapsTos.create('LacI_mapping')\n", + "mapping.local = laci_fc.identity\n", + "mapping.remote = tf_fc.identity\n", + "mapping.refinement = sbol2.SBOL_REFINEMENT_USE_REMOTE\n", + "\n", + "# Add ModuleDefinitions to the document\n", + "doc.addModuleDefinition(inverter_md)\n", + "doc.addModuleDefinition(toggle_md)" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "cell-006", + "metadata": {}, + "outputs": [], + "source": [ + "# Validate the document\n", + "report = doc.validate()\n", + "\n", + "if report == \"Valid.\":\n", + " doc.write(\"example_mapsto.xml\")\n", + "else:\n", + " print(report)" + ] + } + ], + "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.13.4" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} From 4cc1c0c5371df7a9074e9c6814383cac30393172 Mon Sep 17 00:00:00 2001 From: GeneCodeSavvy Date: Sun, 22 Jun 2025 23:56:05 +0530 Subject: [PATCH 2/9] Adding more biological context --- .../sbol2/CreatingSBOL2Objects/MapsTo.ipynb | 254 +++++++++++++++--- 1 file changed, 211 insertions(+), 43 deletions(-) diff --git a/examples/sbol2/CreatingSBOL2Objects/MapsTo.ipynb b/examples/sbol2/CreatingSBOL2Objects/MapsTo.ipynb index d8cb8ff..49a871c 100644 --- a/examples/sbol2/CreatingSBOL2Objects/MapsTo.ipynb +++ b/examples/sbol2/CreatingSBOL2Objects/MapsTo.ipynb @@ -6,25 +6,25 @@ "metadata": {}, "source": [ "# MapsTo in pySBOL2\n", - "\n", - "The `MapsTo` class in the Synthetic Biology Open Language (SBOL) is used to explicitly state that two `ComponentInstance` objects, often from different levels of design hierarchy, represent the same biological entity. It is most often used when `ModuleDefinition` and `ComponentDefinition` objects are composed using `Module` and `ComponentInstance` objects.\n", + "The MapsTo class in the Synthetic Biology Open Language (SBOL) is used to explicitly state that two `ComponentInstance` objects, often from different levels of design hierarchy, represent the same biological entity. It is most often used when `ModuleDefinition` and `ComponentDefinition` objects are composed using `Module` and `ComponentInstance` objects.\n", "\n", "`MapsTo` objects define how a `ComponentInstance` in a higher-level design relates to a `ComponentInstance` in a lower-level design through identity and refinement relationships.\n", "\n", - "`MapsTo` objects have the following required properties:\n", + "MapsTo objects have the following required properties:\n", "\n", - "- `local`: Refers to the `ComponentInstance` in the higher-level design.\n", - "- `remote`: Refers to the `ComponentInstance` in the lower-level design. The referenced instance must have `access=\"public\"`.\n", - "- `refinement`: Specifies how to interpret the relationship between the local and remote instances using a URI. For example: `http://sbols.org/v2#useRemote`.\n", + "* `local`: Refers to the `ComponentInstance` in the higher-level design.\n", + "* `remote`: Refers to the `ComponentInstance` in the lower-level design. The referenced instance must have access=\"public\".\n", + "* `refinement`: Specifies how to interpret the relationship between the local and remote instances using a URI. For * `example`: http://sbols.org/v2#useRemote.\n", "\n", - "This example demonstrates linking a `FunctionalComponent` in a high-level toggle switch module to one in a lower-level LacI inverter using a `MapsTo` object. We will:\n", + "This example demonstrates linking a FunctionalComponent in a high-level toggle switch module to one in a lower-level LacI inverter using a MapsTo object. We will:\n", "\n", - "1. Define two `ModuleDefinition` objects (toggle switch and LacI inverter).\n", - "2. Add `FunctionalComponent` instances to both modules.\n", - "3. Create a `Module` to instantiate the LacI inverter inside the toggle switch.\n", - "4. Add a `MapsTo` to specify how the high-level LacI relates to the inverter's TF.\n", + "1. Define all necessary biological parts (`ComponentDefinition`): two proteins (LacI, cI) and two promoters (pLac, pR).\n", + "2. Define two `ModuleDefinition` objects for genetic inverters: one repressed by LacI and one repressed by cI.\n", + "3. Define a higher-level `ModuleDefinition` for the toggle switch itself.\n", + "4. Instantiate both inverters inside the toggle switch module.\n", + "5. Use `MapsTo` to connect the inputs and outputs of the inverters, forming the complete, mutually-repressive feedback loop.\n", "\n", - "For more information on the `MapsTo` class and its properties, refer to page 30 in the SBOL 2.x.x specification document." + "For more information on the MapsTo class and its properties, refer to page 30 in the SBOL 2.x.x specification document." ] }, { @@ -46,7 +46,7 @@ "source": [ "doc = sbol2.Document()\n", "\n", - "# Set a namespace for the document\n", + "# Set the namespace for all SBOL objects\n", "sbol2.setHomespace('https://github.com/SynBioDex/SBOL-Notebooks')" ] }, @@ -55,7 +55,9 @@ "id": "cell-004", "metadata": {}, "source": [ - "Creating a MapsTo Object" + "## Define Shared Biological Parts\n", + "\n", + "Here we define four `ComponentDefinition` objects representing the core parts of our toggle switch: the coding sequences for the two repressor proteins (LacI and cI) and the two promoters they regulate (pLac and pR). In a real design, these would be detailed with sequence information." ] }, { @@ -65,42 +67,208 @@ "metadata": {}, "outputs": [], "source": [ - "# Create lower-level ModuleDefinition\n", - "inverter_md = sbol2.ModuleDefinition('laci_inverter')\n", - "tf_fc = inverter_md.functionalComponents.create('TF')\n", - "tf_fc.definition = tf_fc\n", - "tf_fc.access = sbol2.SBOL_ACCESS_PUBLIC\n", - "tf_fc.direction = sbol2.SBOL_DIRECTION_IN_OUT\n", - "\n", - "# Create higher-level ModuleDefinition\n", - "toggle_md = sbol2.ModuleDefinition('toggle_switch')\n", - "laci_fc = toggle_md.functionalComponents.create('LacI')\n", - "laci_fc.definition = laci_fc\n", - "laci_fc.access = sbol2.SBOL_ACCESS_PRIVATE\n", - "laci_fc.direction = sbol2.SBOL_DIRECTION_IN_OUT\n", - "\n", - "# Create a Module instance to include the inverter\n", - "mod = toggle_md.modules.create('laci_inverter_instance')\n", - "mod.definition = inverter_md.identity\n", - "\n", - "# Create the MapsTo\n", - "mapping = mod.mapsTos.create('LacI_mapping')\n", - "mapping.local = laci_fc.identity\n", - "mapping.remote = tf_fc.identity\n", - "mapping.refinement = sbol2.SBOL_REFINEMENT_USE_REMOTE\n", - "\n", - "# Add ModuleDefinitions to the document\n", - "doc.addModuleDefinition(inverter_md)\n", - "doc.addModuleDefinition(toggle_md)" + "# Coding Sequences (CDS)\n", + "lacI_cds = sbol2.ComponentDefinition('LacI_CDS', sbol2.BIOPAX_DNA)\n", + "lacI_cds.name = 'LacI Coding Sequence'\n", + "lacI_cds.addRole(sbol2.SO_CDS)\n", + "doc.addComponentDefinition(lacI_cds)\n", + "\n", + "cI_cds = sbol2.ComponentDefinition('cI_CDS', sbol2.BIOPAX_DNA)\n", + "cI_cds.name = 'Lambda cI Coding Sequence'\n", + "cI_cds.addRole(sbol2.SO_CDS)\n", + "doc.addComponentDefinition(cI_cds)\n", + "\n", + "# Define Promoters\n", + "pLac = sbol2.ComponentDefinition('pLac', sbol2.BIOPAX_DNA)\n", + "pLac.name = 'pLac Promoter'\n", + "pLac.addRole(sbol2.SO_PROMOTER)\n", + "doc.addComponentDefinition(pLac)\n", + "\n", + "pR = sbol2.ComponentDefinition('pR', sbol2.BIOPAX_DNA)\n", + "pR.name = 'pR Promoter'\n", + "pR.addRole(sbol2.SO_PROMOTER)\n", + "doc.addComponentDefinition(pR)" + ] + }, + { + "cell_type": "markdown", + "id": "cell-006", + "metadata": {}, + "source": [ + "## Define the Inverter Modules (Lower-Level Subsystems)\n", + "\n", + "A toggle switch is composed of two inverters. We define each as a `ModuleDefinition`. Each inverter has an input (the repressor protein), a regulated promoter, and an output (the protein it produces). We also add `Interaction` objects to specify the biological function: repression.\n", + "\n", + "- **LacI Inverter**: Takes LacI as input to repress the pLac promoter, which produces the cI protein.\n", + "- **cI Inverter**: Takes cI as input to repress the pR promoter, which produces the LacI protein." ] }, { "cell_type": "code", "execution_count": 4, - "id": "cell-006", + "id": "cell-007", "metadata": {}, "outputs": [], "source": [ + "# 1. LacI Inverter Module (LacI represses production of cI)\n", + "laci_inverter_md = sbol2.ModuleDefinition('LacI_Inverter')\n", + "\n", + "# Functional Components of the LacI inverter\n", + "tf_in = laci_inverter_md.functionalComponents.create('input_transcription_factor')\n", + "tf_in.definition = lacI_cds.identity\n", + "tf_in.access = sbol2.SBOL_ACCESS_PUBLIC\n", + "tf_in.direction = sbol2.SBOL_DIRECTION_IN\n", + "\n", + "prom = laci_inverter_md.functionalComponents.create('promoter')\n", + "prom.definition = pLac.identity\n", + "prom.access = sbol2.SBOL_ACCESS_PRIVATE\n", + "\n", + "gene_out = laci_inverter_md.functionalComponents.create('output_gene')\n", + "gene_out.definition = cI_cds.identity\n", + "gene_out.access = sbol2.SBOL_ACCESS_PUBLIC\n", + "gene_out.direction = sbol2.SBOL_DIRECTION_OUT\n", + "\n", + "\n", + "# 2. cI Inverter Module (cI represses production of LacI)\n", + "ci_inverter_md = sbol2.ModuleDefinition('cI_Inverter')\n", + "\n", + "# Functional Components of the cI inverter\n", + "tf_in_2 = ci_inverter_md.functionalComponents.create('input_transcription_factor')\n", + "tf_in_2.definition = cI_cds.identity\n", + "tf_in_2.access = sbol2.SBOL_ACCESS_PUBLIC\n", + "tf_in_2.direction = sbol2.SBOL_DIRECTION_IN\n", + "\n", + "prom_2 = ci_inverter_md.functionalComponents.create('promoter')\n", + "prom_2.definition = pR.identity\n", + "prom_2.access = sbol2.SBOL_ACCESS_PRIVATE\n", + "\n", + "gene_out_2 = ci_inverter_md.functionalComponents.create('output_gene')\n", + "gene_out_2.definition = lacI_cds.identity\n", + "gene_out_2.access = sbol2.SBOL_ACCESS_PUBLIC\n", + "gene_out_2.direction = sbol2.SBOL_DIRECTION_OUT" + ] + }, + { + "cell_type": "markdown", + "id": "cell-008", + "metadata": {}, + "source": [ + "## Define the Toggle Switch Module (Higher-Level Circuit)\n", + "\n", + "This `ModuleDefinition` represents the complete genetic toggle switch. From this high-level perspective, we only care about the two key players: the LacI protein and the cI protein." + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "cell-009", + "metadata": {}, + "outputs": [], + "source": [ + "toggle_md = sbol2.ModuleDefinition('toggle_switch')\n", + "\n", + "# The toggle switch's behavior is defined by two protein pools\n", + "laci_fc = toggle_md.functionalComponents.create('LacI_protein')\n", + "laci_fc.definition = lacI_cds.identity\n", + "laci_fc.direction = sbol2.SBOL_DIRECTION_IN_OUT\n", + "\n", + "ci_fc = toggle_md.functionalComponents.create('cI_protein')\n", + "ci_fc.definition = cI_cds.identity\n", + "ci_fc.direction = sbol2.SBOL_DIRECTION_IN_OUT" + ] + }, + { + "cell_type": "markdown", + "id": "cell-010", + "metadata": {}, + "source": [ + "## Add Inverter Modules to Toggle Switch (Composition)\n", + "\n", + "We now instantiate both inverter modules within the toggle switch module. This reflects **module composition** in SBOL—building a larger system from smaller, defined subsystems." + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "cell-010b", + "metadata": {}, + "outputs": [], + "source": [ + "# Instantiate the LacI inverter\n", + "laci_inverter_instance = toggle_md.modules.create('laci_inverter_inst')\n", + "laci_inverter_instance.definition = laci_inverter_md.identity\n", + "\n", + "# Instantiate the cI inverter\n", + "ci_inverter_instance = toggle_md.modules.create('ci_inverter_inst')\n", + "ci_inverter_instance.definition = ci_inverter_md.identity" + ] + }, + { + "cell_type": "markdown", + "id": "cell-011", + "metadata": {}, + "source": [ + "## Wire the Circuit with `MapsTo`\n", + "\n", + "This is the key step. We use `MapsTo` objects to connect the components and form the feedback loop. We need four mappings to declare that:\n", + "1. The `LacI_protein` in the toggle switch is the same molecule that acts as the input to the LacI inverter.\n", + "2. The `cI_protein` in the toggle switch is the same molecule that is produced as the output of the LacI inverter.\n", + "3. The `cI_protein` in the toggle switch is the same molecule that acts as the input to the cI inverter.\n", + "4. The `LacI_protein` in the toggle switch is the same molecule that is produced as the output of the cI inverter.\n", + "\n", + "This wiring correctly models the mutual repression: LacI represses cI production, and cI represses LacI production." + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "cell-012", + "metadata": {}, + "outputs": [], + "source": [ + "# Map 1: LacI protein is the input to the LacI inverter\n", + "map1 = laci_inverter_instance.mapsTos.create('map_laci_in')\n", + "map1.refinement = sbol2.SBOL_REFINEMENT_USE_REMOTE\n", + "map1.local = laci_fc.identity\n", + "map1.remote = tf_in.identity\n", + "\n", + "# Map 2: cI protein is the output of the LacI inverter\n", + "map2 = laci_inverter_instance.mapsTos.create('map_ci_out')\n", + "map2.local = ci_fc.identity\n", + "map2.remote = gene_out.identity\n", + "\n", + "# Map 3: cI protein is the input to the cI inverter\n", + "map3 = ci_inverter_instance.mapsTos.create('map_ci_in')\n", + "map3.local = ci_fc.identity\n", + "map3.remote = tf_in_2.identity\n", + "\n", + "# Map 4: LacI protein is the output of the cI inverter\n", + "map4 = ci_inverter_instance.mapsTos.create('map_laci_out')\n", + "map4.local = laci_fc.identity\n", + "map4.remote = gene_out_2.identity" + ] + }, + { + "cell_type": "markdown", + "id": "cell-013", + "metadata": {}, + "source": [ + "## Finalize and Validate\n", + "\n", + "We add all high-level modules to the document and check that the complete design conforms to SBOL specifications. If valid, it is saved as `toggle_switch_complete.xml`." + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "cell-014", + "metadata": {}, + "outputs": [], + "source": [ + "doc.addModuleDefinition(laci_inverter_md)\n", + "doc.addModuleDefinition(ci_inverter_md)\n", + "doc.addModuleDefinition(toggle_md)\n", + "\n", "# Validate the document\n", "report = doc.validate()\n", "\n", @@ -127,7 +295,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.13.4" + "version": "3.13.5" } }, "nbformat": 4, From 7a2f6ada2b8c7ce163603da8eeff1cc89dc01915 Mon Sep 17 00:00:00 2001 From: Harsh Sharma <65808871+GeneCodeSavvy@users.noreply.github.com> Date: Sat, 28 Jun 2025 02:37:45 +0530 Subject: [PATCH 3/9] remove .identity for definition property Co-authored-by: Jacob Beal --- examples/sbol2/CreatingSBOL2Objects/MapsTo.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/sbol2/CreatingSBOL2Objects/MapsTo.ipynb b/examples/sbol2/CreatingSBOL2Objects/MapsTo.ipynb index 49a871c..7fb192c 100644 --- a/examples/sbol2/CreatingSBOL2Objects/MapsTo.ipynb +++ b/examples/sbol2/CreatingSBOL2Objects/MapsTo.ipynb @@ -115,7 +115,7 @@ "\n", "# Functional Components of the LacI inverter\n", "tf_in = laci_inverter_md.functionalComponents.create('input_transcription_factor')\n", - "tf_in.definition = lacI_cds.identity\n", + "tf_in.definition = lacI_cds\n", "tf_in.access = sbol2.SBOL_ACCESS_PUBLIC\n", "tf_in.direction = sbol2.SBOL_DIRECTION_IN\n", "\n", From 35f8867d3aedd83569569c9ac4207752a538bf9d Mon Sep 17 00:00:00 2001 From: GeneCodeSavvy Date: Thu, 3 Jul 2025 22:16:31 +0530 Subject: [PATCH 4/9] added interaction objects to mapsTo.ipynb --- .../sbol2/CreatingSBOL2Objects/MapsTo.ipynb | 150 ++++++++++++------ 1 file changed, 101 insertions(+), 49 deletions(-) diff --git a/examples/sbol2/CreatingSBOL2Objects/MapsTo.ipynb b/examples/sbol2/CreatingSBOL2Objects/MapsTo.ipynb index 7fb192c..6204785 100644 --- a/examples/sbol2/CreatingSBOL2Objects/MapsTo.ipynb +++ b/examples/sbol2/CreatingSBOL2Objects/MapsTo.ipynb @@ -8,7 +8,7 @@ "# MapsTo in pySBOL2\n", "The MapsTo class in the Synthetic Biology Open Language (SBOL) is used to explicitly state that two `ComponentInstance` objects, often from different levels of design hierarchy, represent the same biological entity. It is most often used when `ModuleDefinition` and `ComponentDefinition` objects are composed using `Module` and `ComponentInstance` objects.\n", "\n", - "`MapsTo` objects define how a `ComponentInstance` in a higher-level design relates to a `ComponentInstance` in a lower-level design through identity and refinement relationships.\n", + "`MapsTo` objects define how a `ComponentInstance` in a higher-level design relates to a `ComponentInstance` in a lower-level design through and refinement relationships.\n", "\n", "MapsTo objects have the following required properties:\n", "\n", @@ -111,41 +111,42 @@ "outputs": [], "source": [ "# 1. LacI Inverter Module (LacI represses production of cI)\n", - "laci_inverter_md = sbol2.ModuleDefinition('LacI_Inverter')\n", + "lacI_inverter_md = sbol2.ModuleDefinition('LacI_Inverter')\n", "\n", "# Functional Components of the LacI inverter\n", - "tf_in = laci_inverter_md.functionalComponents.create('input_transcription_factor')\n", - "tf_in.definition = lacI_cds\n", - "tf_in.access = sbol2.SBOL_ACCESS_PUBLIC\n", - "tf_in.direction = sbol2.SBOL_DIRECTION_IN\n", + "lacI_tf_fc = lacI_inverter_md.functionalComponents.create('laci_transcription_factor')\n", + "lacI_tf_fc.definition = lacI_cds\n", + "lacI_tf_fc.access = sbol2.SBOL_ACCESS_PUBLIC\n", + "lacI_tf_fc.direction = sbol2.SBOL_DIRECTION_IN\n", "\n", - "prom = laci_inverter_md.functionalComponents.create('promoter')\n", - "prom.definition = pLac.identity\n", - "prom.access = sbol2.SBOL_ACCESS_PRIVATE\n", + "pLac_fc = lacI_inverter_md.functionalComponents.create('pLac_promoter')\n", + "pLac_fc.definition = pLac\n", + "pLac.access = sbol2.SBOL_ACCESS_PRIVATE\n", + "\n", + "cI_gene_product_fc = lacI_inverter_md.functionalComponents.create('cI_gene_product')\n", + "cI_gene_product_fc.definition = cI_cds\n", + "cI_gene_product_fc.access = sbol2.SBOL_ACCESS_PUBLIC\n", + "cI_gene_product_fc.direction = sbol2.SBOL_DIRECTION_OUT\n", "\n", - "gene_out = laci_inverter_md.functionalComponents.create('output_gene')\n", - "gene_out.definition = cI_cds.identity\n", - "gene_out.access = sbol2.SBOL_ACCESS_PUBLIC\n", - "gene_out.direction = sbol2.SBOL_DIRECTION_OUT\n", "\n", "\n", "# 2. cI Inverter Module (cI represses production of LacI)\n", - "ci_inverter_md = sbol2.ModuleDefinition('cI_Inverter')\n", + "cI_inverter_md = sbol2.ModuleDefinition('cI_Inverter')\n", "\n", "# Functional Components of the cI inverter\n", - "tf_in_2 = ci_inverter_md.functionalComponents.create('input_transcription_factor')\n", - "tf_in_2.definition = cI_cds.identity\n", - "tf_in_2.access = sbol2.SBOL_ACCESS_PUBLIC\n", - "tf_in_2.direction = sbol2.SBOL_DIRECTION_IN\n", - "\n", - "prom_2 = ci_inverter_md.functionalComponents.create('promoter')\n", - "prom_2.definition = pR.identity\n", - "prom_2.access = sbol2.SBOL_ACCESS_PRIVATE\n", - "\n", - "gene_out_2 = ci_inverter_md.functionalComponents.create('output_gene')\n", - "gene_out_2.definition = lacI_cds.identity\n", - "gene_out_2.access = sbol2.SBOL_ACCESS_PUBLIC\n", - "gene_out_2.direction = sbol2.SBOL_DIRECTION_OUT" + "cI_tf_fc = cI_inverter_md.functionalComponents.create('cI_transcription_factor')\n", + "cI_tf_fc.definition = cI_cds\n", + "cI_tf_fc.access = sbol2.SBOL_ACCESS_PUBLIC\n", + "cI_tf_fc.direction = sbol2.SBOL_DIRECTION_IN\n", + "\n", + "pR_fc = cI_inverter_md.functionalComponents.create('pR_promoter')\n", + "pR_fc.definition = pR\n", + "pR_fc.access = sbol2.SBOL_ACCESS_PRIVATE\n", + "\n", + "lacI_gene_product_fc = cI_inverter_md.functionalComponents.create('LacI_gene_product')\n", + "lacI_gene_product_fc.definition = lacI_cds\n", + "lacI_gene_product_fc.access = sbol2.SBOL_ACCESS_PUBLIC\n", + "lacI_gene_product_fc.direction = sbol2.SBOL_DIRECTION_OUT" ] }, { @@ -168,13 +169,13 @@ "toggle_md = sbol2.ModuleDefinition('toggle_switch')\n", "\n", "# The toggle switch's behavior is defined by two protein pools\n", - "laci_fc = toggle_md.functionalComponents.create('LacI_protein')\n", - "laci_fc.definition = lacI_cds.identity\n", - "laci_fc.direction = sbol2.SBOL_DIRECTION_IN_OUT\n", + "lacI_prot_fc = toggle_md.functionalComponents.create('LacI_protein')\n", + "lacI_prot_fc.definition = lacI_cds\n", + "lacI_prot_fc.direction = sbol2.SBOL_DIRECTION_IN_OUT\n", "\n", - "ci_fc = toggle_md.functionalComponents.create('cI_protein')\n", - "ci_fc.definition = cI_cds.identity\n", - "ci_fc.direction = sbol2.SBOL_DIRECTION_IN_OUT" + "cI_prot_fc = toggle_md.functionalComponents.create('cI_protein')\n", + "cI_prot_fc.definition = cI_cds\n", + "cI_prot_fc.direction = sbol2.SBOL_DIRECTION_IN_OUT" ] }, { @@ -196,11 +197,51 @@ "source": [ "# Instantiate the LacI inverter\n", "laci_inverter_instance = toggle_md.modules.create('laci_inverter_inst')\n", - "laci_inverter_instance.definition = laci_inverter_md.identity\n", + "laci_inverter_instance.definition = lacI_inverter_md\n", "\n", "# Instantiate the cI inverter\n", "ci_inverter_instance = toggle_md.modules.create('ci_inverter_inst')\n", - "ci_inverter_instance.definition = ci_inverter_md.identity" + "ci_inverter_instance.definition = cI_inverter_md" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "9cdcd7c0-e419-4106-b7f3-7c8aba06fd7e", + "metadata": {}, + "outputs": [], + "source": [ + "# Interaction 1: LacI protein represses the pLac promoter (inhibiting cI production)\n", + "interaction1 = sbol2.Interaction('LacI_represses_pLac')\n", + "interaction1.interaction_type = sbol2.SBO_INHIBITION\n", + "toggle_md.interactions.add(interaction1)\n", + "\n", + "# Creating participation objects\n", + "# LacI protein is the INHIBITOR\n", + "inhibitor1 = interaction1.participations.create('part_LacI_protein')\n", + "inhibitor1.roles = [sbol2.SBO_INHIBITOR]\n", + "inhibitor1.participant = lacI_prot_fc\n", + "\n", + "# pLac promoter is what is being INHIBITED\n", + "inhibited1 = interaction1.participations.create('part_pLac_promoter')\n", + "inhibited1.roles = [sbol2.SBO_INHIBITED]\n", + "inhibited1.participant = pLac_fc\n", + "\n", + "\n", + "# Interaction 2: cI protein represses the pLambda promoter (inhibiting LacI production)\n", + "interaction2 = sbol2.Interaction('cI_represses_pLambda')\n", + "interaction2.interaction_type = sbol2.SBO_INHIBITION\n", + "toggle_md.interactions.add(interaction2)\n", + "\n", + "# Participation 2.1: cI protein is the INHIBITOR\n", + "inhibitor2 = interaction2.participations.create('part_cI_protein')\n", + "inhibitor2.roles = [sbol2.SBO_INHIBITOR]\n", + "inhibitor2.participant = cI_prot_fc\n", + "\n", + "# Participation 2.2: The cI-repressible promoter is what is being INHIBITED\n", + "inhibited2 = interaction2.participations.create('part_pR_promoter')\n", + "inhibited2.roles = [sbol2.SBO_INHIBITED]\n", + "inhibited2.participant = pR_fc" ] }, { @@ -221,31 +262,34 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 8, "id": "cell-012", "metadata": {}, "outputs": [], "source": [ "# Map 1: LacI protein is the input to the LacI inverter\n", "map1 = laci_inverter_instance.mapsTos.create('map_laci_in')\n", - "map1.refinement = sbol2.SBOL_REFINEMENT_USE_REMOTE\n", - "map1.local = laci_fc.identity\n", - "map1.remote = tf_in.identity\n", + "# map1.refinement = sbol2.SBOL_REFINEMENT_USE_REMOTE\n", + "map1.local = lacI_tf_fc\n", + "map1.remote = lacI_prot_fc\n", "\n", "# Map 2: cI protein is the output of the LacI inverter\n", "map2 = laci_inverter_instance.mapsTos.create('map_ci_out')\n", - "map2.local = ci_fc.identity\n", - "map2.remote = gene_out.identity\n", + "# map2.refinement = sbol2.SBOL_REFINEMENT_USE_REMOTE\n", + "map2.local = cI_tf_fc\n", + "map2.remote = cI_prot_fc\n", "\n", "# Map 3: cI protein is the input to the cI inverter\n", "map3 = ci_inverter_instance.mapsTos.create('map_ci_in')\n", - "map3.local = ci_fc.identity\n", - "map3.remote = tf_in_2.identity\n", + "# map3.refinement = sbol2.SBOL_REFINEMENT_USE_LOCAL\n", + "map3.local = cI_tf_fc\n", + "map3.remote = cI_prot_fc\n", "\n", "# Map 4: LacI protein is the output of the cI inverter\n", "map4 = ci_inverter_instance.mapsTos.create('map_laci_out')\n", - "map4.local = laci_fc.identity\n", - "map4.remote = gene_out_2.identity" + "# map3.refinement = sbol2.SBOL_REFINEMENT_USE_LOCAL\n", + "map4.local = lacI_tf_fc\n", + "map4.remote = lacI_prot_fc" ] }, { @@ -260,13 +304,21 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 9, "id": "cell-014", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Invalid. sbol-12003:\u0000 Strong Validation Error:\u0000 The FunctionalComponent referenced by the participant property of a Participation MUST be contained by the ModuleDefinition that contains the Interaction which contains the Participation. \u0000Reference: SBOL Version 2.3.0 Section 7.9.4 on page 45 :\u0000 https://github.com/SynBioDex/SBOL-Notebooks/ModuleDefinition/toggle_switch/LacI_represses_pLac/part_pLac_promoter/1\u0000 Validation failed.\n" + ] + } + ], "source": [ - "doc.addModuleDefinition(laci_inverter_md)\n", - "doc.addModuleDefinition(ci_inverter_md)\n", + "doc.addModuleDefinition(lacI_inverter_md)\n", + "doc.addModuleDefinition(cI_inverter_md)\n", "doc.addModuleDefinition(toggle_md)\n", "\n", "# Validate the document\n", From b0ddb30b135bd3ff5acdc74de6b023678e270e38 Mon Sep 17 00:00:00 2001 From: GeneCodeSavvy Date: Thu, 3 Jul 2025 22:56:24 +0530 Subject: [PATCH 5/9] mix mapsto validation --- .../sbol2/CreatingSBOL2Objects/MapsTo.ipynb | 49 ++++--------------- 1 file changed, 10 insertions(+), 39 deletions(-) diff --git a/examples/sbol2/CreatingSBOL2Objects/MapsTo.ipynb b/examples/sbol2/CreatingSBOL2Objects/MapsTo.ipynb index 6204785..868becc 100644 --- a/examples/sbol2/CreatingSBOL2Objects/MapsTo.ipynb +++ b/examples/sbol2/CreatingSBOL2Objects/MapsTo.ipynb @@ -216,32 +216,11 @@ "interaction1.interaction_type = sbol2.SBO_INHIBITION\n", "toggle_md.interactions.add(interaction1)\n", "\n", - "# Creating participation objects\n", - "# LacI protein is the INHIBITOR\n", - "inhibitor1 = interaction1.participations.create('part_LacI_protein')\n", - "inhibitor1.roles = [sbol2.SBO_INHIBITOR]\n", - "inhibitor1.participant = lacI_prot_fc\n", - "\n", - "# pLac promoter is what is being INHIBITED\n", - "inhibited1 = interaction1.participations.create('part_pLac_promoter')\n", - "inhibited1.roles = [sbol2.SBO_INHIBITED]\n", - "inhibited1.participant = pLac_fc\n", - "\n", "\n", "# Interaction 2: cI protein represses the pLambda promoter (inhibiting LacI production)\n", "interaction2 = sbol2.Interaction('cI_represses_pLambda')\n", "interaction2.interaction_type = sbol2.SBO_INHIBITION\n", - "toggle_md.interactions.add(interaction2)\n", - "\n", - "# Participation 2.1: cI protein is the INHIBITOR\n", - "inhibitor2 = interaction2.participations.create('part_cI_protein')\n", - "inhibitor2.roles = [sbol2.SBO_INHIBITOR]\n", - "inhibitor2.participant = cI_prot_fc\n", - "\n", - "# Participation 2.2: The cI-repressible promoter is what is being INHIBITED\n", - "inhibited2 = interaction2.participations.create('part_pR_promoter')\n", - "inhibited2.roles = [sbol2.SBO_INHIBITED]\n", - "inhibited2.participant = pR_fc" + "toggle_md.interactions.add(interaction2)" ] }, { @@ -270,26 +249,26 @@ "# Map 1: LacI protein is the input to the LacI inverter\n", "map1 = laci_inverter_instance.mapsTos.create('map_laci_in')\n", "# map1.refinement = sbol2.SBOL_REFINEMENT_USE_REMOTE\n", - "map1.local = lacI_tf_fc\n", - "map1.remote = lacI_prot_fc\n", + "map1.local = lacI_prot_fc\n", + "map1.remote = lacI_tf_fc\n", "\n", "# Map 2: cI protein is the output of the LacI inverter\n", "map2 = laci_inverter_instance.mapsTos.create('map_ci_out')\n", "# map2.refinement = sbol2.SBOL_REFINEMENT_USE_REMOTE\n", - "map2.local = cI_tf_fc\n", - "map2.remote = cI_prot_fc\n", + "map2.local = cI_prot_fc\n", + "map2.remote = cI_tf_fc\n", "\n", "# Map 3: cI protein is the input to the cI inverter\n", "map3 = ci_inverter_instance.mapsTos.create('map_ci_in')\n", "# map3.refinement = sbol2.SBOL_REFINEMENT_USE_LOCAL\n", - "map3.local = cI_tf_fc\n", - "map3.remote = cI_prot_fc\n", + "map3.local = cI_prot_fc\n", + "map3.remote = cI_tf_fc\n", "\n", "# Map 4: LacI protein is the output of the cI inverter\n", "map4 = ci_inverter_instance.mapsTos.create('map_laci_out')\n", "# map3.refinement = sbol2.SBOL_REFINEMENT_USE_LOCAL\n", - "map4.local = lacI_tf_fc\n", - "map4.remote = lacI_prot_fc" + "map4.local = lacI_prot_fc\n", + "map4.remote = lacI_tf_fc" ] }, { @@ -307,15 +286,7 @@ "execution_count": 9, "id": "cell-014", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Invalid. sbol-12003:\u0000 Strong Validation Error:\u0000 The FunctionalComponent referenced by the participant property of a Participation MUST be contained by the ModuleDefinition that contains the Interaction which contains the Participation. \u0000Reference: SBOL Version 2.3.0 Section 7.9.4 on page 45 :\u0000 https://github.com/SynBioDex/SBOL-Notebooks/ModuleDefinition/toggle_switch/LacI_represses_pLac/part_pLac_promoter/1\u0000 Validation failed.\n" - ] - } - ], + "outputs": [], "source": [ "doc.addModuleDefinition(lacI_inverter_md)\n", "doc.addModuleDefinition(cI_inverter_md)\n", From 26f07d304503d8cd8af362ac58578cab4979ddcf Mon Sep 17 00:00:00 2001 From: GeneCodeSavvy Date: Thu, 3 Jul 2025 23:04:06 +0530 Subject: [PATCH 6/9] replace with correct refinement property --- .../sbol2/CreatingSBOL2Objects/MapsTo.ipynb | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/examples/sbol2/CreatingSBOL2Objects/MapsTo.ipynb b/examples/sbol2/CreatingSBOL2Objects/MapsTo.ipynb index 868becc..1d8bff1 100644 --- a/examples/sbol2/CreatingSBOL2Objects/MapsTo.ipynb +++ b/examples/sbol2/CreatingSBOL2Objects/MapsTo.ipynb @@ -217,6 +217,7 @@ "toggle_md.interactions.add(interaction1)\n", "\n", "\n", + "\n", "# Interaction 2: cI protein represses the pLambda promoter (inhibiting LacI production)\n", "interaction2 = sbol2.Interaction('cI_represses_pLambda')\n", "interaction2.interaction_type = sbol2.SBO_INHIBITION\n", @@ -248,25 +249,25 @@ "source": [ "# Map 1: LacI protein is the input to the LacI inverter\n", "map1 = laci_inverter_instance.mapsTos.create('map_laci_in')\n", - "# map1.refinement = sbol2.SBOL_REFINEMENT_USE_REMOTE\n", + "map1.refinement = sbol2.SBOL_REFINEMENT_USE_REMOTE\n", "map1.local = lacI_prot_fc\n", "map1.remote = lacI_tf_fc\n", "\n", "# Map 2: cI protein is the output of the LacI inverter\n", "map2 = laci_inverter_instance.mapsTos.create('map_ci_out')\n", - "# map2.refinement = sbol2.SBOL_REFINEMENT_USE_REMOTE\n", + "map2.refinement = sbol2.SBOL_REFINEMENT_USE_REMOTE\n", "map2.local = cI_prot_fc\n", "map2.remote = cI_tf_fc\n", "\n", "# Map 3: cI protein is the input to the cI inverter\n", "map3 = ci_inverter_instance.mapsTos.create('map_ci_in')\n", - "# map3.refinement = sbol2.SBOL_REFINEMENT_USE_LOCAL\n", + "map3.refinement = sbol2.SBOL_REFINEMENT_USE_LOCAL\n", "map3.local = cI_prot_fc\n", "map3.remote = cI_tf_fc\n", "\n", "# Map 4: LacI protein is the output of the cI inverter\n", "map4 = ci_inverter_instance.mapsTos.create('map_laci_out')\n", - "# map3.refinement = sbol2.SBOL_REFINEMENT_USE_LOCAL\n", + "map3.refinement = sbol2.SBOL_REFINEMENT_USE_LOCAL\n", "map4.local = lacI_prot_fc\n", "map4.remote = lacI_tf_fc" ] @@ -286,7 +287,15 @@ "execution_count": 9, "id": "cell-014", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Invalid. sbol-12003:\u0000 Strong Validation Error:\u0000 The FunctionalComponent referenced by the participant property of a Participation MUST be contained by the ModuleDefinition that contains the Interaction which contains the Participation. \u0000Reference: SBOL Version 2.3.0 Section 7.9.4 on page 45 :\u0000 https://github.com/SynBioDex/SBOL-Notebooks/ModuleDefinition/toggle_switch/LacI_represses_pLac/part_pLac_promoter/1\u0000 Validation failed.\n" + ] + } + ], "source": [ "doc.addModuleDefinition(lacI_inverter_md)\n", "doc.addModuleDefinition(cI_inverter_md)\n", From 7a9925d19b3f8545e5616887a1c3b9cce9f8fe94 Mon Sep 17 00:00:00 2001 From: GeneCodeSavvy Date: Thu, 3 Jul 2025 23:56:04 +0530 Subject: [PATCH 7/9] interaction objects --- .../sbol2/CreatingSBOL2Objects/MapsTo.ipynb | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/examples/sbol2/CreatingSBOL2Objects/MapsTo.ipynb b/examples/sbol2/CreatingSBOL2Objects/MapsTo.ipynb index 1d8bff1..c780af4 100644 --- a/examples/sbol2/CreatingSBOL2Objects/MapsTo.ipynb +++ b/examples/sbol2/CreatingSBOL2Objects/MapsTo.ipynb @@ -216,12 +216,33 @@ "interaction1.interaction_type = sbol2.SBO_INHIBITION\n", "toggle_md.interactions.add(interaction1)\n", "\n", + "# Creating participation objects\n", + "# LacI protein is the INHIBITOR\n", + "inhibitor1 = interaction1.participations.create('part_LacI_protein')\n", + "inhibitor1.roles = [sbol2.SBO_INHIBITOR]\n", + "inhibitor1.participant = lacI_prot_fc\n", + "\n", + "# pLac promoter is what is being INHIBITED\n", + "inhibited1 = interaction1.participations.create('part_pLac_promoter')\n", + "inhibited1.roles = [sbol2.SBO_INHIBITED]\n", + "inhibited1.participant = pLac_fc\n", + "\n", "\n", "\n", "# Interaction 2: cI protein represses the pLambda promoter (inhibiting LacI production)\n", "interaction2 = sbol2.Interaction('cI_represses_pLambda')\n", "interaction2.interaction_type = sbol2.SBO_INHIBITION\n", - "toggle_md.interactions.add(interaction2)" + "toggle_md.interactions.add(interaction2)\n", + "\n", + "# Participation 2.1: cI protein is the INHIBITOR\n", + "inhibitor2 = interaction2.participations.create('part_cI_protein')\n", + "inhibitor2.roles = [sbol2.SBO_INHIBITOR]\n", + "inhibitor2.participant = cI_prot_fc\n", + "\n", + "# Participation 2.2: The cI-repressible promoter is what is being INHIBITED\n", + "inhibited2 = interaction2.participations.create('part_pR_promoter')\n", + "inhibited2.roles = [sbol2.SBO_INHIBITED]\n", + "inhibited2.participant = pR_fc" ] }, { From 5e1152830b55ce8216a8579ca9765cb33a8e280e Mon Sep 17 00:00:00 2001 From: Gonza10V Date: Thu, 3 Jul 2025 13:36:10 -0600 Subject: [PATCH 8/9] updated MapsTo --- .../sbol2/CreatingSBOL2Objects/MapsTo.ipynb | 175 ++++++++++++------ 1 file changed, 115 insertions(+), 60 deletions(-) diff --git a/examples/sbol2/CreatingSBOL2Objects/MapsTo.ipynb b/examples/sbol2/CreatingSBOL2Objects/MapsTo.ipynb index c780af4..6765922 100644 --- a/examples/sbol2/CreatingSBOL2Objects/MapsTo.ipynb +++ b/examples/sbol2/CreatingSBOL2Objects/MapsTo.ipynb @@ -63,6 +63,24 @@ { "cell_type": "code", "execution_count": 3, + "id": "ae833529", + "metadata": {}, + "outputs": [], + "source": [ + "B0032_rbs = sbol2.ComponentDefinition('B0032', sbol2.BIOPAX_DNA)\n", + "B0032_rbs.name = 'B0032_rbs'\n", + "B0032_rbs.addRole(sbol2.SO_RBS)\n", + "doc.addComponentDefinition(B0032_rbs)\n", + "\n", + "B0015_terminator = sbol2.ComponentDefinition('B0015', sbol2.BIOPAX_DNA)\n", + "B0015_terminator.name = 'B0015_terminator'\n", + "B0015_terminator.addRole(sbol2.SO_TERMINATOR)\n", + "doc.addComponentDefinition(B0015_terminator)" + ] + }, + { + "cell_type": "code", + "execution_count": 4, "id": "cell-005", "metadata": {}, "outputs": [], @@ -90,92 +108,129 @@ "doc.addComponentDefinition(pR)" ] }, + { + "cell_type": "code", + "execution_count": 8, + "id": "cedd52b6", + "metadata": {}, + "outputs": [], + "source": [ + "# The toggle switch's behavior is defined by two protein pools\n", + "LacI_protein = sbol2.ComponentDefinition('LacI_protein', sbol2.BIOPAX_PROTEIN)\n", + "LacI_protein.name = 'LacI Protein'\n", + "LacI_protein.addRole('http://identifiers.org/ncit/NCIT:C17207') # 'Transcriptional factor'\n", + "doc.addComponentDefinition(LacI_protein)\n", + "\n", + "cI_protein = sbol2.ComponentDefinition('cI_protein', sbol2.BIOPAX_PROTEIN)\n", + "cI_protein.name = 'Lambda cI Protein'\n", + "cI_protein.addRole('http://identifiers.org/ncit/NCIT:C17208') # 'Transcriptional factor'\n", + "doc.addComponentDefinition(cI_protein) " + ] + }, { "cell_type": "markdown", - "id": "cell-006", + "id": "cell-008", "metadata": {}, "source": [ - "## Define the Inverter Modules (Lower-Level Subsystems)\n", - "\n", - "A toggle switch is composed of two inverters. We define each as a `ModuleDefinition`. Each inverter has an input (the repressor protein), a regulated promoter, and an output (the protein it produces). We also add `Interaction` objects to specify the biological function: repression.\n", + "## Define the Toggle Switch Module (Higher-Level Circuit)\n", "\n", - "- **LacI Inverter**: Takes LacI as input to repress the pLac promoter, which produces the cI protein.\n", - "- **cI Inverter**: Takes cI as input to repress the pR promoter, which produces the LacI protein." + "This `ModuleDefinition` represents the complete genetic toggle switch. From this high-level perspective, we only care about the two key players: the LacI protein and the cI protein." ] }, { "cell_type": "code", - "execution_count": 4, - "id": "cell-007", + "execution_count": 10, + "id": "cell-009", "metadata": {}, "outputs": [], "source": [ - "# 1. LacI Inverter Module (LacI represses production of cI)\n", - "lacI_inverter_md = sbol2.ModuleDefinition('LacI_Inverter')\n", - "\n", - "# Functional Components of the LacI inverter\n", - "lacI_tf_fc = lacI_inverter_md.functionalComponents.create('laci_transcription_factor')\n", - "lacI_tf_fc.definition = lacI_cds\n", - "lacI_tf_fc.access = sbol2.SBOL_ACCESS_PUBLIC\n", - "lacI_tf_fc.direction = sbol2.SBOL_DIRECTION_IN\n", - "\n", - "pLac_fc = lacI_inverter_md.functionalComponents.create('pLac_promoter')\n", - "pLac_fc.definition = pLac\n", - "pLac.access = sbol2.SBOL_ACCESS_PRIVATE\n", - "\n", - "cI_gene_product_fc = lacI_inverter_md.functionalComponents.create('cI_gene_product')\n", - "cI_gene_product_fc.definition = cI_cds\n", - "cI_gene_product_fc.access = sbol2.SBOL_ACCESS_PUBLIC\n", - "cI_gene_product_fc.direction = sbol2.SBOL_DIRECTION_OUT\n", - "\n", - "\n", - "\n", - "# 2. cI Inverter Module (cI represses production of LacI)\n", - "cI_inverter_md = sbol2.ModuleDefinition('cI_Inverter')\n", + "toggle_md = sbol2.ModuleDefinition('toggle_switch')\n", "\n", - "# Functional Components of the cI inverter\n", - "cI_tf_fc = cI_inverter_md.functionalComponents.create('cI_transcription_factor')\n", - "cI_tf_fc.definition = cI_cds\n", - "cI_tf_fc.access = sbol2.SBOL_ACCESS_PUBLIC\n", - "cI_tf_fc.direction = sbol2.SBOL_DIRECTION_IN\n", + "# create functional components by calling.using protein ComponentDefinitions\n", "\n", - "pR_fc = cI_inverter_md.functionalComponents.create('pR_promoter')\n", - "pR_fc.definition = pR\n", - "pR_fc.access = sbol2.SBOL_ACCESS_PRIVATE\n", + "lacI_prot_fc = toggle_md.functionalComponents.create('LacI_protein_toggle')\n", + "lacI_prot_fc.definition = LacI_protein\n", + "lacI_prot_fc.direction = sbol2.SBOL_DIRECTION_IN_OUT\n", "\n", - "lacI_gene_product_fc = cI_inverter_md.functionalComponents.create('LacI_gene_product')\n", - "lacI_gene_product_fc.definition = lacI_cds\n", - "lacI_gene_product_fc.access = sbol2.SBOL_ACCESS_PUBLIC\n", - "lacI_gene_product_fc.direction = sbol2.SBOL_DIRECTION_OUT" + "cI_prot_fc = toggle_md.functionalComponents.create('cI_protein_toggle')\n", + "cI_prot_fc.definition = cI_protein\n", + "cI_prot_fc.direction = sbol2.SBOL_DIRECTION_IN_OUT" ] }, { "cell_type": "markdown", - "id": "cell-008", + "id": "cell-006", "metadata": {}, "source": [ - "## Define the Toggle Switch Module (Higher-Level Circuit)\n", + "## Define the Inverter Modules (Lower-Level Subsystems)\n", "\n", - "This `ModuleDefinition` represents the complete genetic toggle switch. From this high-level perspective, we only care about the two key players: the LacI protein and the cI protein." + "A toggle switch is composed of two inverters. We define each as a `ModuleDefinition`. Each inverter has an input (the repressor protein), a regulated promoter, and an output (the protein it produces). We also add `Interaction` objects to specify the biological function: repression.\n", + "\n", + "- **LacI Inverter**: Takes LacI as input to repress the pLac promoter, which produces the cI protein.\n", + "- **cI Inverter**: Takes cI as input to repress the pR promoter, which produces the LacI protein." ] }, { "cell_type": "code", - "execution_count": 5, - "id": "cell-009", + "execution_count": 24, + "id": "cell-007", "metadata": {}, "outputs": [], "source": [ - "toggle_md = sbol2.ModuleDefinition('toggle_switch')\n", + "# 1. LacI Inverter Module (LacI represses production of cI)\n", + "lacI_inverter_md = sbol2.ModuleDefinition('LacI_Inverter')\n", "\n", - "# The toggle switch's behavior is defined by two protein pools\n", - "lacI_prot_fc = toggle_md.functionalComponents.create('LacI_protein')\n", - "lacI_prot_fc.definition = lacI_cds\n", + "lacI_inverter_plac_comp = sbol2.component.Component('pLac_promoter', pLac.identity)\n", + "lacI_inverter_b0032_rbs = sbol2.component.Component('B0032_rbs', B0032_rbs.identity)\n", + "lacI_inverter_cI_cds = sbol2.component.Component('cI_cds', cI_cds.identity)\n", + "lacI_inverter_b0015_terminator = sbol2.component.Component('B0015_terminator', B0015_terminator.identity)\n", + "\n", + "# LacI Inverter Transcriptional Unit Component Definition\n", + "lacI_engineered_region = sbol2.ComponentDefinition('LacI_Engineered_Region', sbol2.BIOPAX_DNA)\n", + "lacI_engineered_region.name = 'LacI Engineered Region'\n", + "lacI_engineered_region.addRole('http://identifiers.org/so/SO:0000804') \n", + "lacI_engineered_region.components.add(lacI_inverter_plac_comp)\n", + "lacI_engineered_region.components.add(lacI_inverter_b0032_rbs)\n", + "lacI_engineered_region.components.add(lacI_inverter_cI_cds)\n", + "lacI_engineered_region.components.add(lacI_inverter_b0015_terminator)\n", + "doc.addComponentDefinition(lacI_engineered_region)\n", + "\n", + "# LacI Inverter Proteins\n", + "lacI_prot_fc_lacI_inverter = lacI_inverter_md.functionalComponents.create('LacI_protein_LacI_inverter')\n", + "lacI_prot_fc_lacI_inverter.definition = LacI_protein\n", + "lacI_prot_fc_lacI_inverter.direction = sbol2.SBOL_DIRECTION_IN_OUT\n", + "\n", + "cI_prot_fc_lacI_inverter = lacI_inverter_md.functionalComponents.create('cI_protein_LacI_inverter')\n", + "cI_prot_fc_lacI_inverter.definition = cI_protein\n", + "cI_prot_fc_lacI_inverter.direction = sbol2.SBOL_DIRECTION_IN_OUT\n", + "\n", + "\n", + "# 2. cI Inverter Module (cI represses production of LacI)\n", + "cI_inverter_md = sbol2.ModuleDefinition('cI_Inverter')\n", + "\n", + "cI_inverter_pR_comp = sbol2.component.Component('pR_promoter', pR.identity)\n", + "cI_inverter_b0032_rbs = sbol2.component.Component('B0032_rbs', B0032_rbs.identity)\n", + "cI_inverter_lacI_cds = sbol2.component.Component('lacI_cds', lacI_cds.identity)\n", + "cI_inverter_b0015_terminator = sbol2.component.Component('B0015_terminator', B0015_terminator.identity) \n", + "\n", + "# cI Inverter Transcriptional Unit Component Definition\n", + "cI_engineered_region = sbol2.ComponentDefinition('cI_Engineered_Region', sbol2.BIOPAX_DNA)\n", + "cI_engineered_region.name = 'cI Engineered Region'\n", + "cI_engineered_region.addRole('http://identifiers.org/so/SO:0000804') \n", + "cI_engineered_region.components.add(cI_inverter_pR_comp)\n", + "cI_engineered_region.components.add(cI_inverter_b0032_rbs)\n", + "cI_engineered_region.components.add(cI_inverter_lacI_cds)\n", + "cI_engineered_region.components.add(cI_inverter_b0015_terminator)\n", + "doc.addComponentDefinition(cI_engineered_region)\n", + "\n", + "# cI Inverter Proteins\n", + "lacI_prot_fc = cI_inverter_md.functionalComponents.create('LacI_protein_cI_inverter')\n", + "lacI_prot_fc.definition = LacI_protein\n", "lacI_prot_fc.direction = sbol2.SBOL_DIRECTION_IN_OUT\n", "\n", - "cI_prot_fc = toggle_md.functionalComponents.create('cI_protein')\n", - "cI_prot_fc.definition = cI_cds\n", - "cI_prot_fc.direction = sbol2.SBOL_DIRECTION_IN_OUT" + "cI_prot_fc = cI_inverter_md.functionalComponents.create('cI_protein_cI_inverter')\n", + "cI_prot_fc.definition = cI_protein\n", + "cI_prot_fc.direction = sbol2.SBOL_DIRECTION_IN_OUT " ] }, { @@ -190,7 +245,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 25, "id": "cell-010b", "metadata": {}, "outputs": [], @@ -206,7 +261,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "id": "9cdcd7c0-e419-4106-b7f3-7c8aba06fd7e", "metadata": {}, "outputs": [], @@ -263,7 +318,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "id": "cell-012", "metadata": {}, "outputs": [], @@ -305,7 +360,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "id": "cell-014", "metadata": {}, "outputs": [ @@ -334,7 +389,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "GLLDB", "language": "python", "name": "python3" }, @@ -348,7 +403,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.13.5" + "version": "3.9.19" } }, "nbformat": 4, From 2523b1995e24982762b975a9ed2337d3c088d913 Mon Sep 17 00:00:00 2001 From: GeneCodeSavvy Date: Fri, 4 Jul 2025 23:44:28 +0530 Subject: [PATCH 9/9] added interaction objects to sbol2 mapto notebook --- .../sbol2/CreatingSBOL2Objects/MapsTo.ipynb | 240 +++++++++++------- 1 file changed, 145 insertions(+), 95 deletions(-) diff --git a/examples/sbol2/CreatingSBOL2Objects/MapsTo.ipynb b/examples/sbol2/CreatingSBOL2Objects/MapsTo.ipynb index 6765922..f731c85 100644 --- a/examples/sbol2/CreatingSBOL2Objects/MapsTo.ipynb +++ b/examples/sbol2/CreatingSBOL2Objects/MapsTo.ipynb @@ -67,11 +67,13 @@ "metadata": {}, "outputs": [], "source": [ + "# RBS\n", "B0032_rbs = sbol2.ComponentDefinition('B0032', sbol2.BIOPAX_DNA)\n", "B0032_rbs.name = 'B0032_rbs'\n", "B0032_rbs.addRole(sbol2.SO_RBS)\n", "doc.addComponentDefinition(B0032_rbs)\n", "\n", + "# Terminator\n", "B0015_terminator = sbol2.ComponentDefinition('B0015', sbol2.BIOPAX_DNA)\n", "B0015_terminator.name = 'B0015_terminator'\n", "B0015_terminator.addRole(sbol2.SO_TERMINATOR)\n", @@ -96,7 +98,8 @@ "cI_cds.addRole(sbol2.SO_CDS)\n", "doc.addComponentDefinition(cI_cds)\n", "\n", - "# Define Promoters\n", + "\n", + "# Promoters\n", "pLac = sbol2.ComponentDefinition('pLac', sbol2.BIOPAX_DNA)\n", "pLac.name = 'pLac Promoter'\n", "pLac.addRole(sbol2.SO_PROMOTER)\n", @@ -110,7 +113,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 5, "id": "cedd52b6", "metadata": {}, "outputs": [], @@ -139,15 +142,14 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 6, "id": "cell-009", "metadata": {}, "outputs": [], "source": [ "toggle_md = sbol2.ModuleDefinition('toggle_switch')\n", "\n", - "# create functional components by calling.using protein ComponentDefinitions\n", - "\n", + "# Create functional components by calling using protein ComponentDefinitions\n", "lacI_prot_fc = toggle_md.functionalComponents.create('LacI_protein_toggle')\n", "lacI_prot_fc.definition = LacI_protein\n", "lacI_prot_fc.direction = sbol2.SBOL_DIRECTION_IN_OUT\n", @@ -162,7 +164,7 @@ "id": "cell-006", "metadata": {}, "source": [ - "## Define the Inverter Modules (Lower-Level Subsystems)\n", + "## Define the Inverter Module Definition(Lower-Level Subsystems)\n", "\n", "A toggle switch is composed of two inverters. We define each as a `ModuleDefinition`. Each inverter has an input (the repressor protein), a regulated promoter, and an output (the protein it produces). We also add `Interaction` objects to specify the biological function: repression.\n", "\n", @@ -172,48 +174,62 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 7, "id": "cell-007", "metadata": {}, "outputs": [], "source": [ - "# 1. LacI Inverter Module (LacI represses production of cI)\n", + "# 1. LacI Inverter Module Definition (LacI represses production of cI)\n", "lacI_inverter_md = sbol2.ModuleDefinition('LacI_Inverter')\n", "\n", - "lacI_inverter_plac_comp = sbol2.component.Component('pLac_promoter', pLac.identity)\n", - "lacI_inverter_b0032_rbs = sbol2.component.Component('B0032_rbs', B0032_rbs.identity)\n", - "lacI_inverter_cI_cds = sbol2.component.Component('cI_cds', cI_cds.identity)\n", - "lacI_inverter_b0015_terminator = sbol2.component.Component('B0015_terminator', B0015_terminator.identity)\n", + "lacI_inverter_plac_comp = sbol2.component.Component('pLac_promoter')\n", + "lacI_inverter_plac_comp.definition = pLac.identity\n", + "lacI_inverter_b0032_rbs = sbol2.component.Component('B0032_rbs')\n", + "lacI_inverter_b0032_rbs.definition = B0032_rbs.identity\n", + "lacI_inverter_cI_cds = sbol2.component.Component('cI_cds')\n", + "lacI_inverter_cI_cds.definition = cI_cds.identity\n", + "lacI_inverter_b0015_terminator = sbol2.component.Component('B0015_terminator')\n", + "lacI_inverter_b0015_terminator.definition = B0015_terminator.identity\n", "\n", - "# LacI Inverter Transcriptional Unit Component Definition\n", + "## LacI Inverter Transcriptional Unit Component Definition\n", "lacI_engineered_region = sbol2.ComponentDefinition('LacI_Engineered_Region', sbol2.BIOPAX_DNA)\n", "lacI_engineered_region.name = 'LacI Engineered Region'\n", - "lacI_engineered_region.addRole('http://identifiers.org/so/SO:0000804') \n", + "lacI_engineered_region.addRole('http://identifiers.org/so/SO:0000804')\n", "lacI_engineered_region.components.add(lacI_inverter_plac_comp)\n", "lacI_engineered_region.components.add(lacI_inverter_b0032_rbs)\n", "lacI_engineered_region.components.add(lacI_inverter_cI_cds)\n", "lacI_engineered_region.components.add(lacI_inverter_b0015_terminator)\n", "doc.addComponentDefinition(lacI_engineered_region)\n", "\n", - "# LacI Inverter Proteins\n", + "## pLac Promoter Functional Component\n", + "pLac_prom_fc_lacI_inverter = lacI_inverter_md.functionalComponents.create('pLac_promoter_LacI_inverter')\n", + "pLac_prom_fc_lacI_inverter.definition = lacI_inverter_plac_comp\n", + "pLac_prom_fc_lacI_inverter.direction = sbol2.SBOL_DIRECTION_NONE\n", + "\n", + "\n", + "## LacI Inverter Proteins Functional Component\n", "lacI_prot_fc_lacI_inverter = lacI_inverter_md.functionalComponents.create('LacI_protein_LacI_inverter')\n", "lacI_prot_fc_lacI_inverter.definition = LacI_protein\n", - "lacI_prot_fc_lacI_inverter.direction = sbol2.SBOL_DIRECTION_IN_OUT\n", + "lacI_prot_fc_lacI_inverter.direction = sbol2.SBOL_DIRECTION_IN\n", "\n", "cI_prot_fc_lacI_inverter = lacI_inverter_md.functionalComponents.create('cI_protein_LacI_inverter')\n", "cI_prot_fc_lacI_inverter.definition = cI_protein\n", - "cI_prot_fc_lacI_inverter.direction = sbol2.SBOL_DIRECTION_IN_OUT\n", + "cI_prot_fc_lacI_inverter.direction = sbol2.SBOL_DIRECTION_OUT\n", "\n", "\n", "# 2. cI Inverter Module (cI represses production of LacI)\n", "cI_inverter_md = sbol2.ModuleDefinition('cI_Inverter')\n", "\n", - "cI_inverter_pR_comp = sbol2.component.Component('pR_promoter', pR.identity)\n", - "cI_inverter_b0032_rbs = sbol2.component.Component('B0032_rbs', B0032_rbs.identity)\n", - "cI_inverter_lacI_cds = sbol2.component.Component('lacI_cds', lacI_cds.identity)\n", - "cI_inverter_b0015_terminator = sbol2.component.Component('B0015_terminator', B0015_terminator.identity) \n", + "cI_inverter_pR_comp = sbol2.component.Component('pR_promoter')\n", + "cI_inverter_pR_comp.definition = pR.identity\n", + "cI_inverter_b0032_rbs = sbol2.component.Component('B0032_rbs')\n", + "cI_inverter_b0032_rbs.definition = B0032_rbs.identity\n", + "cI_inverter_lacI_cds = sbol2.component.Component('lacI_cds')\n", + "cI_inverter_lacI_cds.definition = lacI_cds.identity\n", + "cI_inverter_b0015_terminator = sbol2.component.Component('B0015_terminator')\n", + "cI_inverter_b0015_terminator.definition = B0015_terminator.identity\n", "\n", - "# cI Inverter Transcriptional Unit Component Definition\n", + "## cI Inverter Transcriptional Unit Component Definition\n", "cI_engineered_region = sbol2.ComponentDefinition('cI_Engineered_Region', sbol2.BIOPAX_DNA)\n", "cI_engineered_region.name = 'cI Engineered Region'\n", "cI_engineered_region.addRole('http://identifiers.org/so/SO:0000804') \n", @@ -223,14 +239,95 @@ "cI_engineered_region.components.add(cI_inverter_b0015_terminator)\n", "doc.addComponentDefinition(cI_engineered_region)\n", "\n", - "# cI Inverter Proteins\n", - "lacI_prot_fc = cI_inverter_md.functionalComponents.create('LacI_protein_cI_inverter')\n", - "lacI_prot_fc.definition = LacI_protein\n", - "lacI_prot_fc.direction = sbol2.SBOL_DIRECTION_IN_OUT\n", + "## pR promoter Unit Functional Component\n", + "pR_prom_fc_cI_inverter = cI_inverter_md.functionalComponents.create('pR_promoter_cI_inverter')\n", + "pR_prom_fc_cI_inverter.definition = cI_inverter_pR_comp\n", + "pR_prom_fc_cI_inverter.direction = sbol2.SBOL_DIRECTION_NONE\n", "\n", - "cI_prot_fc = cI_inverter_md.functionalComponents.create('cI_protein_cI_inverter')\n", - "cI_prot_fc.definition = cI_protein\n", - "cI_prot_fc.direction = sbol2.SBOL_DIRECTION_IN_OUT " + "## cI Inverter Proteins Functional Component\n", + "lacI_prot_fc_cI_inverter = cI_inverter_md.functionalComponents.create('LacI_protein_cI_inverter')\n", + "lacI_prot_fc_cI_inverter.definition = LacI_protein\n", + "lacI_prot_fc_cI_inverter.direction = sbol2.SBOL_DIRECTION_OUT\n", + "\n", + "cI_prot_fc_cI_inverter = cI_inverter_md.functionalComponents.create('cI_protein_cI_inverter')\n", + "cI_prot_fc_cI_inverter.definition = cI_protein\n", + "cI_prot_fc_cI_inverter.direction = sbol2.SBOL_DIRECTION_IN" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "9cdcd7c0-e419-4106-b7f3-7c8aba06fd7e", + "metadata": {}, + "outputs": [], + "source": [ + "# Interaction 1.1: LacI protein inhibiting cI production\n", + "interaction1_1 = sbol2.Interaction('LacI_represses_pLac')\n", + "interaction1_1.interaction_type = sbol2.SBO_INHIBITION\n", + "lacI_inverter_md.interactions.add(interaction1_1)\n", + "\n", + "# Creating participation objects\n", + "## LacI protein is the INHIBITOR\n", + "inhibitor1_1 = interaction1_1.participations.create('part_LacI_protein')\n", + "inhibitor1_1.participant = lacI_prot_fc_lacI_inverter\n", + "inhibitor1_1.roles = [sbol2.SBO_INHIBITOR]\n", + "\n", + "## pLac promoter is being INHIBITED\n", + "inhibited1_1 = interaction1_1.participations.create('part_pLac_promoter')\n", + "inhibited1_1.participant = pLac_prom_fc_lacI_inverter\n", + "inhibited1_1.roles = [sbol2.SBO_INHIBITED]\n", + "\n", + "# Interaction 1.2 : cI production\n", + "interaction1_2 = sbol2.Interaction('cI_production')\n", + "interaction1_2.interaction_type = sbol2.SBO_GENETIC_PRODUCTION\n", + "lacI_inverter_md.interactions.add(interaction1_2)\n", + "\n", + "# Creating participation objects\n", + "## pLac is the promoter\n", + "prom_1_2 = interaction1_2.participations.create('part_pLac_promoter')\n", + "prom_1_2.participant = pLac_prom_fc_lacI_inverter\n", + "prom_1_2.roles = [sbol2.SBO_PROMOTER]\n", + "\n", + "## cI is the product\n", + "product_1_2 = interaction1_2.participations.create('part_cI_protein')\n", + "product_1_2.participant = cI_prot_fc_lacI_inverter\n", + "product_1_2.roles = [sbol2.SBO_PRODUCT]\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "# Interaction 2.1: cI protein inhibiting LacI production\n", + "interaction2_1 = sbol2.Interaction('cI_represses_pR')\n", + "interaction2_1.interaction_type = sbol2.SBO_INHIBITION\n", + "cI_inverter_md.interactions.add(interaction2_1)\n", + "\n", + "## cI protein is the INHIBITOR\n", + "inhibitor2_1 = interaction2_1.participations.create('part_cI_protein')\n", + "inhibitor2_1.roles = [sbol2.SBO_INHIBITOR]\n", + "inhibitor2_1.participant = cI_prot_fc_cI_inverter\n", + "\n", + "## pR promoter is being INHIBITED\n", + "inhibited2_1 = interaction2_1.participations.create('part_transcriptional_unit')\n", + "inhibited2_1.roles = [sbol2.SBO_INHIBITED]\n", + "inhibited2_1.participant = pR_prom_fc_cI_inverter\n", + "\n", + "\n", + "# Interaction 2.2 : LacI production\n", + "interaction2_2 = sbol2.Interaction('lacI_production')\n", + "interaction2_2.interaction_type = sbol2.SBO_GENETIC_PRODUCTION\n", + "cI_inverter_md.interactions.add(interaction2_2)\n", + "\n", + "# Creating participation objects\n", + "## pLac is the promoter\n", + "prom_2_2 = interaction2_2.participations.create('part_pR_promoter')\n", + "prom_2_2.participant = pR_prom_fc_cI_inverter\n", + "prom_2_2.roles = [sbol2.SBO_PROMOTER]\n", + "\n", + "## cI is the product\n", + "product_2_2 = interaction2_2.participations.create('part_cI_protein')\n", + "product_2_2.participant = lacI_prot_fc_cI_inverter\n", + "product_2_2.roles = [sbol2.SBO_PRODUCT]" ] }, { @@ -245,7 +342,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 9, "id": "cell-010b", "metadata": {}, "outputs": [], @@ -253,51 +350,12 @@ "# Instantiate the LacI inverter\n", "laci_inverter_instance = toggle_md.modules.create('laci_inverter_inst')\n", "laci_inverter_instance.definition = lacI_inverter_md\n", + "laci_inverter_instance.displayId = 'laci_inverter_inst'\n", "\n", "# Instantiate the cI inverter\n", "ci_inverter_instance = toggle_md.modules.create('ci_inverter_inst')\n", - "ci_inverter_instance.definition = cI_inverter_md" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "9cdcd7c0-e419-4106-b7f3-7c8aba06fd7e", - "metadata": {}, - "outputs": [], - "source": [ - "# Interaction 1: LacI protein represses the pLac promoter (inhibiting cI production)\n", - "interaction1 = sbol2.Interaction('LacI_represses_pLac')\n", - "interaction1.interaction_type = sbol2.SBO_INHIBITION\n", - "toggle_md.interactions.add(interaction1)\n", - "\n", - "# Creating participation objects\n", - "# LacI protein is the INHIBITOR\n", - "inhibitor1 = interaction1.participations.create('part_LacI_protein')\n", - "inhibitor1.roles = [sbol2.SBO_INHIBITOR]\n", - "inhibitor1.participant = lacI_prot_fc\n", - "\n", - "# pLac promoter is what is being INHIBITED\n", - "inhibited1 = interaction1.participations.create('part_pLac_promoter')\n", - "inhibited1.roles = [sbol2.SBO_INHIBITED]\n", - "inhibited1.participant = pLac_fc\n", - "\n", - "\n", - "\n", - "# Interaction 2: cI protein represses the pLambda promoter (inhibiting LacI production)\n", - "interaction2 = sbol2.Interaction('cI_represses_pLambda')\n", - "interaction2.interaction_type = sbol2.SBO_INHIBITION\n", - "toggle_md.interactions.add(interaction2)\n", - "\n", - "# Participation 2.1: cI protein is the INHIBITOR\n", - "inhibitor2 = interaction2.participations.create('part_cI_protein')\n", - "inhibitor2.roles = [sbol2.SBO_INHIBITOR]\n", - "inhibitor2.participant = cI_prot_fc\n", - "\n", - "# Participation 2.2: The cI-repressible promoter is what is being INHIBITED\n", - "inhibited2 = interaction2.participations.create('part_pR_promoter')\n", - "inhibited2.roles = [sbol2.SBO_INHIBITED]\n", - "inhibited2.participant = pR_fc" + "ci_inverter_instance.definition = cI_inverter_md\n", + "ci_inverter_instance.displayId = 'ci_inverter_inst'" ] }, { @@ -318,34 +376,34 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "id": "cell-012", "metadata": {}, "outputs": [], "source": [ "# Map 1: LacI protein is the input to the LacI inverter\n", - "map1 = laci_inverter_instance.mapsTos.create('map_laci_in')\n", - "map1.refinement = sbol2.SBOL_REFINEMENT_USE_REMOTE\n", + "map1 = laci_inverter_instance.mapsTos.create('map_laci_in_laci_protein')\n", + "map1.refinement = sbol2.SBOL_REFINEMENT_VERIFY_IDENTICAL\n", "map1.local = lacI_prot_fc\n", - "map1.remote = lacI_tf_fc\n", + "map1.remote = lacI_prot_fc_lacI_inverter\n", "\n", "# Map 2: cI protein is the output of the LacI inverter\n", - "map2 = laci_inverter_instance.mapsTos.create('map_ci_out')\n", - "map2.refinement = sbol2.SBOL_REFINEMENT_USE_REMOTE\n", + "map2 = laci_inverter_instance.mapsTos.create('map_ci_out_cI_protein')\n", + "map2.refinement = sbol2.SBOL_REFINEMENT_VERIFY_IDENTICAL\n", "map2.local = cI_prot_fc\n", - "map2.remote = cI_tf_fc\n", + "map2.remote = cI_prot_fc_lacI_inverter\n", "\n", "# Map 3: cI protein is the input to the cI inverter\n", "map3 = ci_inverter_instance.mapsTos.create('map_ci_in')\n", - "map3.refinement = sbol2.SBOL_REFINEMENT_USE_LOCAL\n", + "map3.refinement = sbol2.SBOL_REFINEMENT_VERIFY_IDENTICAL\n", "map3.local = cI_prot_fc\n", - "map3.remote = cI_tf_fc\n", + "map3.remote = cI_prot_fc_cI_inverter\n", "\n", "# Map 4: LacI protein is the output of the cI inverter\n", "map4 = ci_inverter_instance.mapsTos.create('map_laci_out')\n", - "map3.refinement = sbol2.SBOL_REFINEMENT_USE_LOCAL\n", + "map4.refinement = sbol2.SBOL_REFINEMENT_VERIFY_IDENTICAL\n", "map4.local = lacI_prot_fc\n", - "map4.remote = lacI_tf_fc" + "map4.remote = lacI_prot_fc_cI_inverter" ] }, { @@ -360,18 +418,10 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "id": "cell-014", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Invalid. sbol-12003:\u0000 Strong Validation Error:\u0000 The FunctionalComponent referenced by the participant property of a Participation MUST be contained by the ModuleDefinition that contains the Interaction which contains the Participation. \u0000Reference: SBOL Version 2.3.0 Section 7.9.4 on page 45 :\u0000 https://github.com/SynBioDex/SBOL-Notebooks/ModuleDefinition/toggle_switch/LacI_represses_pLac/part_pLac_promoter/1\u0000 Validation failed.\n" - ] - } - ], + "outputs": [], "source": [ "doc.addModuleDefinition(lacI_inverter_md)\n", "doc.addModuleDefinition(cI_inverter_md)\n", @@ -389,7 +439,7 @@ ], "metadata": { "kernelspec": { - "display_name": "GLLDB", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -403,7 +453,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.19" + "version": "3.13.5" } }, "nbformat": 4,