Skip to content

Commit

Permalink
Updated omex notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
pgleeson committed Sep 14, 2023
1 parent 2eafede commit 0e20626
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 39 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The following standards are demonstrated:
| [CellML](https://www.cellml.org/) | Used to store and exchange computer-based mathematical models. | [cellml.ipynb](https://github.com/combine-org/combine-notebooks/blob/main/notebooks/cellml.ipynb) [View on Binder](https://mybinder.org/v2/gh/combine-org/combine-notebooks/main?labpath=notebooks%2Fcellml.ipynb) [(Dev version)](https://mybinder.org/v2/gh/combine-org/combine-notebooks/development?labpath=notebooks%2Fcellml.ipynb) | [example_cellml.ipynb](https://github.com/combine-org/combine-notebooks/blob/main/notebooks/example_cellml.ipynb) |
| Synthetic Biology Open Language ([SBOL](https://sbolstandard.org/)) | Used for description and the exchange of synthetic biological parts, devices, and systems. | [sbol.ipynb](https://github.com/combine-org/combine-notebooks/blob/main/notebooks/sbol.ipynb) | - |
| [NeuroML](https://neuroml.org/) | An XML based description language that provides a common data format for defining and exchanging descriptions of neuronal cell and network models. | [neuroml.ipynb](https://github.com/combine-org/combine-notebooks/blob/main/notebooks/neuroml.ipynb) [View on Binder](https://mybinder.org/v2/gh/combine-org/combine-notebooks/main?labpath=notebooks%2Fneuroml.ipynb) [(Dev version)](https://mybinder.org/v2/gh/combine-org/combine-notebooks/development?labpath=notebooks%2Fneuroml.ipynb) | - |
| [COMBINE Archive](https://combinearchive.org/index/) | Used to bundle the various documents necessary for a modelling and simulation project, and all relevant information. | [omex.ipynb](https://github.com/combine-org/combine-notebooks/blob/main/notebooks/omex.ipynb) | [example_omex.ipynb](https://github.com/combine-org/combine-notebooks/blob/main/notebooks/example_omex.ipynb) |
| [COMBINE Archive](https://combinearchive.org/index/) | Used to bundle the various documents necessary for a modelling and simulation project, and all relevant information. | [omex.ipynb](https://github.com/combine-org/combine-notebooks/blob/main/notebooks/omex.ipynb) [View on Binder](https://mybinder.org/v2/gh/combine-org/combine-notebooks/main?labpath=notebooks%2Fomex.ipynb) [(Dev version)](https://mybinder.org/v2/gh/combine-org/combine-notebooks/development?labpath=notebooks%2Fomex.ipynb) | [example_omex.ipynb](https://github.com/combine-org/combine-notebooks/blob/main/notebooks/example_omex.ipynb) |
| Biological Pathway Exchange ([BioPAX](http://www.biopax.org/)) | Used to enable integration, exchange and analysis of biological pathway data. | - | [example_biopax.ipynb](https://github.com/combine-org/combine-notebooks/blob/main/notebooks/example_biopax.ipynb) |


Expand Down
138 changes: 100 additions & 38 deletions notebooks/omex.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -43,38 +43,74 @@
"id": "1875d29c",
"metadata": {},
"source": [
"Note: Please change the `colab` flag to `True` if you are using Google Colab."
"Note: the cell below runs some code to determine where the notebook is running (e.g. on your local machine or on Binder), and decides where to save results. If it is hidden, click on the dots (•••) to view."
]
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 1,
"id": "83f73430",
"metadata": {},
"outputs": [],
"metadata": {
"collapsed": true,
"jupyter": {
"outputs_hidden": true,
"source_hidden": true
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Results will be saved in /Users/padraig/git/combine-notebooks/notebooks/results\n"
]
}
],
"source": [
"colab = False\n",
"if colab:\n",
" !pip install git+https://github.com/combine-org/combine-notebooks\n",
"#note: metadata hides this cell on binder but it doesn't get hidden on colab\n",
"from pathlib import Path\n",
"\n",
"#determine if we're running on colab\n",
"try:\n",
" import google.colab\n",
" exec_env = \"colab\" #we seem to be on colab\n",
" print(\"Assuming this notebook is running on Google Colab\")\n",
"except:\n",
" exec_env = \"binder\" #assume it's binder\n",
"\n",
"if exec_env == \"colab\":\n",
" working_dir = f\"{Path.cwd()}/combine-notebooks/notebooks/results\"\n",
" !git clone https://github.com/combine-org/combine-notebooks\n",
" %cd /content/combine-notebooks/notebooks"
" %cd combine-notebooks\n",
" !pip install .\n",
" %mkdir -p {working_dir}\n",
"\n",
"else:\n",
" #binder starts off in the notebook's folder\n",
" working_dir = f\"{Path.cwd()}/results\"\n",
"\n",
"import os\n",
"os.chdir(working_dir)\n",
"\n",
"print(\"Results will be saved in %s\"%working_dir)"
]
},
{
"cell_type": "code",
"execution_count": 38,
"execution_count": 2,
"id": "5e7c2a84",
"metadata": {
"collapsed": false
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
"from pathlib import Path\n",
"# Some OMEX specific libraries\n",
"\n",
"from pymetadata.console import console\n",
"from pymetadata.omex import EntryFormat, ManifestEntry, Omex\n",
"\n",
"from combine_notebooks import RESULTS_DIR"
"from pymetadata.omex import EntryFormat, ManifestEntry, Omex\n"
]
},
{
Expand All @@ -97,7 +133,7 @@
},
{
"cell_type": "code",
"execution_count": 39,
"execution_count": 3,
"id": "d1a747a8",
"metadata": {},
"outputs": [],
Expand All @@ -122,13 +158,13 @@
},
{
"cell_type": "code",
"execution_count": 40,
"execution_count": 4,
"id": "06cfde3a",
"metadata": {},
"outputs": [],
"source": [
"# Path to our results\n",
"results_dir = Path(RESULTS_DIR.stem)"
"results_dir = Path(working_dir) # determined based on the running environment above"
]
},
{
Expand All @@ -142,7 +178,7 @@
},
{
"cell_type": "code",
"execution_count": 41,
"execution_count": 5,
"id": "83838073",
"metadata": {},
"outputs": [],
Expand All @@ -154,7 +190,7 @@
" format=EntryFormat.SBML_L3V2,\n",
" master=False,\n",
" ),\n",
" entry_path=results_dir / \"hello_world_sbml.xml\",\n",
" entry_path= results_dir / \"hello_world_sbml.xml\",\n",
")"
]
},
Expand All @@ -169,7 +205,7 @@
},
{
"cell_type": "code",
"execution_count": 42,
"execution_count": 6,
"id": "92c65b63",
"metadata": {},
"outputs": [],
Expand All @@ -196,29 +232,29 @@
},
{
"cell_type": "code",
"execution_count": 43,
"execution_count": 7,
"id": "abfad069",
"metadata": {},
"outputs": [],
"source": [
"# Add entry for SBGN file\n",
"omex.add_entry(\n",
" entry=ManifestEntry(\n",
" location=\"./sbgn/hello_world_sbgn.sbgn\",\n",
" location=\"./sbgn/hello_world_sbgn_af.sbgn\",\n",
" format=EntryFormat.SBGN,\n",
" master=False,\n",
" ),\n",
" entry_path=results_dir / \"hello_world_sbgn.sbgn\",\n",
" entry_path=results_dir / \"hello_world_sbgn_af.sbgn\",\n",
")\n",
"\n",
"# Add entry for corresponding png file generated from the SBGN\n",
"omex.add_entry(\n",
" entry=ManifestEntry(\n",
" location=\"./sbgn/hello_world_sbgn.png\",\n",
" location=\"./sbgn/hello_world_sbgn_af.png\",\n",
" format=EntryFormat.PNG,\n",
" master=False,\n",
" ),\n",
" entry_path=results_dir / \"hello_world_sbgn.png\",\n",
" entry_path=results_dir / \"hello_world_sbgn_af.png\",\n",
")"
]
},
Expand All @@ -233,10 +269,13 @@
},
{
"cell_type": "code",
"execution_count": 44,
"execution_count": 8,
"id": "b8796964",
"metadata": {
"collapsed": false
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -271,13 +310,28 @@
},
{
"cell_type": "code",
"execution_count": 45,
"execution_count": 9,
"id": "02f7c609",
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #800000; text-decoration-color: #800000\">WARNING </span> Existing omex is overwritten: <a href=\"file:///opt/homebrew/anaconda3/envs/combine/lib/python3.9/site-packages/pymetadata/omex.py\" target=\"_blank\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">omex.py</span></a><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">:</span><a href=\"file:///opt/homebrew/anaconda3/envs/combine/lib/python3.9/site-packages/pymetadata/omex.py#680\" target=\"_blank\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">680</span></a>\n",
" <span style=\"color: #008000; text-decoration-color: #008000\">'/Users/padraig/git/combine-notebooks/notebooks/results/combine_hello_world.omex'</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> </span>\n",
"</pre>\n"
],
"text/plain": [
"\u001b[31mWARNING \u001b[0m Existing omex is overwritten: \u001b]8;id=259727;file:///opt/homebrew/anaconda3/envs/combine/lib/python3.9/site-packages/pymetadata/omex.py\u001b\\\u001b[2momex.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=895099;file:///opt/homebrew/anaconda3/envs/combine/lib/python3.9/site-packages/pymetadata/omex.py#680\u001b\\\u001b[2m680\u001b[0m\u001b]8;;\u001b\\\n",
" \u001b[32m'/Users/padraig/git/combine-notebooks/notebooks/results/combine_hello_world.omex'\u001b[0m \u001b[2m \u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"RESULTS_DIR.mkdir(parents=True, exist_ok=True)\n",
"omex_path = RESULTS_DIR / \"combine_hello_world.omex\"\n",
"omex_path = results_dir / \"combine_hello_world.omex\"\n",
"omex.to_omex(omex_path)"
]
},
Expand All @@ -292,7 +346,7 @@
},
{
"cell_type": "code",
"execution_count": 46,
"execution_count": 10,
"id": "09eda6c2",
"metadata": {},
"outputs": [
Expand All @@ -306,9 +360,9 @@
"<span style=\"color: #808000; text-decoration-color: #808000\">format</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'http://identifiers.org/combine.specifications:sbml.level-3.version-2'</span>, <span style=\"color: #808000; text-decoration-color: #808000\">master</span>=<span style=\"color: #ff0000; text-decoration-color: #ff0000; font-style: italic\">False</span><span style=\"font-weight: bold\">)</span>,\n",
" <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">ManifestEntry</span><span style=\"font-weight: bold\">(</span><span style=\"color: #808000; text-decoration-color: #808000\">location</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'./cellml/hello_world_cellml.cellml'</span>, \n",
"<span style=\"color: #808000; text-decoration-color: #808000\">format</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'http://identifiers.org/combine.specifications:cellml'</span>, <span style=\"color: #808000; text-decoration-color: #808000\">master</span>=<span style=\"color: #ff0000; text-decoration-color: #ff0000; font-style: italic\">False</span><span style=\"font-weight: bold\">)</span>,\n",
" <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">ManifestEntry</span><span style=\"font-weight: bold\">(</span><span style=\"color: #808000; text-decoration-color: #808000\">location</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'./sbgn/hello_world_sbgn.sbgn'</span>, \n",
" <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">ManifestEntry</span><span style=\"font-weight: bold\">(</span><span style=\"color: #808000; text-decoration-color: #808000\">location</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'./sbgn/hello_world_sbgn_af.sbgn'</span>, \n",
"<span style=\"color: #808000; text-decoration-color: #808000\">format</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'http://identifiers.org/combine.specifications:sbgn'</span>, <span style=\"color: #808000; text-decoration-color: #808000\">master</span>=<span style=\"color: #ff0000; text-decoration-color: #ff0000; font-style: italic\">False</span><span style=\"font-weight: bold\">)</span>,\n",
" <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">ManifestEntry</span><span style=\"font-weight: bold\">(</span><span style=\"color: #808000; text-decoration-color: #808000\">location</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'./sbgn/hello_world_sbgn.png'</span>, <span style=\"color: #808000; text-decoration-color: #808000\">format</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'https://purl.org/NET/mediatypes/image/png'</span>, \n",
" <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">ManifestEntry</span><span style=\"font-weight: bold\">(</span><span style=\"color: #808000; text-decoration-color: #808000\">location</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'./sbgn/hello_world_sbgn_af.png'</span>, <span style=\"color: #808000; text-decoration-color: #808000\">format</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'https://purl.org/NET/mediatypes/image/png'</span>, \n",
"<span style=\"color: #808000; text-decoration-color: #808000\">master</span>=<span style=\"color: #ff0000; text-decoration-color: #ff0000; font-style: italic\">False</span><span style=\"font-weight: bold\">)</span>,\n",
" <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">ManifestEntry</span><span style=\"font-weight: bold\">(</span><span style=\"color: #808000; text-decoration-color: #808000\">location</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'./sedml/hello_world_sedml.sedml'</span>, \n",
"<span style=\"color: #808000; text-decoration-color: #808000\">format</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'http://identifiers.org/combine.specifications:sed-ml'</span>, <span style=\"color: #808000; text-decoration-color: #808000\">master</span>=<span style=\"color: #ff0000; text-decoration-color: #ff0000; font-style: italic\">False</span><span style=\"font-weight: bold\">)]</span>\n",
Expand All @@ -322,9 +376,9 @@
"\u001b[33mformat\u001b[0m=\u001b[32m'http://identifiers.org/combine.specifications:sbml.level-3.version-2'\u001b[0m, \u001b[33mmaster\u001b[0m=\u001b[3;91mFalse\u001b[0m\u001b[1m)\u001b[0m,\n",
" \u001b[1;35mManifestEntry\u001b[0m\u001b[1m(\u001b[0m\u001b[33mlocation\u001b[0m=\u001b[32m'./cellml/hello_world_cellml.cellml'\u001b[0m, \n",
"\u001b[33mformat\u001b[0m=\u001b[32m'http://identifiers.org/combine.specifications:cellml'\u001b[0m, \u001b[33mmaster\u001b[0m=\u001b[3;91mFalse\u001b[0m\u001b[1m)\u001b[0m,\n",
" \u001b[1;35mManifestEntry\u001b[0m\u001b[1m(\u001b[0m\u001b[33mlocation\u001b[0m=\u001b[32m'./sbgn/hello_world_sbgn.sbgn'\u001b[0m, \n",
" \u001b[1;35mManifestEntry\u001b[0m\u001b[1m(\u001b[0m\u001b[33mlocation\u001b[0m=\u001b[32m'./sbgn/hello_world_sbgn_af.sbgn'\u001b[0m, \n",
"\u001b[33mformat\u001b[0m=\u001b[32m'http://identifiers.org/combine.specifications:sbgn'\u001b[0m, \u001b[33mmaster\u001b[0m=\u001b[3;91mFalse\u001b[0m\u001b[1m)\u001b[0m,\n",
" \u001b[1;35mManifestEntry\u001b[0m\u001b[1m(\u001b[0m\u001b[33mlocation\u001b[0m=\u001b[32m'./sbgn/hello_world_sbgn.png'\u001b[0m, \u001b[33mformat\u001b[0m=\u001b[32m'https://purl.org/NET/mediatypes/image/png'\u001b[0m, \n",
" \u001b[1;35mManifestEntry\u001b[0m\u001b[1m(\u001b[0m\u001b[33mlocation\u001b[0m=\u001b[32m'./sbgn/hello_world_sbgn_af.png'\u001b[0m, \u001b[33mformat\u001b[0m=\u001b[32m'https://purl.org/NET/mediatypes/image/png'\u001b[0m, \n",
"\u001b[33mmaster\u001b[0m=\u001b[3;91mFalse\u001b[0m\u001b[1m)\u001b[0m,\n",
" \u001b[1;35mManifestEntry\u001b[0m\u001b[1m(\u001b[0m\u001b[33mlocation\u001b[0m=\u001b[32m'./sedml/hello_world_sedml.sedml'\u001b[0m, \n",
"\u001b[33mformat\u001b[0m=\u001b[32m'http://identifiers.org/combine.specifications:sed-ml'\u001b[0m, \u001b[33mmaster\u001b[0m=\u001b[3;91mFalse\u001b[0m\u001b[1m)\u001b[0m\u001b[1m]\u001b[0m\n"
Expand All @@ -337,11 +391,19 @@
"source": [
"console.print(omex)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "379283ca-e475-4179-9190-adebe29f5536",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -355,7 +417,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.1"
"version": "3.9.16"
}
},
"nbformat": 4,
Expand Down
Binary file modified notebooks/results/combine_hello_world.omex
Binary file not shown.

0 comments on commit 0e20626

Please sign in to comment.