Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 135 additions & 0 deletions examples/sbol2/CreatingSBOL2Objects/MapsTo.ipynb
Original file line number Diff line number Diff line change
@@ -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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Give an intuitive example of what this means - why would you want to do this, biologically?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, to design a genetic "toggle switch" ModuleDefinition we can compose two mutually repressing transcriptional units as its Modules. The transcriptional units ModuleDefinition might be one where its promoter is repressed by the cI transcription factor (TF) protein ComponentInstance and its CDS codes for the LacI TF protein ComponentInstance. And the the other where its prmoter is repressed by LacI and its CDS codes for cI.
In this context we would like to know that the proteins expressed by each transcriptional unit is the one repressing the other. To do this we "map" LacI and ci ComponentInstance from one ModuleDefinition to the other.

"\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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, we need to explain what this means biologically

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We think the example will provide enought link between the biology and its representation.

"\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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Say what we're actually doing, biologically

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

]
},
{
"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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is TF?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now included in the example

"tf_fc.definition = tf_fc\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incorrect, and it shouldn't be letting us get away with this. This should be pointing at a ComponentDefinition.

"tf_fc.access = sbol2.SBOL_ACCESS_PUBLIC\n",
"tf_fc.direction = sbol2.SBOL_DIRECTION_IN_OUT\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this in/out?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GeneCodeSavvy TBI give readable and explicit names

"\n",
"# Create higher-level ModuleDefinition\n",
"toggle_md = sbol2.ModuleDefinition('toggle_switch')\n",
"laci_fc = toggle_md.functionalComponents.create('LacI')\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explain what this is for, biologically: why do we need this here if it is private and not interacting with anything?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"laci_fc.definition = laci_fc\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incorrect, and it shouldn't be letting us get away with this. This should be pointing at a ComponentDefinition.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GeneCodeSavvy create a ComponentDefinition for each object that needs it, then create the functionalComponents pointing to them.

"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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explain what this means, intuitively.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you do something with the contents of the document to show it's correct and useful besides just validate it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you have any idea in how to do it? We can use it as input fora model (like iBioSim)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking something like starting with LacI and tracing the Interactions to show that the linkages go around in a circle.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GeneCodeSavvy please implement this idea so we can review it in the 1o1

"\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
}