diff --git a/notebooks/molstarview.ipynb b/notebooks/molstarview.ipynb index dfe4ce1e..dc0faccc 100644 --- a/notebooks/molstarview.ipynb +++ b/notebooks/molstarview.ipynb @@ -2,10 +2,38 @@ "cells": [ { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "id": "3bef2996-dfbe-4ed7-9816-da54d4a57eb0", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "9ffbadcecf2c413aa0754e80c9b08b37", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "1141c093551641e0b45f0b5f2383307d", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "MolstarView()" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "import nglview as nv\n", "from nglview.widget_molstar import MolstarView\n", @@ -16,32 +44,131 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "id": "b8df28e8-c84d-4bf8-910c-ce2483538a6e", "metadata": {}, "outputs": [], "source": [ - "st = nv.FileStructure(nv.datafiles.PDB)" + "st = nv.FileStructure(nv.datafiles.PDB)\n", + "view.add_structure(st)" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "74bbfaa4-52ee-4d18-be9a-2b002d959940", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'3.9.0'" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "view._molstar_version" + ] + }, + { + "cell_type": "markdown", + "id": "970660fb-8db8-41f3-ac28-ce2730bfc516", + "metadata": {}, + "source": [ + "# Display view again" ] }, { "cell_type": "code", - "execution_count": null, - "id": "8dbe8e02-6ba0-4b17-b81a-4d14d801e30d", + "execution_count": 4, + "id": "b974147d-7761-4511-9640-0b0ec4645ac3", + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "1141c093551641e0b45f0b5f2383307d", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "MolstarView()" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "view" + ] + }, + { + "cell_type": "markdown", + "id": "7afb6cdc-5bcf-4abf-9db3-cf204d624c67", + "metadata": {}, + "source": [ + "# Embed (not working properly yet)" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "id": "d3267052-054f-4d51-812d-e0012e8523c9", "metadata": {}, "outputs": [], "source": [ - "view.add_structure(st)" + "view._js(\"this.getState()\")" ] }, { "cell_type": "code", - "execution_count": null, - "id": "74bbfaa4-52ee-4d18-be9a-2b002d959940", + "execution_count": 26, + "id": "5b5e6df6-a3c2-4e31-817e-cd8b4bd344b4", "metadata": {}, "outputs": [], "source": [ - "view._molstar_version" + "nv.write_html('index.html', view)" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "id": "9fbe9a38-d165-4636-ab2d-53dd3c83b035", + "metadata": {}, + "outputs": [], + "source": [ + "!open index.html" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "id": "ebe3e41b-a4cd-4ffe-be1f-a2568fa62144", + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "ff10e43f5a5a48a39f6486e0af7f0d54", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "NGLWidget()" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "nv.NGLWidget(st)" ] } ],