diff --git a/README.md b/README.md index 3573232..de54fac 100644 --- a/README.md +++ b/README.md @@ -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) | diff --git a/notebooks/omex.ipynb b/notebooks/omex.ipynb index f6ee9a7..c5b4f75 100644 --- a/notebooks/omex.ipynb +++ b/notebooks/omex.ipynb @@ -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" ] }, { @@ -97,7 +133,7 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 3, "id": "d1a747a8", "metadata": {}, "outputs": [], @@ -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" ] }, { @@ -142,7 +178,7 @@ }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 5, "id": "83838073", "metadata": {}, "outputs": [], @@ -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", ")" ] }, @@ -169,7 +205,7 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 6, "id": "92c65b63", "metadata": {}, "outputs": [], @@ -196,7 +232,7 @@ }, { "cell_type": "code", - "execution_count": 43, + "execution_count": 7, "id": "abfad069", "metadata": {}, "outputs": [], @@ -204,21 +240,21 @@ "# 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", ")" ] }, @@ -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": [ @@ -271,13 +310,28 @@ }, { "cell_type": "code", - "execution_count": 45, + "execution_count": 9, "id": "02f7c609", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
WARNING  Existing omex is overwritten:                                                                  omex.py:680\n",
+       "         '/Users/padraig/git/combine-notebooks/notebooks/results/combine_hello_world.omex'                         \n",
+       "
\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)" ] }, @@ -292,7 +346,7 @@ }, { "cell_type": "code", - "execution_count": 46, + "execution_count": 10, "id": "09eda6c2", "metadata": {}, "outputs": [ @@ -306,9 +360,9 @@ "format='http://identifiers.org/combine.specifications:sbml.level-3.version-2', master=False),\n", " ManifestEntry(location='./cellml/hello_world_cellml.cellml', \n", "format='http://identifiers.org/combine.specifications:cellml', master=False),\n", - " ManifestEntry(location='./sbgn/hello_world_sbgn.sbgn', \n", + " ManifestEntry(location='./sbgn/hello_world_sbgn_af.sbgn', \n", "format='http://identifiers.org/combine.specifications:sbgn', master=False),\n", - " ManifestEntry(location='./sbgn/hello_world_sbgn.png', format='https://purl.org/NET/mediatypes/image/png', \n", + " ManifestEntry(location='./sbgn/hello_world_sbgn_af.png', format='https://purl.org/NET/mediatypes/image/png', \n", "master=False),\n", " ManifestEntry(location='./sedml/hello_world_sedml.sedml', \n", "format='http://identifiers.org/combine.specifications:sed-ml', master=False)]\n", @@ -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" @@ -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" }, @@ -355,7 +417,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.1" + "version": "3.9.16" } }, "nbformat": 4, diff --git a/notebooks/results/combine_hello_world.omex b/notebooks/results/combine_hello_world.omex index 6a6ab23..9ac8838 100644 Binary files a/notebooks/results/combine_hello_world.omex and b/notebooks/results/combine_hello_world.omex differ