{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import bokehmol\n", "\n", "from bokeh.models import ColumnDataSource\n", "from bokeh.plotting import figure" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's start with some dummy data. You can provide input as a simple SMILES string,\n", "a SMILES string containing multiple fragments, or a list of SMILES to display as a grid." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "# example dataset\n", "source = ColumnDataSource(\n", " data=dict(\n", " x=[1, 2, 3, 4, 5],\n", " y=[6, 7, 2, 4, 5],\n", " SMILES=[\n", " [\"O=C1CCCN1C\", \"O=C1CC(C)CN1C\"],\n", " \"c1ccccc1.c1ccccc1O\",\n", " [\"CN1C(=O)N(C)c2ncn(C)c2C1(=O)\", \"O=C1CCCN1C.O=C1CC(C)CN1C\"],\n", " \"C1C(=O)C=C2CCC3C4CCC(C(=O)CO)C4(C)CCC3C2(C)C1\",\n", " \"CC(=O)OC1=CC=CC=C1C(=O)O\",\n", " ]\n", " )\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The easiest way to use `bokehmol` is to import the package, run the `bokehmol.register_alias()` function, and then specify either `rdkit_hover` or `smiles_hover` in the `tools` parameter of the `bokeh` figure." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "bokehmol.register_alias()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This assumes that your `ColumnDataSource` containing your data has a `SMILES` column.\n", "\n", "You can then hover over any glyph on the figure to reveal the corresponding structure:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", " \n", "