From 9e7edff5fa2de577acb365ed77b4baa32806e6e9 Mon Sep 17 00:00:00 2001 From: Yehuda Binik Date: Fri, 13 Sep 2024 18:49:40 -0400 Subject: [PATCH 01/12] Created `Component`, `Component_Definition, and `Sequence` NoteBooks --- .../CreatingSBOL2Objects/Component.ipynb | 187 ++++++++++++++++++ .../Component_Definition.ipynb | 82 ++++++++ examples/sbol2/CreatingSBOL2Objects/Cut.ipynb | 23 ++- .../sbol2/CreatingSBOL2Objects/Sequence.ipynb | 76 +++++++ 4 files changed, 362 insertions(+), 6 deletions(-) create mode 100644 examples/sbol2/CreatingSBOL2Objects/Component.ipynb create mode 100644 examples/sbol2/CreatingSBOL2Objects/Component_Definition.ipynb create mode 100644 examples/sbol2/CreatingSBOL2Objects/Sequence.ipynb diff --git a/examples/sbol2/CreatingSBOL2Objects/Component.ipynb b/examples/sbol2/CreatingSBOL2Objects/Component.ipynb new file mode 100644 index 0000000..a56977c --- /dev/null +++ b/examples/sbol2/CreatingSBOL2Objects/Component.ipynb @@ -0,0 +1,187 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Creating a Component\n", + "\n", + "In the following tutorial, we will be creating a `Component` object.\n", + "\n", + "`Components` connect component `ComponentDefinitions` into a hierarchy. In this totorial, we will have one a parent `ComponentDefinition` representing a gene and a child `ComponentDefinition` representing a RBS on said gene.\n", + "\n", + "`Component` objects have the following properties:\n", + "- `uri` yes\n", + "- `definition` yes\n", + "- `mapsTo` no\n", + "- `access` yes\n", + "- `measures` yes\n", + "- `roles` yes\n", + "- `roleIntegration` yes\n", + "- `sourceLocations` maybe\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Import the module" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "metadata": {}, + "outputs": [], + "source": [ + "import sbol2" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Create the document and set the namespace" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "metadata": {}, + "outputs": [], + "source": [ + "doc = sbol2.Document()\n", + "sbol2.setHomespace('https://github.com/SynBioDex/SBOL-Notebooks')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Create a `Sequence` object and add it to the document" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "metadata": {}, + "outputs": [], + "source": [ + "gene_seq = sbol2.Sequence('example_sequence')\n", + "gene_seq.elements = 'AAAGAGGAGAAAATGCGTACGTAGCTAGTCTGATCGTAGCTAGT'\n", + "gene_seq.encoding = sbol2.SBOL_ENCODING_IUPAC\n", + "doc.addSequence(gene_seq)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Ceate a `ComponentDefinition` object for a 'parent' gene and add it to the document" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "metadata": {}, + "outputs": [], + "source": [ + "parent_component_definition = sbol2.ComponentDefinition(uri='parent_component_definition', component_type=sbol2.BIOPAX_DNA)\n", + "parent_component_definition.addRole(sbol2.SO_GENE)\n", + "parent_component_definition.sequence = gene_seq\n", + "doc.addComponentDefinition(parent_component_definition)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Ceate a `ComponentDefinition` object for a 'child' promoter and add it to the document." + ] + }, + { + "cell_type": "code", + "execution_count": 42, + "metadata": {}, + "outputs": [], + "source": [ + "child_component_definition = sbol2.ComponentDefinition(uri='child_component_definition', component_type=sbol2.BIOPAX_DNA)\n", + "child_component_definition.addRole(sbol2.SO_PROMOTER)\n", + "doc.addComponentDefinition(child_component_definition)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Now, Create some `Location` object to define the portion of the gene's sequence that will be included in the promoter. For this tutorial, we will create a `range`, as that is what makes most sense, however you cut create a `Cut`, `GenericLocation`, or even a combination of all three, if thats what you need." + ] + }, + { + "cell_type": "code", + "execution_count": 43, + "metadata": {}, + "outputs": [], + "source": [ + "promoter_range = sbol2.Range(uri='sample_generic_location')\n", + "promoter_range.start = 1\n", + "promoter_range.end = 12\n", + "doc.add(promoter_range)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Create a `Component` object to connect the promoter to the gene" + ] + }, + { + "cell_type": "code", + "execution_count": 44, + "metadata": {}, + "outputs": [], + "source": [ + "child_component = sbol2.Component(uri='child_component', access=sbol2.SBOL_ACCESS_PRIVATE)\n", + "child_component.definition = child_component_definition\n", + "child_component.sourceLocations = [promoter_range]\n", + "parent_component_definition.components.add(child_component)" + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "metadata": {}, + "outputs": [], + "source": [ + "report = doc.validate()\n", + "if (report == 'Valid.'):\n", + " doc.write('component_example.xml')\n", + "else:\n", + " print(report)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "SBOL-test", + "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.10.14" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/examples/sbol2/CreatingSBOL2Objects/Component_Definition.ipynb b/examples/sbol2/CreatingSBOL2Objects/Component_Definition.ipynb new file mode 100644 index 0000000..b6c6d2a --- /dev/null +++ b/examples/sbol2/CreatingSBOL2Objects/Component_Definition.ipynb @@ -0,0 +1,82 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [], + "source": [ + "import sbol2\n", + "\n", + "# Create an SBOL document\n", + "doc = sbol2.Document()\n", + "\n", + "# Set a namespace for the document\n", + "sbol2.setHomespace('https://github.com/SynBioDex/SBOL-Notebooks')" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [], + "source": [ + "# Create a ComponentDefinition object for a DNA component\n", + "comp_def = sbol2.ComponentDefinition(uri='example_component_definition', component_type=sbol2.BIOPAX_DNA)\n", + "\n", + "# Add the ComponentDefinition to the document\n", + "doc.addComponentDefinition(comp_def)" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Valid.\n" + ] + } + ], + "source": [ + "# Validate the document Save the document to an SBOL file\n", + "report = doc.validate()\n", + "if (report == 'Valid'):\n", + " doc.write('comp_def_example.xml')\n", + "else:\n", + " print(report)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "SBOL-test", + "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.10.14" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/examples/sbol2/CreatingSBOL2Objects/Cut.ipynb b/examples/sbol2/CreatingSBOL2Objects/Cut.ipynb index 61beb97..856e031 100644 --- a/examples/sbol2/CreatingSBOL2Objects/Cut.ipynb +++ b/examples/sbol2/CreatingSBOL2Objects/Cut.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -14,7 +14,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -32,7 +32,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -60,9 +60,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'Valid.'" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# Save the document to an SBOL file\n", "doc.write('cut_example.xml')" @@ -85,7 +96,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.6" + "version": "3.10.14" } }, "nbformat": 4, diff --git a/examples/sbol2/CreatingSBOL2Objects/Sequence.ipynb b/examples/sbol2/CreatingSBOL2Objects/Sequence.ipynb new file mode 100644 index 0000000..2680ad5 --- /dev/null +++ b/examples/sbol2/CreatingSBOL2Objects/Sequence.ipynb @@ -0,0 +1,76 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import sbol2" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Create the document and set the namespace" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "doc = sbol2.Document()\n", + "sbol2.setHomespace('https://github.com/SynBioDex/SBOL-Notebooks')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Create a Sequence Object and add it to the document" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "seq = sbol2.Sequence('example_sequence')\n", + "seq.elements = 'ATGCGTACGTAGCTAGTCTGATCGTAGCTAGT'\n", + "seq.encoding = sbol2.SBOL_ENCODING_IUPAC\n", + "doc.addSequence(seq)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Validate the document and save the document to an SBOL file\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "report = doc.validate()\n", + "if (report == 'Valid'):\n", + " doc.write('sequence_example.xml')\n", + "else:\n", + " print(report)" + ] + } + ], + "metadata": { + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From 477e0b83b1fe4aa173c08a69d05e180792c5baa0 Mon Sep 17 00:00:00 2001 From: Yehuda Binik Date: Sun, 15 Sep 2024 19:18:27 -0400 Subject: [PATCH 02/12] final changes --- .../CreatingSBOL2Objects/Component.ipynb | 91 +++++++++------- .../Component_Definition.ipynb | 102 ++++++++++++++---- .../sbol2/CreatingSBOL2Objects/Sequence.ipynb | 48 +++++++-- 3 files changed, 175 insertions(+), 66 deletions(-) diff --git a/examples/sbol2/CreatingSBOL2Objects/Component.ipynb b/examples/sbol2/CreatingSBOL2Objects/Component.ipynb index a56977c..23f74d9 100644 --- a/examples/sbol2/CreatingSBOL2Objects/Component.ipynb +++ b/examples/sbol2/CreatingSBOL2Objects/Component.ipynb @@ -8,17 +8,24 @@ "\n", "In the following tutorial, we will be creating a `Component` object.\n", "\n", - "`Components` connect component `ComponentDefinitions` into a hierarchy. In this totorial, we will have one a parent `ComponentDefinition` representing a gene and a child `ComponentDefinition` representing a RBS on said gene.\n", + "`Components` connect component `ComponentDefinitions` into a hierarchy. In this totorial, we will have one a parent `ComponentDefinition` representing a gene and a child `ComponentDefinition` representing a promoter on said gene.\n", + "\n", "\n", "`Component` objects have the following properties:\n", - "- `uri` yes\n", - "- `definition` yes\n", - "- `mapsTo` no\n", - "- `access` yes\n", - "- `measures` yes\n", - "- `roles` yes\n", - "- `roleIntegration` yes\n", - "- `sourceLocations` maybe\n", + "- `uri` \n", + "- `definition`\n", + "- `mapsTo`\n", + "- `access`\n", + "- `measures`\n", + "- `roles`\n", + "- `roleIntegration`\n", + "- `sourceLocations`\n", + "\n", + "In this tutorial, we will not be dealing with neither the `mapsTo` nor the `measures` atributes. For a guide on those, check out the corresponding notebooks.\n", + "\n", + "For more information on the `Component` class and its properties, check out page 28 of the SBOL 2.3.0 specifications which can be found at the following [link](https://sbolstandard.org/docs/SBOL2.3.0.pdf).\n", + "\n", + "\n", "\n" ] }, @@ -31,7 +38,7 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 62, "metadata": {}, "outputs": [], "source": [ @@ -47,7 +54,7 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 63, "metadata": {}, "outputs": [], "source": [ @@ -59,99 +66,101 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Create a `Sequence` object and add it to the document" + "Create a plasmid `Sequence` object and add it to the document" ] }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 64, "metadata": {}, "outputs": [], "source": [ - "gene_seq = sbol2.Sequence('example_sequence')\n", - "gene_seq.elements = 'AAAGAGGAGAAAATGCGTACGTAGCTAGTCTGATCGTAGCTAGT'\n", - "gene_seq.encoding = sbol2.SBOL_ENCODING_IUPAC\n", - "doc.addSequence(gene_seq)" + "plasmid_sequence = sbol2.Sequence('example_plasmid')\n", + "plasmid_sequence.elements = 'ATGCGTACGATCGTAAAGAGGAGAAAATGCGTACGTAGCTAGTCTGATCGTAGCTAGT'\n", + "plasmid_sequence.encoding = sbol2.SBOL_ENCODING_IUPAC\n", + "doc.addSequence(plasmid_sequence)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "Ceate a `ComponentDefinition` object for a 'parent' gene and add it to the document" + "Ceate a `ComponentDefinition` object for the promoter `Sequence`" ] }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 65, "metadata": {}, "outputs": [], "source": [ - "parent_component_definition = sbol2.ComponentDefinition(uri='parent_component_definition', component_type=sbol2.BIOPAX_DNA)\n", - "parent_component_definition.addRole(sbol2.SO_GENE)\n", - "parent_component_definition.sequence = gene_seq\n", - "doc.addComponentDefinition(parent_component_definition)" + "plasmid_component_definition = sbol2.ComponentDefinition(uri='plasmid_component_definition', component_type=sbol2.BIOPAX_DNA)\n", + "plasmid_component_definition.addRole(sbol2.SO_PROMOTER)\n", + "plasmid_component_definition.sequence = plasmid_sequence\n", + "doc.addComponentDefinition(plasmid_component_definition)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "Ceate a `ComponentDefinition` object for a 'child' promoter and add it to the document." + "Now, Create a `Range` object to define the portion of the plasmids's sequence that will be included in the RBS (lets say 15 - 28)" ] }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 66, "metadata": {}, "outputs": [], "source": [ - "child_component_definition = sbol2.ComponentDefinition(uri='child_component_definition', component_type=sbol2.BIOPAX_DNA)\n", - "child_component_definition.addRole(sbol2.SO_PROMOTER)\n", - "doc.addComponentDefinition(child_component_definition)" + "promoter_range = sbol2.Range(uri='sample_range')\n", + "promoter_range.start = 15\n", + "promoter_range.end = 28\n", + "doc.add(promoter_range)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "Now, Create some `Location` object to define the portion of the gene's sequence that will be included in the promoter. For this tutorial, we will create a `range`, as that is what makes most sense, however you cut create a `Cut`, `GenericLocation`, or even a combination of all three, if thats what you need." + "Ceate a `ComponentDefinition` object for the Gene the RBS will be a part of" ] }, { "cell_type": "code", - "execution_count": 43, + "execution_count": 67, "metadata": {}, "outputs": [], "source": [ - "promoter_range = sbol2.Range(uri='sample_generic_location')\n", - "promoter_range.start = 1\n", - "promoter_range.end = 12\n", - "doc.add(promoter_range)" + "example_gene_component_definition = sbol2.ComponentDefinition(uri='example_gene_component_definition', component_type=sbol2.BIOPAX_DNA)\n", + "example_gene_component_definition.addRole(sbol2.SO_GENE)\n", + "doc.addComponentDefinition(example_gene_component_definition)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "Create a `Component` object to connect the promoter to the gene" + "Create a `Component` object for the RBS" ] }, { "cell_type": "code", - "execution_count": 44, + "execution_count": 68, "metadata": {}, "outputs": [], "source": [ - "child_component = sbol2.Component(uri='child_component', access=sbol2.SBOL_ACCESS_PRIVATE)\n", - "child_component.definition = child_component_definition\n", - "child_component.sourceLocations = [promoter_range]\n", - "parent_component_definition.components.add(child_component)" + "promoter_component = sbol2.Component(uri='RBS_component', access=sbol2.SBOL_ACCESS_PRIVATE)\n", + "promoter_component.definition = plasmid_component_definition\n", + "promoter_component.sourceLocations = [promoter_range]\n", + "promoter_component.roles = [sbol2.SO_PROMOTER]\n", + "promoter_component.roleIntegration = sbol2.SBOL_ROLE_INTEGRATION_OVERRIDE\n", + "example_gene_component_definition.components.add(promoter_component)" ] }, { "cell_type": "code", - "execution_count": 45, + "execution_count": 69, "metadata": {}, "outputs": [], "source": [ diff --git a/examples/sbol2/CreatingSBOL2Objects/Component_Definition.ipynb b/examples/sbol2/CreatingSBOL2Objects/Component_Definition.ipynb index b6c6d2a..037d1a4 100644 --- a/examples/sbol2/CreatingSBOL2Objects/Component_Definition.ipynb +++ b/examples/sbol2/CreatingSBOL2Objects/Component_Definition.ipynb @@ -1,36 +1,108 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Creating a ComponentDefinition\n", + "\n", + "In the following tutorial, we will be creating a `ComponentDefinition` object.\n", + "\n", + "`ComponentDefinition` objects have the following properties:\n", + "- `uri`\n", + "- `types`\n", + "- `roles`\n", + "- `sequences`\n", + "- `components`\n", + "- `sequenceAnnotations`\n", + "- `sequenceConstraints`\n", + "\n", + "In this tutorial, we will be creating a `ComponentDefinition` with a `Sequence` and so will only be setting the `uri`, `types`, `roles`, and `sequences` properties. For a guide on setting the `components`, `sequenceAnnotations`, and `sequenceConstraints` properties, check out the cooresponding notebooks.\n", + "\n", + "For more information on the `ComponentDefinition` class and its properties, check out page 22 of the SBOL 2.3.0 specifications which can be found at the following [link](https://sbolstandard.org/docs/SBOL2.3.0.pdf)." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Import the module" + ] + }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ - "import sbol2\n", - "\n", - "# Create an SBOL document\n", + "import sbol2" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Create the document and set the namespace" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "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", + "metadata": {}, + "source": [ + "Create a `Sequence` object and add it to the document" + ] + }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 13, + "metadata": {}, + "outputs": [], + "source": [ + "seq = sbol2.Sequence('example_sequence')\n", + "seq.elements = 'AAAGAGGAGAAAATGCGTACGTAGCTAGTCTGATCGTAGCTAGT'\n", + "seq.encoding = sbol2.SBOL_ENCODING_IUPAC\n", + "doc.addSequence(seq)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Ceate a `ComponentDefinition` object for a DNA component and add it to the document." + ] + }, + { + "cell_type": "code", + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ - "# Create a ComponentDefinition object for a DNA component\n", "comp_def = sbol2.ComponentDefinition(uri='example_component_definition', component_type=sbol2.BIOPAX_DNA)\n", - "\n", - "# Add the ComponentDefinition to the document\n", + "comp_def.addRole(sbol2.SO_RBS)\n", + "comp_def.sequences = [seq]\n", "doc.addComponentDefinition(comp_def)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Validate the document Save the document to an SBOL file" + ] + }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 15, "metadata": {}, "outputs": [ { @@ -42,20 +114,12 @@ } ], "source": [ - "# Validate the document Save the document to an SBOL file\n", "report = doc.validate()\n", - "if (report == 'Valid'):\n", + "if (report == 'Valid.'):\n", " doc.write('comp_def_example.xml')\n", "else:\n", " print(report)" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { diff --git a/examples/sbol2/CreatingSBOL2Objects/Sequence.ipynb b/examples/sbol2/CreatingSBOL2Objects/Sequence.ipynb index 2680ad5..7fa0d01 100644 --- a/examples/sbol2/CreatingSBOL2Objects/Sequence.ipynb +++ b/examples/sbol2/CreatingSBOL2Objects/Sequence.ipynb @@ -1,8 +1,30 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Creating a Sequence\n", + "\n", + "In the following tutorial, we will be creating a `Sequence` object.\n", + "\n", + "`Sequence` objects have the following properties:\n", + "- `elements` specifies the make-up of the sequence (in this case, it is a string of nucleotide bases)\n", + "- `encoding` specifies how the sequence should be interpreted\n", + "\n", + "For more information on the `Sequence` class and its properties, check out page 21 of the SBOL 2.3.0 specifications which can be found at the following [link](https://sbolstandard.org/docs/SBOL2.3.0.pdf)." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Import the module" + ] + }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -18,7 +40,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ @@ -30,12 +52,12 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Create a Sequence Object and add it to the document" + "Create a `Sequence` and add it to the document" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ @@ -59,7 +81,7 @@ "outputs": [], "source": [ "report = doc.validate()\n", - "if (report == 'Valid'):\n", + "if (report == 'Valid.'):\n", " doc.write('sequence_example.xml')\n", "else:\n", " print(report)" @@ -67,8 +89,22 @@ } ], "metadata": { + "kernelspec": { + "display_name": "SBOL-test", + "language": "python", + "name": "python3" + }, "language_info": { - "name": "python" + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.14" } }, "nbformat": 4, From 5d69933030df52b7e58a99e4c54b611a1703b21d Mon Sep 17 00:00:00 2001 From: Yehuda Binik Date: Mon, 16 Sep 2024 21:26:42 -0400 Subject: [PATCH 03/12] changed some wording in the markdown in Component.ipynb --- .../CreatingSBOL2Objects/Component.ipynb | 2 -- .../Component_Definition.ipynb | 22 +++++-------------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/examples/sbol2/CreatingSBOL2Objects/Component.ipynb b/examples/sbol2/CreatingSBOL2Objects/Component.ipynb index 23f74d9..fa49bcc 100644 --- a/examples/sbol2/CreatingSBOL2Objects/Component.ipynb +++ b/examples/sbol2/CreatingSBOL2Objects/Component.ipynb @@ -6,8 +6,6 @@ "source": [ "# Creating a Component\n", "\n", - "In the following tutorial, we will be creating a `Component` object.\n", - "\n", "`Components` connect component `ComponentDefinitions` into a hierarchy. In this totorial, we will have one a parent `ComponentDefinition` representing a gene and a child `ComponentDefinition` representing a promoter on said gene.\n", "\n", "\n", diff --git a/examples/sbol2/CreatingSBOL2Objects/Component_Definition.ipynb b/examples/sbol2/CreatingSBOL2Objects/Component_Definition.ipynb index 037d1a4..82427a8 100644 --- a/examples/sbol2/CreatingSBOL2Objects/Component_Definition.ipynb +++ b/examples/sbol2/CreatingSBOL2Objects/Component_Definition.ipynb @@ -6,8 +6,6 @@ "source": [ "# Creating a ComponentDefinition\n", "\n", - "In the following tutorial, we will be creating a `ComponentDefinition` object.\n", - "\n", "`ComponentDefinition` objects have the following properties:\n", "- `uri`\n", "- `types`\n", @@ -31,7 +29,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 16, "metadata": {}, "outputs": [], "source": [ @@ -47,7 +45,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 17, "metadata": {}, "outputs": [], "source": [ @@ -64,7 +62,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 18, "metadata": {}, "outputs": [], "source": [ @@ -83,7 +81,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 19, "metadata": {}, "outputs": [], "source": [ @@ -102,17 +100,9 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 20, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Valid.\n" - ] - } - ], + "outputs": [], "source": [ "report = doc.validate()\n", "if (report == 'Valid.'):\n", From 883359835ac5b0c2ec5c3dd54eb74accba0f36bc Mon Sep 17 00:00:00 2001 From: Yehuda Binik Date: Mon, 16 Sep 2024 21:30:30 -0400 Subject: [PATCH 04/12] removed Collection.ipynb. Will move future development of notebook to its own branch --- .../CreatingSBOL2Objects/Component.ipynb | 194 ------------------ 1 file changed, 194 deletions(-) delete mode 100644 examples/sbol2/CreatingSBOL2Objects/Component.ipynb diff --git a/examples/sbol2/CreatingSBOL2Objects/Component.ipynb b/examples/sbol2/CreatingSBOL2Objects/Component.ipynb deleted file mode 100644 index fa49bcc..0000000 --- a/examples/sbol2/CreatingSBOL2Objects/Component.ipynb +++ /dev/null @@ -1,194 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Creating a Component\n", - "\n", - "`Components` connect component `ComponentDefinitions` into a hierarchy. In this totorial, we will have one a parent `ComponentDefinition` representing a gene and a child `ComponentDefinition` representing a promoter on said gene.\n", - "\n", - "\n", - "`Component` objects have the following properties:\n", - "- `uri` \n", - "- `definition`\n", - "- `mapsTo`\n", - "- `access`\n", - "- `measures`\n", - "- `roles`\n", - "- `roleIntegration`\n", - "- `sourceLocations`\n", - "\n", - "In this tutorial, we will not be dealing with neither the `mapsTo` nor the `measures` atributes. For a guide on those, check out the corresponding notebooks.\n", - "\n", - "For more information on the `Component` class and its properties, check out page 28 of the SBOL 2.3.0 specifications which can be found at the following [link](https://sbolstandard.org/docs/SBOL2.3.0.pdf).\n", - "\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Import the module" - ] - }, - { - "cell_type": "code", - "execution_count": 62, - "metadata": {}, - "outputs": [], - "source": [ - "import sbol2" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Create the document and set the namespace" - ] - }, - { - "cell_type": "code", - "execution_count": 63, - "metadata": {}, - "outputs": [], - "source": [ - "doc = sbol2.Document()\n", - "sbol2.setHomespace('https://github.com/SynBioDex/SBOL-Notebooks')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Create a plasmid `Sequence` object and add it to the document" - ] - }, - { - "cell_type": "code", - "execution_count": 64, - "metadata": {}, - "outputs": [], - "source": [ - "plasmid_sequence = sbol2.Sequence('example_plasmid')\n", - "plasmid_sequence.elements = 'ATGCGTACGATCGTAAAGAGGAGAAAATGCGTACGTAGCTAGTCTGATCGTAGCTAGT'\n", - "plasmid_sequence.encoding = sbol2.SBOL_ENCODING_IUPAC\n", - "doc.addSequence(plasmid_sequence)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Ceate a `ComponentDefinition` object for the promoter `Sequence`" - ] - }, - { - "cell_type": "code", - "execution_count": 65, - "metadata": {}, - "outputs": [], - "source": [ - "plasmid_component_definition = sbol2.ComponentDefinition(uri='plasmid_component_definition', component_type=sbol2.BIOPAX_DNA)\n", - "plasmid_component_definition.addRole(sbol2.SO_PROMOTER)\n", - "plasmid_component_definition.sequence = plasmid_sequence\n", - "doc.addComponentDefinition(plasmid_component_definition)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now, Create a `Range` object to define the portion of the plasmids's sequence that will be included in the RBS (lets say 15 - 28)" - ] - }, - { - "cell_type": "code", - "execution_count": 66, - "metadata": {}, - "outputs": [], - "source": [ - "promoter_range = sbol2.Range(uri='sample_range')\n", - "promoter_range.start = 15\n", - "promoter_range.end = 28\n", - "doc.add(promoter_range)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Ceate a `ComponentDefinition` object for the Gene the RBS will be a part of" - ] - }, - { - "cell_type": "code", - "execution_count": 67, - "metadata": {}, - "outputs": [], - "source": [ - "example_gene_component_definition = sbol2.ComponentDefinition(uri='example_gene_component_definition', component_type=sbol2.BIOPAX_DNA)\n", - "example_gene_component_definition.addRole(sbol2.SO_GENE)\n", - "doc.addComponentDefinition(example_gene_component_definition)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Create a `Component` object for the RBS" - ] - }, - { - "cell_type": "code", - "execution_count": 68, - "metadata": {}, - "outputs": [], - "source": [ - "promoter_component = sbol2.Component(uri='RBS_component', access=sbol2.SBOL_ACCESS_PRIVATE)\n", - "promoter_component.definition = plasmid_component_definition\n", - "promoter_component.sourceLocations = [promoter_range]\n", - "promoter_component.roles = [sbol2.SO_PROMOTER]\n", - "promoter_component.roleIntegration = sbol2.SBOL_ROLE_INTEGRATION_OVERRIDE\n", - "example_gene_component_definition.components.add(promoter_component)" - ] - }, - { - "cell_type": "code", - "execution_count": 69, - "metadata": {}, - "outputs": [], - "source": [ - "report = doc.validate()\n", - "if (report == 'Valid.'):\n", - " doc.write('component_example.xml')\n", - "else:\n", - " print(report)" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "SBOL-test", - "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.10.14" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} From 6ac24103882c2df24047d254053a76d389a0f3a1 Mon Sep 17 00:00:00 2001 From: Yehuda Binik Date: Mon, 16 Sep 2024 21:34:40 -0400 Subject: [PATCH 05/12] Added Cut.ipynb that was accidently deleted on previous commit --- examples/sbol2/CreatingSBOL2Objects/Cut.ipynb | 182 ++++++++++++++++++ 1 file changed, 182 insertions(+) create mode 100644 examples/sbol2/CreatingSBOL2Objects/Cut.ipynb diff --git a/examples/sbol2/CreatingSBOL2Objects/Cut.ipynb b/examples/sbol2/CreatingSBOL2Objects/Cut.ipynb new file mode 100644 index 0000000..bf0ba77 --- /dev/null +++ b/examples/sbol2/CreatingSBOL2Objects/Cut.ipynb @@ -0,0 +1,182 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "import sbol2\n", + "\n", + "# Create an SBOL document\n", + "doc = sbol2.Document()" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "# Set a namespace for the document\n", + "sbol2.setHomespace('https://github.com/SynBioDex/SBOL-Notebooks')\n", + "\n", + "# Create a Sequence object\n", + "seq = sbol2.Sequence('example_sequence')\n", + "seq.elements = 'ATGCGTACGTAGCTAGTCTGATCGTAGCTAGT'\n", + "seq.encoding = sbol2.SBOL_ENCODING_IUPAC\n", + "\n", + "# Add the sequence to the document\n", + "doc.addSequence(seq)" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [], + "source": [ + "# Create a ComponentDefinition object for a DNA component\n", + "comp_def = sbol2.ComponentDefinition('example_component', sbol2.BIOPAX_DNA)\n", + "comp_def.sequences = [seq.persistentIdentity]\n", + "\n", + "# Add the ComponentDefinition to the document\n", + "doc.addComponentDefinition(comp_def)\n", + "\n", + "# Create a SequenceAnnotation object to describe a notable feature\n", + "seq_annotation = sbol2.SequenceAnnotation('cut_feature')\n", + "\n", + "# Create a Cut Location\n", + "cut = sbol2.Cut('cut_location')\n", + "cut.at = 10 # Define where the cut is located (position 10)\n", + "cut.orientation = sbol2.SBOL_ORIENTATION_INLINE\n", + "\n", + "# Add the Cut location to the SequenceAnnotation\n", + "seq_annotation.locations.add(cut)\n", + "\n", + "# Add the SequenceAnnotation to the ComponentDefinition\n", + "comp_def.sequenceAnnotations.add(seq_annotation)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'Valid.'" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Check if the SBOL document is valid\n", + "doc.validate()" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'Valid.'" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Save the document to an SBOL file\n", + "doc.write('cut_example.xml')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Extracting Sub-sequences Before and After the Cut\n", + "\n", + "In this section, we will extract the sub-sequences before and after the cut position defined by the `cut_location` in our `SequenceAnnotation`. This process illustrates how we can easily manipulate and analyze sequence data within the SBOL framework, making use of SBOL's standardized approach to describing and annotating biological sequences.\n", + "\n", + "We have defined a `SequenceAnnotation` with a `Cut` location at position 10, meaning that the sequence is \"cut\" at this position. Now, we will use this information to split the sequence into two parts: one before the cut and one after it." + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ATGCGTACGTAGCTAGTCTGATCGTAGCTAGT\n" + ] + } + ], + "source": [ + "# The original sequence is as follows:\n", + "sequence = seq.elements\n", + "print(sequence)" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Before cut: ATGCGTACGT\n", + "After cut: AGCTAGTCTGATCGTAGCTAGT\n" + ] + } + ], + "source": [ + "#Define the cut position (from the SequenceAnnotation's cut location)\n", + "cut_position = cut.at\n", + "\n", + "# Extract the sub-sequences\n", + "before_cut = sequence[:cut_position]\n", + "after_cut = sequence[cut_position:]\n", + "\n", + "# Output the sub-sequences\n", + "print(f\"Before cut: {before_cut}\")\n", + "print(f\"After cut: {after_cut}\")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "sbol_env", + "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.11.6" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From b07205096d27d207eeda1652be51670a2a81502b Mon Sep 17 00:00:00 2001 From: Yehuda Binik Date: Mon, 16 Sep 2024 21:51:01 -0400 Subject: [PATCH 06/12] cleaned up Component.ipynb" --- .../CreatingSBOL2Objects/Component.ipynb | 195 ++++++++++++++++++ .../Component_Definition.ipynb | 136 ------------ 2 files changed, 195 insertions(+), 136 deletions(-) create mode 100644 examples/sbol2/CreatingSBOL2Objects/Component.ipynb delete mode 100644 examples/sbol2/CreatingSBOL2Objects/Component_Definition.ipynb diff --git a/examples/sbol2/CreatingSBOL2Objects/Component.ipynb b/examples/sbol2/CreatingSBOL2Objects/Component.ipynb new file mode 100644 index 0000000..ae4bb61 --- /dev/null +++ b/examples/sbol2/CreatingSBOL2Objects/Component.ipynb @@ -0,0 +1,195 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Creating a Component\n", + "\n", + "`Components` connect component `ComponentDefinitions` into a hierarchy. In this totorial, we will have one a parent `ComponentDefinition` representing a gene and a child `ComponentDefinition` representing a promoter on said gene.\n", + "\n", + "\n", + "`Component` objects have the following properties:\n", + "- `uri` \n", + "- `definition`\n", + "- `mapsTo`\n", + "- `access`\n", + "- `measures`\n", + "- `roles`\n", + "- `roleIntegration`\n", + "- `sourceLocations`\n", + "\n", + "In this tutorial, we will not be dealing with neither the `mapsTo` nor the `measures` atributes. For a guide on those, check out the corresponding notebooks.\n", + "\n", + "For more information on the `Component` class and its properties, check out page 28 of the SBOL 2.3.0 specifications which can be found at the following [link](https://sbolstandard.org/docs/SBOL2.3.0.pdf).\n", + "\n", + "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Import the module" + ] + }, + { + "cell_type": "code", + "execution_count": 62, + "metadata": {}, + "outputs": [], + "source": [ + "import sbol2" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Create the document and set the namespace" + ] + }, + { + "cell_type": "code", + "execution_count": 63, + "metadata": {}, + "outputs": [], + "source": [ + "doc = sbol2.Document()\n", + "sbol2.setHomespace('https://github.com/SynBioDex/SBOL-Notebooks')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Create a plasmid `Sequence` object and add it to the document" + ] + }, + { + "cell_type": "code", + "execution_count": 64, + "metadata": {}, + "outputs": [], + "source": [ + "plasmid_sequence = sbol2.Sequence('example_plasmid')\n", + "plasmid_sequence.elements = 'ATGCGTACGATCGTAAAGAGGAGAAAATGCGTACGTAGCTAGTCTGATCGTAGCTAGT'\n", + "plasmid_sequence.encoding = sbol2.SBOL_ENCODING_IUPAC\n", + "doc.addSequence(plasmid_sequence)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Ceate a `ComponentDefinition` object for the promoter `Sequence`" + ] + }, + { + "cell_type": "code", + "execution_count": 65, + "metadata": {}, + "outputs": [], + "source": [ + "plasmid_component_definition = sbol2.ComponentDefinition(uri='plasmid_component_definition', component_type=sbol2.BIOPAX_DNA)\n", + "plasmid_component_definition.addRole(sbol2.SO_PROMOTER)\n", + "plasmid_component_definition.sequence = plasmid_sequence\n", + "doc.addComponentDefinition(plasmid_component_definition)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Now, Create a `Range` object to define the portion of the plasmids's sequence that will be included in the RBS (lets say 15 - 28)" + ] + }, + { + "cell_type": "code", + "execution_count": 66, + "metadata": {}, + "outputs": [], + "source": [ + "promoter_range = sbol2.Range(uri='sample_range')\n", + "promoter_range.start = 15\n", + "promoter_range.end = 28\n", + "doc.add(promoter_range)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Create a `Component` object for the Promoter that is situated inside the plasmid" + ] + }, + { + "cell_type": "code", + "execution_count": 68, + "metadata": {}, + "outputs": [], + "source": [ + "promoter_component = sbol2.Component(uri='RBS_component', access=sbol2.SBOL_ACCESS_PRIVATE)\n", + "promoter_component.definition = plasmid_component_definition\n", + "promoter_component.sourceLocations = [promoter_range]\n", + "promoter_component.roles = [sbol2.SO_PROMOTER]\n", + "promoter_component.roleIntegration = sbol2.SBOL_ROLE_INTEGRATION_OVERRIDE" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Ceate a `ComponentDefinition` object for the Gene the Promoter will be promoting, and then add the promoter to said compo. You can optionally add a `Sequence` and `SequenceAnnotation` to the Gene to specify the full gene sequence as well as where the promoter for the gene is situated, however we will not go into how to do that here. For more information, go over to the relevent NoteBooks." + ] + }, + { + "cell_type": "code", + "execution_count": 67, + "metadata": {}, + "outputs": [], + "source": [ + "example_gene_component_definition = sbol2.ComponentDefinition(uri='example_gene_component_definition', component_type=sbol2.BIOPAX_DNA)\n", + "example_gene_component_definition.addRole(sbol2.SO_GENE)\n", + "example_gene_component_definition.addRole(sbol2.SO_PROMOTER)\n", + "doc.addComponentDefinition(example_gene_component_definition)\n", + "example_gene_component_definition.components.add(promoter_component)" + ] + }, + { + "cell_type": "code", + "execution_count": 69, + "metadata": {}, + "outputs": [], + "source": [ + "report = doc.validate()\n", + "if (report == 'Valid.'):\n", + " doc.write('component_example.xml')\n", + "else:\n", + " print(report)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "SBOL-test", + "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.10.14" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/examples/sbol2/CreatingSBOL2Objects/Component_Definition.ipynb b/examples/sbol2/CreatingSBOL2Objects/Component_Definition.ipynb deleted file mode 100644 index 82427a8..0000000 --- a/examples/sbol2/CreatingSBOL2Objects/Component_Definition.ipynb +++ /dev/null @@ -1,136 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Creating a ComponentDefinition\n", - "\n", - "`ComponentDefinition` objects have the following properties:\n", - "- `uri`\n", - "- `types`\n", - "- `roles`\n", - "- `sequences`\n", - "- `components`\n", - "- `sequenceAnnotations`\n", - "- `sequenceConstraints`\n", - "\n", - "In this tutorial, we will be creating a `ComponentDefinition` with a `Sequence` and so will only be setting the `uri`, `types`, `roles`, and `sequences` properties. For a guide on setting the `components`, `sequenceAnnotations`, and `sequenceConstraints` properties, check out the cooresponding notebooks.\n", - "\n", - "For more information on the `ComponentDefinition` class and its properties, check out page 22 of the SBOL 2.3.0 specifications which can be found at the following [link](https://sbolstandard.org/docs/SBOL2.3.0.pdf)." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Import the module" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": {}, - "outputs": [], - "source": [ - "import sbol2" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Create the document and set the namespace" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": {}, - "outputs": [], - "source": [ - "doc = sbol2.Document()\n", - "sbol2.setHomespace('https://github.com/SynBioDex/SBOL-Notebooks')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Create a `Sequence` object and add it to the document" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": {}, - "outputs": [], - "source": [ - "seq = sbol2.Sequence('example_sequence')\n", - "seq.elements = 'AAAGAGGAGAAAATGCGTACGTAGCTAGTCTGATCGTAGCTAGT'\n", - "seq.encoding = sbol2.SBOL_ENCODING_IUPAC\n", - "doc.addSequence(seq)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Ceate a `ComponentDefinition` object for a DNA component and add it to the document." - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": {}, - "outputs": [], - "source": [ - "comp_def = sbol2.ComponentDefinition(uri='example_component_definition', component_type=sbol2.BIOPAX_DNA)\n", - "comp_def.addRole(sbol2.SO_RBS)\n", - "comp_def.sequences = [seq]\n", - "doc.addComponentDefinition(comp_def)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Validate the document Save the document to an SBOL file" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": {}, - "outputs": [], - "source": [ - "report = doc.validate()\n", - "if (report == 'Valid.'):\n", - " doc.write('comp_def_example.xml')\n", - "else:\n", - " print(report)" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "SBOL-test", - "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.10.14" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} From dbe38065428ca29a87fdc5190c0e5b133a1de3eb Mon Sep 17 00:00:00 2001 From: Yehuda-Binik <99425841+Yehuda-Binik@users.noreply.github.com> Date: Mon, 30 Sep 2024 14:33:29 -0400 Subject: [PATCH 07/12] Update examples/sbol2/CreatingSBOL2Objects/Component.ipynb fixed typos Co-authored-by: Jacob Beal --- examples/sbol2/CreatingSBOL2Objects/Component.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/sbol2/CreatingSBOL2Objects/Component.ipynb b/examples/sbol2/CreatingSBOL2Objects/Component.ipynb index ae4bb61..f19948f 100644 --- a/examples/sbol2/CreatingSBOL2Objects/Component.ipynb +++ b/examples/sbol2/CreatingSBOL2Objects/Component.ipynb @@ -6,7 +6,7 @@ "source": [ "# Creating a Component\n", "\n", - "`Components` connect component `ComponentDefinitions` into a hierarchy. In this totorial, we will have one a parent `ComponentDefinition` representing a gene and a child `ComponentDefinition` representing a promoter on said gene.\n", + "`Components` connect `ComponentDefinitions` into a hierarchy. In this tutorial, we will have one a parent `ComponentDefinition` representing a gene and a child `ComponentDefinition` representing a promoter on said gene.\n", "\n", "\n", "`Component` objects have the following properties:\n", From 3cea708b48de1f151ae9fc78eafb950aa33a7e27 Mon Sep 17 00:00:00 2001 From: Yehuda Binik Date: Thu, 3 Oct 2024 12:52:17 -0400 Subject: [PATCH 08/12] Adding markdown to Component Notebook and making the totorial more intuitive --- .../CreatingSBOL2Objects/Component.ipynb | 237 ++++++++---------- .../SequenceConstraint.ipynb | 65 +++++ 2 files changed, 164 insertions(+), 138 deletions(-) create mode 100644 examples/sbol2/CreatingSBOL2Objects/SequenceConstraint.ipynb diff --git a/examples/sbol2/CreatingSBOL2Objects/Component.ipynb b/examples/sbol2/CreatingSBOL2Objects/Component.ipynb index ae4bb61..8a8b24a 100644 --- a/examples/sbol2/CreatingSBOL2Objects/Component.ipynb +++ b/examples/sbol2/CreatingSBOL2Objects/Component.ipynb @@ -4,170 +4,131 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Creating a Component\n", + "# Creating a `Component`\n", "\n", - "`Components` connect component `ComponentDefinitions` into a hierarchy. In this totorial, we will have one a parent `ComponentDefinition` representing a gene and a child `ComponentDefinition` representing a promoter on said gene.\n", + "A `Component` is used to compose `ComponentDefinition` objects into a structural hierarchy. For example, the `ComponentDefinition` of a gene could contain four `Component` objects: a promoter, RBS, CDS, and terminator. In turn, the `ComponentDefinition` of the promoter `Component could contain` Component objects defined as various operator sites.\n", "\n", + "`Component` objects have the following properties of note:\n", + "- `definition`: Identifies the `ComponentDefinition` that provides the detailed description or blueprint for the Component. It is `MANDATORY`.\n", "\n", - "`Component` objects have the following properties:\n", - "- `uri` \n", - "- `definition`\n", - "- `mapsTo`\n", - "- `access`\n", - "- `measures`\n", - "- `roles`\n", - "- `roleIntegration`\n", - "- `sourceLocations`\n", + "- `roles`: The expected purpose and function of a genetic part are described by the `roles` property of `ComponentDefinition`. However, the same building block might be used for a different purpose in an actual design. In other words, purpose and function are sometimes determined by context.\n", "\n", - "In this tutorial, we will not be dealing with neither the `mapsTo` nor the `measures` atributes. For a guide on those, check out the corresponding notebooks.\n", + "- `roleIntegration`: Specifies the relationship between a Component instance’s own set of roles and the set of roles on the included sub-ComponentDefinition. It is only mandatory to set if one or more `roles` are set. It can be set to:\n", + " 1. `SBOL_ROLE_INTEGRATION_MERGE`: This option combines the roles from both the current Component and the included sub-ComponentDefinition, resulting in the union of their roles​. It is the default.\n", + " 2. `SBOL_ROLE_INTEGRATION_OVERRIDE`: This option instructs that any roles specified for the included sub-ComponentDefinition should be ignored, and only the roles explicitly defined for the current Component should be used.\n", "\n", - "For more information on the `Component` class and its properties, check out page 28 of the SBOL 2.3.0 specifications which can be found at the following [link](https://sbolstandard.org/docs/SBOL2.3.0.pdf).\n", + "- `sourceLocations`: Indicates which elements of a `ComponentDefinition`'s `Sequence` are to be included in the `Component`'s Parent. It is optional. If it is not set, the whole `Sequence` is assumed to be included.\n", + "\n", + "`Components` also have a `mapsTo`, `access` and `measures` attributes, but they will not be covered in this NoteBook. For an explanation of `mapsTo` and `access`, head over to the `MapsTo` Notebook. for an explantion of `measures`, head over to the `Measure` NoteBook.\n", + "\n", + "For more information on the `Component` class and its properties, check out page 28 of the SBOL 2.3.0 specifications, which can be found at the following [link](https://sbolstandard.org/docs/SBOL2.3.0.pdf).\n", "\n", "\n", "\n" ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Import the module" - ] - }, { "cell_type": "code", - "execution_count": 62, - "metadata": {}, - "outputs": [], - "source": [ - "import sbol2" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Create the document and set the namespace" - ] - }, - { - "cell_type": "code", - "execution_count": 63, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ + "# import dependency\n", + "import sbol2\n", + "\n", + "# Create the document and set the namespace\n", "doc = sbol2.Document()\n", - "sbol2.setHomespace('https://github.com/SynBioDex/SBOL-Notebooks')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Create a plasmid `Sequence` object and add it to the document" - ] - }, - { - "cell_type": "code", - "execution_count": 64, - "metadata": {}, - "outputs": [], - "source": [ - "plasmid_sequence = sbol2.Sequence('example_plasmid')\n", - "plasmid_sequence.elements = 'ATGCGTACGATCGTAAAGAGGAGAAAATGCGTACGTAGCTAGTCTGATCGTAGCTAGT'\n", - "plasmid_sequence.encoding = sbol2.SBOL_ENCODING_IUPAC\n", - "doc.addSequence(plasmid_sequence)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Ceate a `ComponentDefinition` object for the promoter `Sequence`" - ] - }, - { - "cell_type": "code", - "execution_count": 65, - "metadata": {}, - "outputs": [], - "source": [ - "plasmid_component_definition = sbol2.ComponentDefinition(uri='plasmid_component_definition', component_type=sbol2.BIOPAX_DNA)\n", - "plasmid_component_definition.addRole(sbol2.SO_PROMOTER)\n", - "plasmid_component_definition.sequence = plasmid_sequence\n", - "doc.addComponentDefinition(plasmid_component_definition)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now, Create a `Range` object to define the portion of the plasmids's sequence that will be included in the RBS (lets say 15 - 28)" - ] - }, - { - "cell_type": "code", - "execution_count": 66, - "metadata": {}, - "outputs": [], - "source": [ - "promoter_range = sbol2.Range(uri='sample_range')\n", - "promoter_range.start = 15\n", - "promoter_range.end = 28\n", - "doc.add(promoter_range)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Create a `Component` object for the Promoter that is situated inside the plasmid" - ] - }, - { - "cell_type": "code", - "execution_count": 68, - "metadata": {}, - "outputs": [], - "source": [ - "promoter_component = sbol2.Component(uri='RBS_component', access=sbol2.SBOL_ACCESS_PRIVATE)\n", - "promoter_component.definition = plasmid_component_definition\n", - "promoter_component.sourceLocations = [promoter_range]\n", - "promoter_component.roles = [sbol2.SO_PROMOTER]\n", - "promoter_component.roleIntegration = sbol2.SBOL_ROLE_INTEGRATION_OVERRIDE" + "sbol2.setHomespace('https://github.com/SynBioDex/SBOL-Notebooks')\n", + "\n", + "# Create a Sequence object for the genetic construct\n", + "genetic_construct_sequence = sbol2.Sequence('genetic_construct_sequence')\n", + "genetic_construct_sequence.elements = 'ATGCGTACGATCGTAAAGAGGAGAAAATGCGTACGTAGCTAGTCTGATCGTAGCTAGTTGGCTCTGGTTTACTGGGCG'\n", + "genetic_construct_sequence.encoding = sbol2.SBOL_ENCODING_IUPAC\n", + "doc.addSequence(genetic_construct_sequence)\n", + "\n", + "# Create a ComponentDefinition object to house the genetic construct sequence\n", + "genetic_construct_cd = sbol2.ComponentDefinition('genetic_construct_component_definition', component_type=sbol2.BIOPAX_DNA)\n", + "genetic_construct_cd.addRole(sbol2.SBO_GENE)\n", + "genetic_construct_cd.sequence = genetic_construct_sequence\n", + "doc.addComponentDefinition(genetic_construct_cd)\n", + "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "Ceate a `ComponentDefinition` object for the Gene the Promoter will be promoting, and then add the promoter to said compo. You can optionally add a `Sequence` and `SequenceAnnotation` to the Gene to specify the full gene sequence as well as where the promoter for the gene is situated, however we will not go into how to do that here. For more information, go over to the relevent NoteBooks." - ] - }, - { - "cell_type": "code", - "execution_count": 67, - "metadata": {}, - "outputs": [], - "source": [ - "example_gene_component_definition = sbol2.ComponentDefinition(uri='example_gene_component_definition', component_type=sbol2.BIOPAX_DNA)\n", - "example_gene_component_definition.addRole(sbol2.SO_GENE)\n", - "example_gene_component_definition.addRole(sbol2.SO_PROMOTER)\n", - "doc.addComponentDefinition(example_gene_component_definition)\n", - "example_gene_component_definition.components.add(promoter_component)" + "## Steps in Creating A Component\n", + "There are 4 steps in creating a Component \n", + "1. Create the Sub-ComponentDefinition\n", + "2. Create the Component\n", + "3. Set `Component.definition` connecting the `Component`'s `definition` property to the Sub-ComponentDefinition\n", + "4. Add the `Component` to the `component` list of the parent `ComponentDefinition`\n", + "\n", + "Let us walk through the 4 steps by creating a promoter as a SubComponent on the genetic construct" ] }, { "cell_type": "code", - "execution_count": 69, - "metadata": {}, - "outputs": [], - "source": [ - "report = doc.validate()\n", - "if (report == 'Valid.'):\n", - " doc.write('component_example.xml')\n", - "else:\n", - " print(report)" + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'Valid.'" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# --- First Component: Promoter ---\n", + "# Step 1: Ceate a ComponentDefinition object for the promoter\n", + "promoter_component_definition = sbol2.ComponentDefinition('promoter_component_definition', component_type=sbol2.BIOPAX_DNA)\n", + "promoter_component_definition.addRole(sbol2.SO_PROMOTER)\n", + "doc.addComponentDefinition(promoter_component_definition)\n", + "\n", + "# Step 2: Create a Component object for the promoter\n", + "promotor_component = sbol2.Component('promoter_comoponent')\n", + "\n", + "# Step 3: Connect the Component object to the ComponentDefinition object through the definition property\n", + "promotor_component.definition = promoter_component_definition\n", + "\n", + "# Step 4: Add the Component to the the components list in the parent ComponentDefinition\n", + "genetic_construct_cd.components.add(promotor_component)\n", + "\n", + "# Create a range objects to specify the location of the promotor on the genetic construct sequence\n", + "promotor_range = sbol2.Range('promoter_range', start=1, end=26)\n", + "promotor_component.sourceLocations.add(promotor_range)\n", + "\n", + "\n", + "# --- Second Component: CDS ---\n", + "# Create a ComponentDefinition object for the CDS\n", + "cds_component_definition = sbol2.ComponentDefinition('cds_component_definition', component_type=sbol2.BIOPAX_DNA)\n", + "cds_component_definition.addRole(sbol2.SO_CDS)\n", + "doc.addComponentDefinition(cds_component_definition)\n", + "\n", + "# Create a Component for the CDS \n", + "cds_component = sbol2.Component('cds_component')\n", + "cds_component.definition = cds_component_definition\n", + "genetic_construct_cd.components.add(cds_component)\n", + "\n", + "# Add a role integration\n", + "promotor_component.roleIntegration = sbol2.SBOL_ROLE_INTEGRATION_OVERRIDE\n", + "\n", + "# Create a range objects to specify the location of the CDS on the genetic construct sequence\n", + "cds_range = sbol2.Range('cds_range', start=27, end=79)\n", + "cds_component.sourceLocations.add(cds_range)\n", + "\n", + "\n", + "# Check if the SBOL document is valid\n", + "doc.validate()\n", + "\n", + "# Save the document to an SBOL file\n", + "doc.write('component_example.xml')" ] } ], diff --git a/examples/sbol2/CreatingSBOL2Objects/SequenceConstraint.ipynb b/examples/sbol2/CreatingSBOL2Objects/SequenceConstraint.ipynb new file mode 100644 index 0000000..a619c65 --- /dev/null +++ b/examples/sbol2/CreatingSBOL2Objects/SequenceConstraint.ipynb @@ -0,0 +1,65 @@ +{ + "cells": [ + { + "attachments": { + "SequenceConstraintCircuit.PNG": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAvYAAAE0CAIAAADIS+BVAAAN1klEQVR42u3dL2ya+R/AcQSiAkEuywWBQCAQiIqJCQQCUYFoLoiKiokTFRWI5UIu5IJETCBOnJhAVFQgKiomllQgEBWICUTFxAnEBOIRFYjf77ksud9vd91Gu/55vl9eL3XJLUv2/cDzea+D58n9BwAgOjlHAABIHAAAiQMAIHEAACQOAIDEAQAkDgCAx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IAABIHAEDiAABIHAAAiQMAIHEAACQOACBxAAAkDgCAxAEAkDgAABIHAJA4AAASBwBA4gAASBwAAIkDACBxAACJAwAgcQAAJA4AgMQBAJA4AIDEAQCQOAAAEgcAQOIAAEgcAACJAwBIHAAAiQMAIHEAACQOAIDEAQAkDgBAXP4LdwgJH/AKiaAAAAAASUVORK5CYII=" + } + }, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Using `SequenceConstraint` to place restrictions on `Components` within the same `ComponentDefinition`\n", + "\n", + "`SequenceConstraints` are used to describe the relative position and orientation between two components within the same component definition. There are four types of restriction that two components can have. They are outlined through the following examples:\n", + "\n", + "1. `ComponentA` precedes `ComponentB`\n", + "2. `ComponentA` is the same orientation as `ComponentB`\n", + "3. `ComponentA` is the opposite orientation as `ComponentB`\n", + "4. `ComponentA` is different from `ComponentB`\n", + "\n", + "Of the four examples, only #4 is not immediatly straight forward.\n", + "\n", + "To demonstrate the various `SequenceConstraints`, we will model the following genetic circuit\n", + "\n", + "![SequenceConstraintCircuit.PNG](attachment:SequenceConstraintCircuit.PNG)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import sbol2\n", + "\n", + "# Create an SBOL document\n", + "doc = sbol2.Document()\n", + "\n", + "# Set a namespace for the document\n", + "sbol2.setHomespace('https://github.com/SynBioDex/SBOL-Notebooks')\n", + "\n", + "# Create a ComponentDefinition for the genetic circuit\n", + "genetic_cicuit = sbol2.ComponentDefinition('genetic_circuit', sbol2.BIOPAX_DNA)\n", + "doc.addComponentDefinition(example_component_definition)\n", + "\n", + "# Create the Components for each part of the genetic circuit\n", + "\n", + "promoter = sbol2.ComponentDefinition('promoter', sbol2.BIOPAX_DNA)\n", + "\n", + "# Component for the first loxP site\n", + "loxP1 = sbol2.ComponentDefinition('loxP_site_1', sbol2.BIOPAX_DNA)\n", + "loxP1_seq = sbol2.Sequence('loxP_seq_1', 'ATAACTTCGTATAATGTATGCTATACGAAGTTAT', sbol2.SBOL_ENCODING_IUPAC)\n", + "loxP1.sequences = [loxP1_seq.identity]\n", + "doc.addComponentDefinition(loxP1)" + ] + } + ], + "metadata": { + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From ae50e7292917668cc089eb778c02cc862d90b488 Mon Sep 17 00:00:00 2001 From: Yehuda Binik Date: Wed, 9 Oct 2024 11:46:30 -0400 Subject: [PATCH 09/12] Changed some of the wording in the markdown of Component NoteBook --- .../CreatingSBOL2Objects/Component.ipynb | 121 ++++++++++++------ 1 file changed, 85 insertions(+), 36 deletions(-) diff --git a/examples/sbol2/CreatingSBOL2Objects/Component.ipynb b/examples/sbol2/CreatingSBOL2Objects/Component.ipynb index 8a8b24a..f5b42dd 100644 --- a/examples/sbol2/CreatingSBOL2Objects/Component.ipynb +++ b/examples/sbol2/CreatingSBOL2Objects/Component.ipynb @@ -4,14 +4,15 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Creating a `Component`\n", + "# Introduction\n", "\n", - "A `Component` is used to compose `ComponentDefinition` objects into a structural hierarchy. For example, the `ComponentDefinition` of a gene could contain four `Component` objects: a promoter, RBS, CDS, and terminator. In turn, the `ComponentDefinition` of the promoter `Component could contain` Component objects defined as various operator sites.\n", + "A `Component` is used to compose `ComponentDefinition` objects into a structural hierarchy. For example, the `ComponentDefinition` of a gene could contain four `Component` objects: a promoter, RBS, CDS, and terminator. In turn, the `ComponentDefinition` of the promoter `Component` could contain Component objects defined as various operator sites.\n", "\n", "`Component` objects have the following properties of note:\n", + "\n", "- `definition`: Identifies the `ComponentDefinition` that provides the detailed description or blueprint for the Component. It is `MANDATORY`.\n", "\n", - "- `roles`: The expected purpose and function of a genetic part are described by the `roles` property of `ComponentDefinition`. However, the same building block might be used for a different purpose in an actual design. In other words, purpose and function are sometimes determined by context.\n", + "- `roles`: describes the expected purpose and function of the component. Used when the `role` of the component differes from that of the `sub-componentDefinition`. For example, A component Definition that is an activator is being used as a repressor. \n", "\n", "- `roleIntegration`: Specifies the relationship between a Component instance’s own set of roles and the set of roles on the included sub-ComponentDefinition. It is only mandatory to set if one or more `roles` are set. It can be set to:\n", " 1. `SBOL_ROLE_INTEGRATION_MERGE`: This option combines the roles from both the current Component and the included sub-ComponentDefinition, resulting in the union of their roles​. It is the default.\n", @@ -19,17 +20,21 @@ "\n", "- `sourceLocations`: Indicates which elements of a `ComponentDefinition`'s `Sequence` are to be included in the `Component`'s Parent. It is optional. If it is not set, the whole `Sequence` is assumed to be included.\n", "\n", - "`Components` also have a `mapsTo`, `access` and `measures` attributes, but they will not be covered in this NoteBook. For an explanation of `mapsTo` and `access`, head over to the `MapsTo` Notebook. for an explantion of `measures`, head over to the `Measure` NoteBook.\n", + "- `mapsTo`: Defines relationships between `Component` objects in different contexts, such as hierarchical designs. For details, see the `MapsTo` Notebook.\n", "\n", - "For more information on the `Component` class and its properties, check out page 28 of the SBOL 2.3.0 specifications, which can be found at the following [link](https://sbolstandard.org/docs/SBOL2.3.0.pdf).\n", + "- `access`: the access property of a Component controls whether it can be referenced by other components or modules through a `MapsTo` object. There are two options:\n", "\n", + " 1. `SBOL_ACCESS_PUBLIC`: The component is visible and accessible to other designs, meaning it can be used in different parts of a larger system.\n", + " 2. `SBOL_ACCESS_PRIVATE`: The component is only accessible within the design it belongs to and cannot be used by external components.\n", "\n", - "\n" + "- `measures`: The measures property is OPTIONAL and MAY contain a set of Measure objects. For details, see the `Measures` Notebook.\n", + "\n", + "For more information on the `Component` class and its properties, check out page 28 of the SBOL 2.3.0 specifications, which can be found at the following [link](https://sbolstandard.org/docs/SBOL2.3.0.pdf)." ] }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ @@ -58,32 +63,14 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Steps in Creating A Component\n", - "There are 4 steps in creating a Component \n", - "1. Create the Sub-ComponentDefinition\n", - "2. Create the Component\n", - "3. Set `Component.definition` connecting the `Component`'s `definition` property to the Sub-ComponentDefinition\n", - "4. Add the `Component` to the `component` list of the parent `ComponentDefinition`\n", - "\n", - "Let us walk through the 4 steps by creating a promoter as a SubComponent on the genetic construct" + "## Steps in Creating A Component" ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 8, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'Valid.'" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# --- First Component: Promoter ---\n", "# Step 1: Ceate a ComponentDefinition object for the promoter\n", @@ -98,32 +85,94 @@ "promotor_component.definition = promoter_component_definition\n", "\n", "# Step 4: Add the Component to the the components list in the parent ComponentDefinition\n", - "genetic_construct_cd.components.add(promotor_component)\n", + "genetic_construct_cd.components.add(promotor_component)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We can also specify which elements of the gene-construct `ComponentDefinition` is to be included in the promoter. Let us say that the promoter spans the first 26 DNA nucleotides of the gene-construct." + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [], + "source": [ "\n", "# Create a range objects to specify the location of the promotor on the genetic construct sequence\n", "promotor_range = sbol2.Range('promoter_range', start=1, end=26)\n", - "promotor_component.sourceLocations.add(promotor_range)\n", - "\n", + "promotor_component.sourceLocations.add(promotor_range)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Creating the CDS `Component`\n", + "We will now create a second Sub-Component for the gene-construct: A CDS. " + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [], + "source": [ "\n", "# --- Second Component: CDS ---\n", - "# Create a ComponentDefinition object for the CDS\n", + "# Step 1: Ceate a ComponentDefinition object for the promoter\n", "cds_component_definition = sbol2.ComponentDefinition('cds_component_definition', component_type=sbol2.BIOPAX_DNA)\n", "cds_component_definition.addRole(sbol2.SO_CDS)\n", + "\n", "doc.addComponentDefinition(cds_component_definition)\n", "\n", - "# Create a Component for the CDS \n", + "# Step 2: Create a Component object for the promoter\n", "cds_component = sbol2.Component('cds_component')\n", + "\n", + "# Step 3: Connect the Component object to the ComponentDefinition object through the definition property\n", "cds_component.definition = cds_component_definition\n", - "genetic_construct_cd.components.add(cds_component)\n", "\n", - "# Add a role integration\n", + "# Step 4: Add the Component to the the components list in the parent ComponentDefinition\n", + "genetic_construct_cd.components.add(cds_component)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Now we will add a `role` and a `roleIntegration` to the " + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'Valid.'" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "\n", + "# Add a role integration.\n", + "# Note that we have not set any roles for the cds_component. Therefore, it is not required to set a roleIntegration\n", + "# It is only \n", "promotor_component.roleIntegration = sbol2.SBOL_ROLE_INTEGRATION_OVERRIDE\n", "\n", "# Create a range objects to specify the location of the CDS on the genetic construct sequence\n", "cds_range = sbol2.Range('cds_range', start=27, end=79)\n", "cds_component.sourceLocations.add(cds_range)\n", "\n", - "\n", "# Check if the SBOL document is valid\n", "doc.validate()\n", "\n", From 914a1ee99ed6fb8fc8091fa47a1c00af114aecc5 Mon Sep 17 00:00:00 2001 From: Yehuda Binik Date: Wed, 9 Oct 2024 11:49:31 -0400 Subject: [PATCH 10/12] Fixed a typo --- examples/sbol2/CreatingSBOL2Objects/Component.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/sbol2/CreatingSBOL2Objects/Component.ipynb b/examples/sbol2/CreatingSBOL2Objects/Component.ipynb index f5b42dd..6ef3ebf 100644 --- a/examples/sbol2/CreatingSBOL2Objects/Component.ipynb +++ b/examples/sbol2/CreatingSBOL2Objects/Component.ipynb @@ -143,7 +143,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Now we will add a `role` and a `roleIntegration` to the " + "Now we will add a `role` and a `roleIntegration` to the cds_component" ] }, { From 4114b5f8e13c09c5fde9d6a7656f451523c2f73b Mon Sep 17 00:00:00 2001 From: Yehuda Binik Date: Wed, 9 Oct 2024 12:07:02 -0400 Subject: [PATCH 11/12] Removed SequenceConstraint.ipynb as the file was in the wrong branch --- .../SequenceConstraint.ipynb | 65 ------------------- 1 file changed, 65 deletions(-) delete mode 100644 examples/sbol2/CreatingSBOL2Objects/SequenceConstraint.ipynb diff --git a/examples/sbol2/CreatingSBOL2Objects/SequenceConstraint.ipynb b/examples/sbol2/CreatingSBOL2Objects/SequenceConstraint.ipynb deleted file mode 100644 index a619c65..0000000 --- a/examples/sbol2/CreatingSBOL2Objects/SequenceConstraint.ipynb +++ /dev/null @@ -1,65 +0,0 @@ -{ - "cells": [ - { - "attachments": { - "SequenceConstraintCircuit.PNG": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAvYAAAE0CAIAAADIS+BVAAAN1klEQVR42u3dL2ya+R/AcQSiAkEuywWBQCAQiIqJCQQCUYFoLoiKiokTFRWI5UIu5IJETCBOnJhAVFQgKiomllQgEBWICUTFxAnEBOIRFYjf77ksud9vd91Gu/55vl9eL3XJLUv2/cDzea+D58n9BwAgOjlHAABIHAAAiQMAIHEAACQOAIDEAQAkDgCAxAEAkDgAABIHAEDiAAASBwBA4gAASBwAAIkDACBxAAAkDgAgcQAAJA4AgMQBAJA4AAASBwCQOAAAEgcAQOIAAEiczFmv16PRqNlsViqVVqt1enrqTABA4gTfN2nW5D7XbreTJHE4ACBxQjUcDnM3efHixXK5dD4AIHGCVK1Wc19Qq9Wurq4cEQBInABP56tKpdJ8PndKACBxAlOpVL5eOYVC4eLiwkEBgMQJSbfbzX1LPp+fTCbOCgAkTjCSJKnX67kNjEYjxwUAEicYy+Vyw8p59eqV4wIAiROMJEkajcYmlXN4eLher50YAEicMKTh0ul0Nqmcvb09NwYEAIkTUuVs8uljNwYEAIkTni/d79iNAQFA4oRtPB7n8/lvVo4bAwKAxAnM+fl5oVD4ZuW4MSAASJzATKfTUqnkxoAAI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JInEAC9J2NEF9g8QBLEjb0QT1DRIHsCDvqNfrmWDQ+v2+dzoSByQOn+l2uyZogiBxQOLYjiZogkgcwIK0HU1Q3yBxAAvy0RwdHZmgvgGJAxInKp1OZ71em6AJgsQBiWM7mqAJInEAC9J2NEETROIAFqTtaIL6BokDWJB30Ww2A92OZvdJu93WN0gcwIL8TKPRSJLEBE0QJA7Eo1qt2o5Bb0cT1DdIHOAG3W7XdjRBEwSJA7FJ10OtVrMdTdAEQeJAhJXT7Xa36t876vX6YDCI5tOpJggSBwBA4gAASBwAQOIAAEgcAACJAwAgcQAAJA4AIHEAACQOAIDEAQCQOAAAEgcAQOIAABIHAEDiAABIHAAAiQMAIHEAAIkDACBxAAAkDgCAxAEAkDgAABIHAJA4AAASBwBA4gAASBwAAIkDAEgcAACJAwAgcQAAJA4AgMQBAJA4AIDEAQCQOAAAEgcAQOIAAEgcAEDiAABIHAAAiQMAIHEAACQOAIDEAQAkDgCAxAEAkDgAABIHAEDiAAASBwBA4gAASBwAAIkDACBxAAAkDgAgcQAAJA4AgMQBAJA4AAASBwCQOAAAEgcAQOIAAEgcAACJAwBIHEcAAEgcAACJAwAgcQAAJA4AgMQBACQOAIDEAQCQOAAAEgcAQOIAABIHAEDiAABIHAAAiQMAIHEAACQOACBxAAAkDgCAxAEAkDgAABIHAJA4AAASBwBA4gAASBwAAIkDACBxAACJAwAgcQAAJA4AgMQBAJA4AIDEAQCQOAAAEgcAQOIAAEgcAACJAwBIHAAAiQMAIHEAACQOAIDEAQAkDgBAXP4LdwgJH/AKiaAAAAAASUVORK5CYII=" - } - }, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Using `SequenceConstraint` to place restrictions on `Components` within the same `ComponentDefinition`\n", - "\n", - "`SequenceConstraints` are used to describe the relative position and orientation between two components within the same component definition. There are four types of restriction that two components can have. They are outlined through the following examples:\n", - "\n", - "1. `ComponentA` precedes `ComponentB`\n", - "2. `ComponentA` is the same orientation as `ComponentB`\n", - "3. `ComponentA` is the opposite orientation as `ComponentB`\n", - "4. `ComponentA` is different from `ComponentB`\n", - "\n", - "Of the four examples, only #4 is not immediatly straight forward.\n", - "\n", - "To demonstrate the various `SequenceConstraints`, we will model the following genetic circuit\n", - "\n", - "![SequenceConstraintCircuit.PNG](attachment:SequenceConstraintCircuit.PNG)\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import sbol2\n", - "\n", - "# Create an SBOL document\n", - "doc = sbol2.Document()\n", - "\n", - "# Set a namespace for the document\n", - "sbol2.setHomespace('https://github.com/SynBioDex/SBOL-Notebooks')\n", - "\n", - "# Create a ComponentDefinition for the genetic circuit\n", - "genetic_cicuit = sbol2.ComponentDefinition('genetic_circuit', sbol2.BIOPAX_DNA)\n", - "doc.addComponentDefinition(example_component_definition)\n", - "\n", - "# Create the Components for each part of the genetic circuit\n", - "\n", - "promoter = sbol2.ComponentDefinition('promoter', sbol2.BIOPAX_DNA)\n", - "\n", - "# Component for the first loxP site\n", - "loxP1 = sbol2.ComponentDefinition('loxP_site_1', sbol2.BIOPAX_DNA)\n", - "loxP1_seq = sbol2.Sequence('loxP_seq_1', 'ATAACTTCGTATAATGTATGCTATACGAAGTTAT', sbol2.SBOL_ENCODING_IUPAC)\n", - "loxP1.sequences = [loxP1_seq.identity]\n", - "doc.addComponentDefinition(loxP1)" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} From ccc11f81a3f1ffb097099838b7d9395b12e7d318 Mon Sep 17 00:00:00 2001 From: Yehuda Binik Date: Mon, 28 Oct 2024 16:59:11 -0400 Subject: [PATCH 12/12] Got rid of the code relating to source locations --- .../CreatingSBOL2Objects/Component.ipynb | 38 +------------------ 1 file changed, 2 insertions(+), 36 deletions(-) diff --git a/examples/sbol2/CreatingSBOL2Objects/Component.ipynb b/examples/sbol2/CreatingSBOL2Objects/Component.ipynb index 6ef3ebf..89c730e 100644 --- a/examples/sbol2/CreatingSBOL2Objects/Component.ipynb +++ b/examples/sbol2/CreatingSBOL2Objects/Component.ipynb @@ -63,7 +63,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Steps in Creating A Component" + "## Steps in Creating A `Component`" ] }, { @@ -136,42 +136,8 @@ "cds_component.definition = cds_component_definition\n", "\n", "# Step 4: Add the Component to the the components list in the parent ComponentDefinition\n", - "genetic_construct_cd.components.add(cds_component)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now we will add a `role` and a `roleIntegration` to the cds_component" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'Valid.'" - ] - }, - "execution_count": 11, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "\n", - "# Add a role integration.\n", - "# Note that we have not set any roles for the cds_component. Therefore, it is not required to set a roleIntegration\n", - "# It is only \n", - "promotor_component.roleIntegration = sbol2.SBOL_ROLE_INTEGRATION_OVERRIDE\n", + "genetic_construct_cd.components.add(cds_component)\n", "\n", - "# Create a range objects to specify the location of the CDS on the genetic construct sequence\n", - "cds_range = sbol2.Range('cds_range', start=27, end=79)\n", - "cds_component.sourceLocations.add(cds_range)\n", "\n", "# Check if the SBOL document is valid\n", "doc.validate()\n",