-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A notebook that creates an example of an SBOL2 Component #33
Open
Yehuda-Binik
wants to merge
15
commits into
main
Choose a base branch
from
Yehuda/pysbol2-component
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
9e7edff
Created `Component`, `Component_Definition, and `Sequence` NoteBooks
Yehuda-Binik 800127b
commiting files before pull request
Yehuda-Binik 477e0b8
final changes
Yehuda-Binik f77d46d
Merge branch 'main' of github.com:SynBioDex/SBOL-Notebooks into Yehud…
Yehuda-Binik 5d69933
changed some wording in the markdown in Component.ipynb
Yehuda-Binik 8833598
removed Collection.ipynb. Will move future development of notebook to…
Yehuda-Binik 6ac2410
Added Cut.ipynb that was accidently deleted on previous commit
Yehuda-Binik b072050
cleaned up Component.ipynb"
Yehuda-Binik dbe3806
Update examples/sbol2/CreatingSBOL2Objects/Component.ipynb
Yehuda-Binik 3cea708
Adding markdown to Component Notebook and making the totorial more in…
Yehuda-Binik 0d6bb01
Resolved merge conflict in Component.ipynb by keeping my version
Yehuda-Binik ae50e72
Changed some of the wording in the markdown of Component NoteBook
Yehuda-Binik 914a1ee
Fixed a typo
Yehuda-Binik 4114b5f
Removed SequenceConstraint.ipynb as the file was in the wrong branch
Yehuda-Binik ccc11f8
Got rid of the code relating to source locations
Yehuda-Binik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,205 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# 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", | ||
"\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`: 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", | ||
" 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", | ||
"- `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", | ||
"- `mapsTo`: Defines relationships between `Component` objects in different contexts, such as hierarchical designs. For details, see the `MapsTo` Notebook.\n", | ||
"\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", | ||
"- `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": 7, | ||
"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')\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": [ | ||
"## Steps in Creating A Component" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 8, | ||
"metadata": {}, | ||
"outputs": [], | ||
"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)" | ||
] | ||
}, | ||
{ | ||
"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)" | ||
] | ||
}, | ||
{ | ||
"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", | ||
"# 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", | ||
"# 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", | ||
"\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", | ||
"\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", | ||
"\n", | ||
"# Save the document to an SBOL file\n", | ||
"doc.write('component_example.xml')" | ||
] | ||
} | ||
], | ||
"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 | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this part of the notebook, I would like to have an example of a
component
that has itsrole
property set along with aroleIntegration
ofOverrideRoles
. However, I do not know what example scenario to use to demonstrate this functionality. I was thinking perhaps I could use an activatorComponentDefinition
that is actually being used as a repressor. However, I'm not sure if this example makes sense. In addition, there does not seem to be predefined pysbol constants ofActivator
andRepressor
so I think I would have to find the relevant ontology and create my own URI. How would I go about doing this? Is this the path I should be going down? Any assistance would be appreciated.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
overrideRoles
value is very rarely used, and I'm not sure we have many good examples. I don't think that I've ever used it myself.@cjmyers , do you have a good example here?