diff --git a/17_regular_expressions.ipynb b/16_regular_expressions.ipynb similarity index 100% rename from 17_regular_expressions.ipynb rename to 16_regular_expressions.ipynb diff --git a/16_viewing_molecules.ipynb b/16_viewing_molecules.ipynb deleted file mode 100644 index afa355c..0000000 --- a/16_viewing_molecules.ipynb +++ /dev/null @@ -1,153 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Viewing Molecules\n", - "\n", - "[nglview](http://nglviewer.org/nglview/latest/api.html) is an extremely powerful and capable 3D molecule view that runs within a web browser. It supports complex visualisations of molecules from a range of file formats, and can even be used to view trajectories. It provides a full framework for building 3D molecular visualisation into your Jupyter notebooks or websites.\n", - "\n", - "While nglview is very powerful, that power and flexibility can be a little daunting for newcomers. " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import nglview as nv\n", - "view = nv.show_file(\"data/dioxin.pdb\")\n", - "view\n", - "view.display(gui=True)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The above code has used nglview to load the molecule contained in `dioxin.pdb`. This is then rendered using nglview. The above nglview interface allows you to rotate the molecule (left click and drag), zoom in and out (pinch or scroll up or down) and translate (right click and drag, or control+click on a Mac).\n", - "\n", - "Try moving and rotating the molecule. If you lose the molecule, click the \"Center\" button in the General tab to recenter the molecule.\n", - "\n", - "![Simple molecule view](images/view_move.jpeg)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The nglview `show_file` function has done two things:\n", - "\n", - "* it first loaded the molecule(s) from the file,\n", - "* and it then rendered them\n", - "\n", - "Loading molecules can take a long time and use a lot of memory. To prevent you from having to repeatedly load molecules, the `show_file` function has returned a view object that can be re-used. To see how to use it, use python's help..." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "help(view)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "As you can see, we can use `view` to view all of the loaded molecules again, without having to reload them." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "scrolled": false - }, - "outputs": [], - "source": [ - "view\n", - "view.display(gui=True)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "You can change the representation of the molecule by clicking on the \"Representation\" tab. First click the \"Remove\" icon to remove the current representation. Then click the drop-down representation box to choose another representation (e.g. \"spacefill\"). Then click the \"Add\" icon to add that representation. Experiment with adding and removing different representations.\n", - "\n", - "![Different representations](images/view_representation.jpeg)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Loading lots of molecules\n", - "\n", - "nglview isn't just limited to viewing small molecules. It also works really well as a viewer for large molecular systems. It (sometimes) is sufficiently clever to select appropriate representations for the molecules being loaded.\n", - "\n", - "For example, view the protein-ligand complex in `data/complex.pdb`" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "scrolled": false - }, - "outputs": [], - "source": [ - "v = nv.show_file(\"data/complex.pdb\")\n", - "v\n", - "v.display(gui=True)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "In this case, nglview has automatically selected a cartoon representation for the protein and a ball and stick representation for the ligand.\n", - "\n", - "You can achieve this yourself by using selections to set different representation for different molecules (or parts of molecules). First, delete the default representations by repeatedly clicking the \"Remove\" button in the representations tab. Once you have removed all of them, we will add a new representation. Select the type as surface, and then type \"protein\" into the selection box (which starts off with a \"*\" in it).\n", - "\n", - "![Select protein](images/view_protein.jpeg)\n", - "\n", - "Click \"Add\". After some time thinking, nglview will show you a surface representation of the protein.\n", - "\n", - "Next, add a \"spacefill\" representation to the ligand. The ligand residue is called \"LIG\", so to do this, select \"spacefill\", type \"LIG\" into the selection box, and then click add. You should now see the ligand neatly bound into the protein.\n", - "\n", - "![Select ligand](images/view_ligand.jpeg)\n", - "\n", - "The selection box can be used to select proteins (\"protein\"), water (\"water\"), everything (\"*\") or residues by name (e.g. \"LIG\") or number (e.g. \"35\"). Play around creating different selections and representations. For example, create a \"point\" representation for water, a \"tube\" representation of the protein and a \"licorice\" representation of all alanine residues. Note - you can control the opacity (level of transparency) of a representation by selecting the representation in the drop down box and changing the \"opacity\" slider in the \"Parameters\" tab - see below. You can also change things like the colour scheme of the representation in this \"Parameters\" tab\n", - "\n", - "![Opacity](images/view_opacity.jpeg)" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.1.-1" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/answers/17_regular_expressions.ipynb b/answers/16_regular_expressions.ipynb similarity index 100% rename from answers/17_regular_expressions.ipynb rename to answers/16_regular_expressions.ipynb diff --git a/answers/16_viewing_molecules.ipynb b/answers/16_viewing_molecules.ipynb deleted file mode 100644 index 0ba2b14..0000000 --- a/answers/16_viewing_molecules.ipynb +++ /dev/null @@ -1,823 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Viewing Molecules\n", - "\n", - "[nglview](http://nglviewer.org/nglview/latest/api.html) is an extremely powerful and capable 3D molecule view that runs within a web browser. It supports complex visualisations of molecules from a range of file formats, and can even be used to view trajectories. It provides a full framework for building 3D molecular visualisation into your Jupyter notebooks or websites.\n", - "\n", - "While nglview is very powerful, that power and flexibility can be a little daunting for newcomers. [BioSimSpace](https://biosimspace.org) is a project that provides easy-to-use wrappers around common molecular simulation tasks. One such task is viewing molecules. BioSimSpace provides the function `viewMolecules` that uses [nglview](http://nglviewer.org/nglview/latest/api.html) to do exactly that :-)" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "scrolled": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Reading molecules from '['data/dioxin.pdb']'\n", - "Rendering the molecules...\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "b1b80ae274d2498fb56adf60b281387d", - "version_major": 2, - "version_minor": 0 - }, - "text/html": [ - "

Failed to display Jupyter Widget of type NGLWidget.

\n", - "

\n", - " If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n", - " that the widgets JavaScript is still loading. If this message persists, it\n", - " likely means that the widgets JavaScript library is either not installed or\n", - " not enabled. See the Jupyter\n", - " Widgets Documentation for setup instructions.\n", - "

\n", - "

\n", - " If you're reading this message in another frontend (for example, a static\n", - " rendering on GitHub or NBViewer),\n", - " it may mean that your frontend doesn't currently support widgets.\n", - "

\n" - ], - "text/plain": [ - "NGLWidget()" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "2b5cf136894b4abfac97fc04749484e3", - "version_major": 2, - "version_minor": 0 - }, - "text/html": [ - "

Failed to display Jupyter Widget of type Tab.

\n", - "

\n", - " If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n", - " that the widgets JavaScript is still loading. If this message persists, it\n", - " likely means that the widgets JavaScript library is either not installed or\n", - " not enabled. See the Jupyter\n", - " Widgets Documentation for setup instructions.\n", - "

\n", - "

\n", - " If you're reading this message in another frontend (for example, a static\n", - " rendering on GitHub or NBViewer),\n", - " it may mean that your frontend doesn't currently support widgets.\n", - "

\n" - ], - "text/plain": [ - "Tab(children=(Box(children=(Box(children=(Box(children=(Label(value='step'), IntSlider(value=1, min=-100)), layout=Layout(display='flex', flex_flow='row', justify_content='space-between')), Box(children=(Label(value='delay'), IntSlider(value=100, max=1000, min=10)), layout=Layout(display='flex', flex_flow='row', justify_content='space-between')), Box(children=(Label(value='background'), ColorPicker(value='white')), layout=Layout(display='flex', flex_flow='row', justify_content='space-between')), Box(children=(Label(value='camera'), Dropdown(options=('perspective', 'orthographic'), value='perspective')), layout=Layout(display='flex', flex_flow='row', justify_content='space-between')), Box(children=(Label(value=''), HBox(children=(ToggleButton(value=False, description='Smoothing', tooltip='smoothing trajectory'), Button(description=' Center', icon='bullseye', style=ButtonStyle()), Button(description=' Screenshot', icon='camera', style=ButtonStyle()), Button(description='qtconsole', style=ButtonStyle(), tooltip='pop up qtconsole')), layout=Layout(flex='1 1 auto', width='auto'))), layout=Layout(display='flex', flex_flow='row', justify_content='space-between'))), layout=Layout(align_items='stretch', display='flex', flex_flow='column', width='100%')),)), Box(), Box(), Box(), Box(), Box()), layout=Layout(align_items='stretch', align_self='center'), _titles={'4': 'Extra', '5': 'Help', '0': 'General', '2': 'Preference', '3': 'Theme', '1': 'Representation'})" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "from BioSimSpace import viewMolecules\n", - "v = viewMolecules(\"data/dioxin.pdb\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The above code has use the molecule file parsers built into BioSimSpace to load the molecule contained in `dioxin.pdb`. This is then rendered using nglview. The above nglview interface allows you to rotate the molecule (left click and drag), zoom in and out (pinch or scroll up or down) and translate (right click and drag, or control+click on a Mac).\n", - "\n", - "Try moving and rotating the molecule. If you lose the molecule, click the \"Center\" button in the General tab to recenter the molecule.\n", - "\n", - "![Simple molecule view](images/view_move.jpeg)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The BioSimSpace `viewMolecules` function has done two things:\n", - "\n", - "* it first loaded the molecule(s) from the file,\n", - "* and it then rendered them\n", - "\n", - "Loading molecules can take a long time and use a lot of memory. To prevent you from having to repeatedly load molecules, the `viewMolecules` function has returned a view object that can be re-used. To see how to use it, use python's help..." - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Help on View in module BioSimSpace.Notebook.view object:\n", - "\n", - "class View(builtins.object)\n", - " | A class for handling interactive molecular visualisations.\n", - " | \n", - " | Methods defined here:\n", - " | \n", - " | __init__(self, handle)\n", - " | Constructor.\n", - " | \n", - " | Positional arguments:\n", - " | \n", - " | handle -- A handle to a Sire.System or BioSimSpace.Process object.\n", - " | \n", - " | molecule(self, index=0, gui=True)\n", - " | View a specific molecule.\n", - " | \n", - " | Keyword arguments:\n", - " | \n", - " | index -- The molecule index.\n", - " | gui -- Whether to display the gui.\n", - " | \n", - " | molecules(self, indices=None, gui=True)\n", - " | View specific molecules.\n", - " | \n", - " | Keyword arguments:\n", - " | \n", - " | indices -- A list of molecule indices.\n", - " | gui -- Whether to display the gui.\n", - " | \n", - " | nViews(self)\n", - " | Return the number of views.\n", - " | \n", - " | reload(self, index=None, gui=True)\n", - " | Reload a particular view.\n", - " | \n", - " | Keyword arguments:\n", - " | \n", - " | index -- The view index.\n", - " | gui -- Whether to display the gui.\n", - " | \n", - " | reset(self)\n", - " | Reset the object, clearing all view files.\n", - " | \n", - " | savePDB(self, file, index=None)\n", - " | Save a specific view as a PDB file.\n", - " | \n", - " | Positional arguments:\n", - " | \n", - " | file -- The name of the file to write to.\n", - " | \n", - " | Keyword arguments:\n", - " | \n", - " | index -- The view index.\n", - " | \n", - " | system(self, gui=True)\n", - " | View the entire molecular system.\n", - " | \n", - " | Keyword arguments:\n", - " | \n", - " | gui -- Whether to display the gui.\n", - " | \n", - " | ----------------------------------------------------------------------\n", - " | Data descriptors defined here:\n", - " | \n", - " | __dict__\n", - " | dictionary for instance variables (if defined)\n", - " | \n", - " | __weakref__\n", - " | list of weak references to the object (if defined)\n", - "\n" - ] - } - ], - "source": [ - "help(v)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "As you can see, we can use `v.system()` to view all of the loaded molecules again, without having to reload them." - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "scrolled": false - }, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "b0d9db048ddf436aa3a74f9bb185ff75", - "version_major": 2, - "version_minor": 0 - }, - "text/html": [ - "

Failed to display Jupyter Widget of type NGLWidget.

\n", - "

\n", - " If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n", - " that the widgets JavaScript is still loading. If this message persists, it\n", - " likely means that the widgets JavaScript library is either not installed or\n", - " not enabled. See the Jupyter\n", - " Widgets Documentation for setup instructions.\n", - "

\n", - "

\n", - " If you're reading this message in another frontend (for example, a static\n", - " rendering on GitHub or NBViewer),\n", - " it may mean that your frontend doesn't currently support widgets.\n", - "

\n" - ], - "text/plain": [ - "NGLWidget()" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "5baef0726820428abc4341cc3d4e1afe", - "version_major": 2, - "version_minor": 0 - }, - "text/html": [ - "

Failed to display Jupyter Widget of type Tab.

\n", - "

\n", - " If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n", - " that the widgets JavaScript is still loading. If this message persists, it\n", - " likely means that the widgets JavaScript library is either not installed or\n", - " not enabled. See the Jupyter\n", - " Widgets Documentation for setup instructions.\n", - "

\n", - "

\n", - " If you're reading this message in another frontend (for example, a static\n", - " rendering on GitHub or NBViewer),\n", - " it may mean that your frontend doesn't currently support widgets.\n", - "

\n" - ], - "text/plain": [ - "Tab(children=(Box(children=(Box(children=(Box(children=(Label(value='step'), IntSlider(value=1, min=-100)), layout=Layout(display='flex', flex_flow='row', justify_content='space-between')), Box(children=(Label(value='delay'), IntSlider(value=100, max=1000, min=10)), layout=Layout(display='flex', flex_flow='row', justify_content='space-between')), Box(children=(Label(value='background'), ColorPicker(value='white')), layout=Layout(display='flex', flex_flow='row', justify_content='space-between')), Box(children=(Label(value='camera'), Dropdown(options=('perspective', 'orthographic'), value='perspective')), layout=Layout(display='flex', flex_flow='row', justify_content='space-between')), Box(children=(Label(value=''), HBox(children=(ToggleButton(value=False, description='Smoothing', tooltip='smoothing trajectory'), Button(description=' Center', icon='bullseye', style=ButtonStyle()), Button(description=' Screenshot', icon='camera', style=ButtonStyle()), Button(description='qtconsole', style=ButtonStyle(), tooltip='pop up qtconsole')), layout=Layout(flex='1 1 auto', width='auto'))), layout=Layout(display='flex', flex_flow='row', justify_content='space-between'))), layout=Layout(align_items='stretch', display='flex', flex_flow='column', width='100%')),)), Box(), Box(), Box(), Box(), Box()), layout=Layout(align_items='stretch', align_self='center'), _titles={'4': 'Extra', '5': 'Help', '0': 'General', '2': 'Preference', '3': 'Theme', '1': 'Representation'})" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "v.system()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "You can change the representation of the molecule by clicking on the \"Representation\" tab. First click the \"Remove\" icon to remove the current representation. Then click the drop-down representation box to choose another representation (e.g. \"spacefill\"). Then click the \"Add\" icon to add that representation. Experiment with adding and removing different representations.\n", - "\n", - "![Different representations](images/view_representation.jpeg)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Loading lots of molecules\n", - "\n", - "nglview isn't just limited to viewing small molecules. It also works really well as a viewer for large molecular systems. It (sometimes) is sufficiently clever to select appropriate representations for the molecules being loaded.\n", - "\n", - "For example, view the protein-ligand complex in `data/complex.pdb`" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "scrolled": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Reading molecules from '['data/complex.pdb']'\n", - "Rendering the molecules...\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "ce0e7b1f4446425b8437bcbea3be24fb", - "version_major": 2, - "version_minor": 0 - }, - "text/html": [ - "

Failed to display Jupyter Widget of type NGLWidget.

\n", - "

\n", - " If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n", - " that the widgets JavaScript is still loading. If this message persists, it\n", - " likely means that the widgets JavaScript library is either not installed or\n", - " not enabled. See the Jupyter\n", - " Widgets Documentation for setup instructions.\n", - "

\n", - "

\n", - " If you're reading this message in another frontend (for example, a static\n", - " rendering on GitHub or NBViewer),\n", - " it may mean that your frontend doesn't currently support widgets.\n", - "

\n" - ], - "text/plain": [ - "NGLWidget()" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "01db6e5af5644c8a929eac214a7904b0", - "version_major": 2, - "version_minor": 0 - }, - "text/html": [ - "

Failed to display Jupyter Widget of type Tab.

\n", - "

\n", - " If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n", - " that the widgets JavaScript is still loading. If this message persists, it\n", - " likely means that the widgets JavaScript library is either not installed or\n", - " not enabled. See the Jupyter\n", - " Widgets Documentation for setup instructions.\n", - "

\n", - "

\n", - " If you're reading this message in another frontend (for example, a static\n", - " rendering on GitHub or NBViewer),\n", - " it may mean that your frontend doesn't currently support widgets.\n", - "

\n" - ], - "text/plain": [ - "Tab(children=(Box(children=(Box(children=(Box(children=(Label(value='step'), IntSlider(value=1, min=-100)), layout=Layout(display='flex', flex_flow='row', justify_content='space-between')), Box(children=(Label(value='delay'), IntSlider(value=100, max=1000, min=10)), layout=Layout(display='flex', flex_flow='row', justify_content='space-between')), Box(children=(Label(value='background'), ColorPicker(value='white')), layout=Layout(display='flex', flex_flow='row', justify_content='space-between')), Box(children=(Label(value='camera'), Dropdown(options=('perspective', 'orthographic'), value='perspective')), layout=Layout(display='flex', flex_flow='row', justify_content='space-between')), Box(children=(Label(value=''), HBox(children=(ToggleButton(value=False, description='Smoothing', tooltip='smoothing trajectory'), Button(description=' Center', icon='bullseye', style=ButtonStyle()), Button(description=' Screenshot', icon='camera', style=ButtonStyle()), Button(description='qtconsole', style=ButtonStyle(), tooltip='pop up qtconsole')), layout=Layout(flex='1 1 auto', width='auto'))), layout=Layout(display='flex', flex_flow='row', justify_content='space-between'))), layout=Layout(align_items='stretch', display='flex', flex_flow='column', width='100%')),)), Box(), Box(), Box(), Box(), Box()), layout=Layout(align_items='stretch', align_self='center'), _titles={'4': 'Extra', '5': 'Help', '0': 'General', '2': 'Preference', '3': 'Theme', '1': 'Representation'})" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "v = viewMolecules(\"data/complex.pdb\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "In this case, nglview has automatically selected a cartoon representation for the protein and a ball and stick representation for the ligand.\n", - "\n", - "You can achieve this yourself by using selections to set different representation for different molecules (or parts of molecules). First, delete the default representations by repeatedly clicking the \"Remove\" button in the representations tab. Once you have removed all of them, we will add a new representation. Select the type as surface, and then type \"protein\" into the selection box (which starts off with a \"*\" in it).\n", - "\n", - "![Select protein](images/view_protein.jpeg)\n", - "\n", - "Click \"Add\". After some time thinking, nglview will show you a surface representation of the protein.\n", - "\n", - "Next, add a \"spacefill\" representation to the ligand. The ligand residue is called \"LIG\", so to do this, select \"spacefill\", type \"LIG\" into the selection box, and then click add. You should now see the ligand neatly bound into the protein.\n", - "\n", - "![Select ligand](images/view_ligand.jpeg)\n", - "\n", - "The selection box can be used to select proteins (\"protein\"), water (\"water\"), everything (\"*\") or residues by name (e.g. \"LIG\") or number (e.g. \"35\"). Play around creating different selections and representations. For example, create a \"point\" representation for water, a \"tube\" representation of the protein and a \"licorice\" representation of all alanine residues. Note - you can control the opacity (level of transparency) of a representation by selecting the representation in the drop down box and changing the \"opacity\" slider in the \"Parameters\" tab - see below. You can also change things like the colour scheme of the representation in this \"Parameters\" tab\n", - "\n", - "![Opacity](images/view_opacity.jpeg)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Viewing individual molecules\n", - "\n", - "The view object returned by BioSimSpace can be used to view specific molecules from the file. To do this, use the `molecules` function. This takes a list of indicies of the molecules you want to view. For example, to view the first molecule (molecule at index 0) type;" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "5513fe3c630a4beca6974db4c7b28a55", - "version_major": 2, - "version_minor": 0 - }, - "text/html": [ - "

Failed to display Jupyter Widget of type NGLWidget.

\n", - "

\n", - " If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n", - " that the widgets JavaScript is still loading. If this message persists, it\n", - " likely means that the widgets JavaScript library is either not installed or\n", - " not enabled. See the Jupyter\n", - " Widgets Documentation for setup instructions.\n", - "

\n", - "

\n", - " If you're reading this message in another frontend (for example, a static\n", - " rendering on GitHub or NBViewer),\n", - " it may mean that your frontend doesn't currently support widgets.\n", - "

\n" - ], - "text/plain": [ - "NGLWidget()" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "a2255f5691274ee2bfeb6e736e3fdcbe", - "version_major": 2, - "version_minor": 0 - }, - "text/html": [ - "

Failed to display Jupyter Widget of type Tab.

\n", - "

\n", - " If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n", - " that the widgets JavaScript is still loading. If this message persists, it\n", - " likely means that the widgets JavaScript library is either not installed or\n", - " not enabled. See the Jupyter\n", - " Widgets Documentation for setup instructions.\n", - "

\n", - "

\n", - " If you're reading this message in another frontend (for example, a static\n", - " rendering on GitHub or NBViewer),\n", - " it may mean that your frontend doesn't currently support widgets.\n", - "

\n" - ], - "text/plain": [ - "Tab(children=(Box(children=(Box(children=(Box(children=(Label(value='step'), IntSlider(value=1, min=-100)), layout=Layout(display='flex', flex_flow='row', justify_content='space-between')), Box(children=(Label(value='delay'), IntSlider(value=100, max=1000, min=10)), layout=Layout(display='flex', flex_flow='row', justify_content='space-between')), Box(children=(Label(value='background'), ColorPicker(value='white')), layout=Layout(display='flex', flex_flow='row', justify_content='space-between')), Box(children=(Label(value='camera'), Dropdown(options=('perspective', 'orthographic'), value='perspective')), layout=Layout(display='flex', flex_flow='row', justify_content='space-between')), Box(children=(Label(value=''), HBox(children=(ToggleButton(value=False, description='Smoothing', tooltip='smoothing trajectory'), Button(description=' Center', icon='bullseye', style=ButtonStyle()), Button(description=' Screenshot', icon='camera', style=ButtonStyle()), Button(description='qtconsole', style=ButtonStyle(), tooltip='pop up qtconsole')), layout=Layout(flex='1 1 auto', width='auto'))), layout=Layout(display='flex', flex_flow='row', justify_content='space-between'))), layout=Layout(align_items='stretch', display='flex', flex_flow='column', width='100%')),)), Box(), Box(), Box(), Box(), Box()), layout=Layout(align_items='stretch', align_self='center'), _titles={'4': 'Extra', '5': 'Help', '0': 'General', '2': 'Preference', '3': 'Theme', '1': 'Representation'})" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "v.molecules([0])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "while to view molecules 100-1000 use the below code (noting that you may need to add a \"ball and stick\" represntation in case nglview automatically hides the water molecules)." - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "74dd90ca0f9c43ba8422f43b2e6e7b2e", - "version_major": 2, - "version_minor": 0 - }, - "text/html": [ - "

Failed to display Jupyter Widget of type NGLWidget.

\n", - "

\n", - " If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n", - " that the widgets JavaScript is still loading. If this message persists, it\n", - " likely means that the widgets JavaScript library is either not installed or\n", - " not enabled. See the Jupyter\n", - " Widgets Documentation for setup instructions.\n", - "

\n", - "

\n", - " If you're reading this message in another frontend (for example, a static\n", - " rendering on GitHub or NBViewer),\n", - " it may mean that your frontend doesn't currently support widgets.\n", - "

\n" - ], - "text/plain": [ - "NGLWidget()" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "3ea92594a34f4719a6661746c42c060c", - "version_major": 2, - "version_minor": 0 - }, - "text/html": [ - "

Failed to display Jupyter Widget of type Tab.

\n", - "

\n", - " If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n", - " that the widgets JavaScript is still loading. If this message persists, it\n", - " likely means that the widgets JavaScript library is either not installed or\n", - " not enabled. See the Jupyter\n", - " Widgets Documentation for setup instructions.\n", - "

\n", - "

\n", - " If you're reading this message in another frontend (for example, a static\n", - " rendering on GitHub or NBViewer),\n", - " it may mean that your frontend doesn't currently support widgets.\n", - "

\n" - ], - "text/plain": [ - "Tab(children=(Box(children=(Box(children=(Box(children=(Label(value='step'), IntSlider(value=1, min=-100)), layout=Layout(display='flex', flex_flow='row', justify_content='space-between')), Box(children=(Label(value='delay'), IntSlider(value=100, max=1000, min=10)), layout=Layout(display='flex', flex_flow='row', justify_content='space-between')), Box(children=(Label(value='background'), ColorPicker(value='white')), layout=Layout(display='flex', flex_flow='row', justify_content='space-between')), Box(children=(Label(value='camera'), Dropdown(options=('perspective', 'orthographic'), value='perspective')), layout=Layout(display='flex', flex_flow='row', justify_content='space-between')), Box(children=(Label(value=''), HBox(children=(ToggleButton(value=False, description='Smoothing', tooltip='smoothing trajectory'), Button(description=' Center', icon='bullseye', style=ButtonStyle()), Button(description=' Screenshot', icon='camera', style=ButtonStyle()), Button(description='qtconsole', style=ButtonStyle(), tooltip='pop up qtconsole')), layout=Layout(flex='1 1 auto', width='auto'))), layout=Layout(display='flex', flex_flow='row', justify_content='space-between'))), layout=Layout(align_items='stretch', display='flex', flex_flow='column', width='100%')),)), Box(), Box(), Box(), Box(), Box()), layout=Layout(align_items='stretch', align_self='center'), _titles={'4': 'Extra', '5': 'Help', '0': 'General', '2': 'Preference', '3': 'Theme', '1': 'Representation'})" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "v.molecules( range(100,1000) )" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Loading more complex files\n", - "\n", - "BioSimSpace provides reader and writers for a variety of molecular file formats. Some of these split the molecular data over multiple files, e.g. a topology and coordinate file. To view these, pass all of the necessary files to `viewMolecules` in a list, e.g." - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Reading molecules from '['data/ala.top', 'data/ala.crd']'\n", - "Rendering the molecules...\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "4ec4de19fc9342678a6a39ceba00bcb8", - "version_major": 2, - "version_minor": 0 - }, - "text/html": [ - "

Failed to display Jupyter Widget of type NGLWidget.

\n", - "

\n", - " If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n", - " that the widgets JavaScript is still loading. If this message persists, it\n", - " likely means that the widgets JavaScript library is either not installed or\n", - " not enabled. See the Jupyter\n", - " Widgets Documentation for setup instructions.\n", - "

\n", - "

\n", - " If you're reading this message in another frontend (for example, a static\n", - " rendering on GitHub or NBViewer),\n", - " it may mean that your frontend doesn't currently support widgets.\n", - "

\n" - ], - "text/plain": [ - "NGLWidget()" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "75c1273d51714dd788a8453905f67cff", - "version_major": 2, - "version_minor": 0 - }, - "text/html": [ - "

Failed to display Jupyter Widget of type Tab.

\n", - "

\n", - " If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n", - " that the widgets JavaScript is still loading. If this message persists, it\n", - " likely means that the widgets JavaScript library is either not installed or\n", - " not enabled. See the Jupyter\n", - " Widgets Documentation for setup instructions.\n", - "

\n", - "

\n", - " If you're reading this message in another frontend (for example, a static\n", - " rendering on GitHub or NBViewer),\n", - " it may mean that your frontend doesn't currently support widgets.\n", - "

\n" - ], - "text/plain": [ - "Tab(children=(Box(children=(Box(children=(Box(children=(Label(value='step'), IntSlider(value=1, min=-100)), layout=Layout(display='flex', flex_flow='row', justify_content='space-between')), Box(children=(Label(value='delay'), IntSlider(value=100, max=1000, min=10)), layout=Layout(display='flex', flex_flow='row', justify_content='space-between')), Box(children=(Label(value='background'), ColorPicker(value='white')), layout=Layout(display='flex', flex_flow='row', justify_content='space-between')), Box(children=(Label(value='camera'), Dropdown(options=('perspective', 'orthographic'), value='perspective')), layout=Layout(display='flex', flex_flow='row', justify_content='space-between')), Box(children=(Label(value=''), HBox(children=(ToggleButton(value=False, description='Smoothing', tooltip='smoothing trajectory'), Button(description=' Center', icon='bullseye', style=ButtonStyle()), Button(description=' Screenshot', icon='camera', style=ButtonStyle()), Button(description='qtconsole', style=ButtonStyle(), tooltip='pop up qtconsole')), layout=Layout(flex='1 1 auto', width='auto'))), layout=Layout(display='flex', flex_flow='row', justify_content='space-between'))), layout=Layout(align_items='stretch', display='flex', flex_flow='column', width='100%')),)), Box(), Box(), Box(), Box(), Box()), layout=Layout(align_items='stretch', align_self='center'), _titles={'4': 'Extra', '5': 'Help', '0': 'General', '2': 'Preference', '3': 'Theme', '1': 'Representation'})" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "v = viewMolecules([\"data/ala.top\",\"data/ala.crd\"])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "This can be combined with molecule selection, e.g. to load and view only molecules 0-4 in the file pass the indicies of the molecules you want to view as a second argument to `viewMolecule`, e.g." - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Reading molecules from '['data/ala.top', 'data/ala.crd']'\n", - "Rendering the molecules...\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "d3517c839eb9483ea7e0e7a2e615db4a", - "version_major": 2, - "version_minor": 0 - }, - "text/html": [ - "

Failed to display Jupyter Widget of type NGLWidget.

\n", - "

\n", - " If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n", - " that the widgets JavaScript is still loading. If this message persists, it\n", - " likely means that the widgets JavaScript library is either not installed or\n", - " not enabled. See the Jupyter\n", - " Widgets Documentation for setup instructions.\n", - "

\n", - "

\n", - " If you're reading this message in another frontend (for example, a static\n", - " rendering on GitHub or NBViewer),\n", - " it may mean that your frontend doesn't currently support widgets.\n", - "

\n" - ], - "text/plain": [ - "NGLWidget()" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "6155d2bbd3b64ff29bda0d443d4d67c7", - "version_major": 2, - "version_minor": 0 - }, - "text/html": [ - "

Failed to display Jupyter Widget of type Tab.

\n", - "

\n", - " If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n", - " that the widgets JavaScript is still loading. If this message persists, it\n", - " likely means that the widgets JavaScript library is either not installed or\n", - " not enabled. See the Jupyter\n", - " Widgets Documentation for setup instructions.\n", - "

\n", - "

\n", - " If you're reading this message in another frontend (for example, a static\n", - " rendering on GitHub or NBViewer),\n", - " it may mean that your frontend doesn't currently support widgets.\n", - "

\n" - ], - "text/plain": [ - "Tab(children=(Box(children=(Box(children=(Box(children=(Label(value='step'), IntSlider(value=1, min=-100)), layout=Layout(display='flex', flex_flow='row', justify_content='space-between')), Box(children=(Label(value='delay'), IntSlider(value=100, max=1000, min=10)), layout=Layout(display='flex', flex_flow='row', justify_content='space-between')), Box(children=(Label(value='background'), ColorPicker(value='white')), layout=Layout(display='flex', flex_flow='row', justify_content='space-between')), Box(children=(Label(value='camera'), Dropdown(options=('perspective', 'orthographic'), value='perspective')), layout=Layout(display='flex', flex_flow='row', justify_content='space-between')), Box(children=(Label(value=''), HBox(children=(ToggleButton(value=False, description='Smoothing', tooltip='smoothing trajectory'), Button(description=' Center', icon='bullseye', style=ButtonStyle()), Button(description=' Screenshot', icon='camera', style=ButtonStyle()), Button(description='qtconsole', style=ButtonStyle(), tooltip='pop up qtconsole')), layout=Layout(flex='1 1 auto', width='auto'))), layout=Layout(display='flex', flex_flow='row', justify_content='space-between'))), layout=Layout(align_items='stretch', display='flex', flex_flow='column', width='100%')),)), Box(), Box(), Box(), Box(), Box()), layout=Layout(align_items='stretch', align_self='center'), _titles={'4': 'Extra', '5': 'Help', '0': 'General', '2': 'Preference', '3': 'Theme', '1': 'Representation'})" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "v = viewMolecules([\"data/ala.top\",\"data/ala.crd\"], [0,1,2,3,4])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "(in reality, all molecules are loaded, but only molecules specified by the indicies are viewed. You can still use `v.system()` to view all molecules)" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "a1f8af41e5d547c48589b8f6c6fa54c1", - "version_major": 2, - "version_minor": 0 - }, - "text/html": [ - "

Failed to display Jupyter Widget of type NGLWidget.

\n", - "

\n", - " If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n", - " that the widgets JavaScript is still loading. If this message persists, it\n", - " likely means that the widgets JavaScript library is either not installed or\n", - " not enabled. See the Jupyter\n", - " Widgets Documentation for setup instructions.\n", - "

\n", - "

\n", - " If you're reading this message in another frontend (for example, a static\n", - " rendering on GitHub or NBViewer),\n", - " it may mean that your frontend doesn't currently support widgets.\n", - "

\n" - ], - "text/plain": [ - "NGLWidget()" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "293b0de20781440f86bf7b70a0020e3b", - "version_major": 2, - "version_minor": 0 - }, - "text/html": [ - "

Failed to display Jupyter Widget of type Tab.

\n", - "

\n", - " If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n", - " that the widgets JavaScript is still loading. If this message persists, it\n", - " likely means that the widgets JavaScript library is either not installed or\n", - " not enabled. See the Jupyter\n", - " Widgets Documentation for setup instructions.\n", - "

\n", - "

\n", - " If you're reading this message in another frontend (for example, a static\n", - " rendering on GitHub or NBViewer),\n", - " it may mean that your frontend doesn't currently support widgets.\n", - "

\n" - ], - "text/plain": [ - "Tab(children=(Box(children=(Box(children=(Box(children=(Label(value='step'), IntSlider(value=1, min=-100)), layout=Layout(display='flex', flex_flow='row', justify_content='space-between')), Box(children=(Label(value='delay'), IntSlider(value=100, max=1000, min=10)), layout=Layout(display='flex', flex_flow='row', justify_content='space-between')), Box(children=(Label(value='background'), ColorPicker(value='white')), layout=Layout(display='flex', flex_flow='row', justify_content='space-between')), Box(children=(Label(value='camera'), Dropdown(options=('perspective', 'orthographic'), value='perspective')), layout=Layout(display='flex', flex_flow='row', justify_content='space-between')), Box(children=(Label(value=''), HBox(children=(ToggleButton(value=False, description='Smoothing', tooltip='smoothing trajectory'), Button(description=' Center', icon='bullseye', style=ButtonStyle()), Button(description=' Screenshot', icon='camera', style=ButtonStyle()), Button(description='qtconsole', style=ButtonStyle(), tooltip='pop up qtconsole')), layout=Layout(flex='1 1 auto', width='auto'))), layout=Layout(display='flex', flex_flow='row', justify_content='space-between'))), layout=Layout(align_items='stretch', display='flex', flex_flow='column', width='100%')),)), Box(), Box(), Box(), Box(), Box()), layout=Layout(align_items='stretch', align_self='center'), _titles={'4': 'Extra', '5': 'Help', '0': 'General', '2': 'Preference', '3': 'Theme', '1': 'Representation'})" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "v.system()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.5.2" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -}