{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " \n", " Loading BokehJS ...\n", "
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": "(function(root) {\n function now() {\n return new Date();\n }\n\n const force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\nconst JS_MIME_TYPE = 'application/javascript';\n const HTML_MIME_TYPE = 'text/html';\n const EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n const CLASS_NAME = 'output_bokeh rendered_html';\n\n /**\n * Render data to the DOM node\n */\n function render(props, node) {\n const script = document.createElement(\"script\");\n node.appendChild(script);\n }\n\n /**\n * Handle when an output is cleared or removed\n */\n function handleClearOutput(event, handle) {\n const cell = handle.cell;\n\n const id = cell.output_area._bokeh_element_id;\n const server_id = cell.output_area._bokeh_server_id;\n // Clean up Bokeh references\n if (id != null && id in Bokeh.index) {\n Bokeh.index[id].model.document.clear();\n delete Bokeh.index[id];\n }\n\n if (server_id !== undefined) {\n // Clean up Bokeh references\n const cmd_clean = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n cell.notebook.kernel.execute(cmd_clean, {\n iopub: {\n output: function(msg) {\n const id = msg.content.text.trim();\n if (id in Bokeh.index) {\n Bokeh.index[id].model.document.clear();\n delete Bokeh.index[id];\n }\n }\n }\n });\n // Destroy server and session\n const cmd_destroy = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n cell.notebook.kernel.execute(cmd_destroy);\n }\n }\n\n /**\n * Handle when a new output is added\n */\n function handleAddOutput(event, handle) {\n const output_area = handle.output_area;\n const output = handle.output;\n\n // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n if ((output.output_type != \"display_data\") || (!Object.prototype.hasOwnProperty.call(output.data, EXEC_MIME_TYPE))) {\n return\n }\n\n const toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n\n if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n // store reference to embed id on output_area\n output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n }\n if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n const bk_div = document.createElement(\"div\");\n bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n const script_attrs = bk_div.children[0].attributes;\n for (let i = 0; i < script_attrs.length; i++) {\n toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n }\n // store reference to server id on output_area\n output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n }\n }\n\n function register_renderer(events, OutputArea) {\n\n function append_mime(data, metadata, element) {\n // create a DOM node to render to\n const toinsert = this.create_output_subarea(\n metadata,\n CLASS_NAME,\n EXEC_MIME_TYPE\n );\n this.keyboard_manager.register_events(toinsert);\n // Render to node\n const props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n render(props, toinsert[toinsert.length - 1]);\n element.append(toinsert);\n return toinsert\n }\n\n /* Handle when an output is cleared or removed */\n events.on('clear_output.CodeCell', handleClearOutput);\n events.on('delete.Cell', handleClearOutput);\n\n /* Handle when a new output is added */\n events.on('output_added.OutputArea', handleAddOutput);\n\n /**\n * Register the mime type and append_mime function with output_area\n */\n OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n /* Is output safe? */\n safe: true,\n /* Index of renderer in `output_area.display_order` */\n index: 0\n });\n }\n\n // register the mime type if in Jupyter Notebook environment and previously unregistered\n if (root.Jupyter !== undefined) {\n const events = require('base/js/events');\n const OutputArea = require('notebook/js/outputarea').OutputArea;\n\n if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n register_renderer(events, OutputArea);\n }\n }\n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n const NB_LOAD_WARNING = {'data': {'text/html':\n \"
\\n\"+\n \"

\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"

\\n\"+\n \"\\n\"+\n \"\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"\\n\"+\n \"
\"}};\n\n function display_loaded() {\n const el = document.getElementById(\"d8af742b-d92e-41af-90c9-a7d0fe1cb348\");\n if (el != null) {\n el.textContent = \"BokehJS is loading...\";\n }\n if (root.Bokeh !== undefined) {\n if (el != null) {\n el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(display_loaded, 100)\n }\n }\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error(url) {\n console.error(\"failed to load \" + url);\n }\n\n for (let i = 0; i < css_urls.length; i++) {\n const url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n for (let i = 0; i < js_urls.length; i++) {\n const url = js_urls[i];\n const element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.async = false;\n element.src = url;\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n const js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-3.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.1.1.min.js\"];\n const css_urls = [];\n\n const inline_js = [ function(Bokeh) {\n inject_raw_css(\"/*!\\n * Copyright (c) 2012 - 2023, Anaconda, Inc., and Bokeh Contributors\\n * All rights reserved.\\n * \\n * Redistribution and use in source and binary forms, with or without modification,\\n * are permitted provided that the following conditions are met:\\n * \\n * Redistributions of source code must retain the above copyright notice,\\n * this list of conditions and the following disclaimer.\\n * \\n * Redistributions in binary form must reproduce the above copyright notice,\\n * this list of conditions and the following disclaimer in the documentation\\n * and/or other materials provided with the distribution.\\n * \\n * Neither the name of Anaconda nor the names of any contributors\\n * may be used to endorse or promote products derived from this software\\n * without specific prior written permission.\\n * \\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \\\"AS IS\\\"\\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\\n * THE POSSIBILITY OF SUCH DAMAGE.\\n */\\n(function(root, factory) {\\n factory(root[\\\"Bokeh\\\"], undefined);\\n})(this, function(Bokeh, version) {\\n let define;\\n return (function(modules, entry, aliases, externals) {\\n const bokeh = typeof Bokeh !== \\\"undefined\\\" \\u0026\\u0026 (version != null ? Bokeh[version] : Bokeh);\\n if (bokeh != null) {\\n return bokeh.register_plugin(modules, entry, aliases);\\n } else {\\n throw new Error(\\\"Cannot find Bokeh \\\" + version + \\\". You have to load it prior to loading plugins.\\\");\\n }\\n })\\n({\\n\\\"af61f89f3f\\\": function _(e,o,s,t,b){t();const i=e(\\\"tslib\\\").__importStar(e(\\\"e6378f9e46\\\"));s.bokehmol=i;(0,e(\\\"@bokehjs/base\\\").register_models)(i)},\\n\\\"e6378f9e46\\\": function _(e,r,a,t,o){t(),o(\\\"BaseFormatter\\\",e(\\\"ed5e284034\\\").BaseFormatter),o(\\\"BaseHover\\\",e(\\\"a3142aba83\\\").BaseHover),o(\\\"RDKitFormatter\\\",e(\\\"1d76839fb6\\\").RDKitFormatter),o(\\\"RDKitHover\\\",e(\\\"59dcea9792\\\").RDKitHover),o(\\\"SmilesDrawerFormatter\\\",e(\\\"1ebfefbb31\\\").SmilesDrawerFormatter),o(\\\"SmilesDrawerHover\\\",e(\\\"54f47c3230\\\").SmilesDrawerHover)},\\n\\\"ed5e284034\\\": function _(e,t,o,s,r){var _;s();const a=e(\\\"@bokehjs/models/tools/inspectors/customjs_hover\\\");class m extends a.CustomJSHover{constructor(e){super(e)}draw_svg(e){return\\\"\\\"}format(e,t,o){return this.draw_svg(e)}}o.BaseFormatter=m,_=m,m.__name__=\\\"BaseFormatter\\\",m.__module__=\\\"bokehmol.models.base_formatter\\\",_.define((({Int:e})=\\u003e({width:[e,160],height:[e,120]})))},\\n\\\"a3142aba83\\\": function _(i,e,o,I,t){var s;I();const A=i(\\\"@bokehjs/core/dom\\\"),l=i(\\\"@bokehjs/core/util/templating\\\"),r=i(\\\"@bokehjs/core/util/types\\\"),h=i(\\\"@bokehjs/models/tools/inspectors/hover_tool\\\"),n=i(\\\"@bokehjs/styles/icons.css\\\");class a extends h.HoverToolView{_render_tooltips(i,e){var o;const{tooltips:I,smiles_column:t}=this.model,s=e.index;let h=I;if(null===h\\u0026\\u0026(h=\\\"\\\"),!(0,r.isString)(h)){const I=null!==(o=this._template_el)\\u0026\\u0026void 0!==o?o:this._template_el=this._create_template(h);h=this._render_template(I,h,i,e).outerHTML}const n=\\\"\\u003cdiv\\u003e@\\\"+t+\\\"{custom}\\u003c/div\\u003e\\\"+h,a=(0,l.replace_placeholders)({html:n},i,s,this.model.formatters,e);return(0,A.div)(a)}}o.BaseHoverView=a,a.__name__=\\\"BaseHoverView\\\";class _ extends h.HoverTool{get computed_icon(){return\\\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAMAAADzapwJAAAAt1BMVEUAAAAAAAArKyskJCQcHBwrKyscHBwmJiYjIyMhISEgICAfHx8dHR0kJCQiIiIhISEhISEgICAkJCQkJCQjIyMiIiIiIiIhISEkJCQjIyMiIiIiIiIjIyMjIyMkJCQjIyMiIiIkJCQhISEjIyMiIiIiIiIiIiIkJCQjIyMiIiIiIiIiIiIiIiIhISEjIyMjIyMiIiIiIiIjIyMiIiIiIiIhISEiIiIiIiIiIiIiIiIhISEjIyP///9o30WSAAAAPHRSTlMAAQYHCQwSFBYXGBkaKy0uLzAxMjM0NTY5UVJTV1hdYHJyc3V3eHmBk5SVlpeZmpucnaqtrrCytLa7wMBTv07WAAAAAWJLR0Q8p2phzwAAAKRJREFUGBmtwQkagUAAgNF/ZAtZo2yRIrusofvfi+ab0gG8xx85gS8FDjlabJuS/db4WQ1RRksy+p3ZRZpxbZA6t8gYJxRzTc7WQhKPCjnlSJDwXEIdRQ9xPRKeS+eAcurjeiTEo8JhgNTdU44EUm9D9SlIRDV2FkrYZjHhazrHOJLS7xReRSi+CtzqZJYjmiUoNRn7/GixbUr2WyPHCXwpcPifD0UBD3u/QqniAAAAAElFTkSuQmCC\\\"}constructor(i){super(i),this.tool_icon=n.tool_icon_hover}}o.BaseHover=_,s=_,_.__name__=\\\"BaseHover\\\",_.__module__=\\\"bokehmol.models.base_hover\\\",s.prototype.default_view=a,s.define((({String:i,Number:e})=\\u003e({smiles_column:[i,\\\"SMILES\\\"],width:[e,160],height:[e,120]}))),s.override({tooltips:[]})},\\n\\\"1d76839fb6\\\": function _(t,i,e,s,o){var r;s();const n=t(\\\"ed5e284034\\\");class _ extends n.BaseFormatter{constructor(t){super(t)}initialize(){super.initialize(),initRDKitModule().then((t=\\u003e{this.RDKitModule=t,console.log(\\\"RDKit version: \\\"+t.version())}))}_setup_options(){return this.RDKitModule.prefer_coordgen(this.prefer_coordgen),this.json_mol_opts=JSON.stringify({removeHs:this.remove_hs,sanitize:this.sanitize,kekulize:this.kekulize}),this.json_draw_opts=JSON.stringify(Object.assign({width:this.width,height:this.height},this.draw_options)),this.json_draw_opts}draw_svg(t){var i;const e=null!==(i=this.json_draw_opts)\\u0026\\u0026void 0!==i?i:this._setup_options(),s=this.RDKitModule.get_mol(t,this.json_mol_opts);if(null!==s\\u0026\\u0026s.is_valid()){const t=s.get_svg_with_highlights(e);return s.delete(),t}return super.draw_svg(t)}}e.RDKitFormatter=_,r=_,_.__name__=\\\"RDKitFormatter\\\",_.__module__=\\\"bokehmol.models.rdkit_formatter\\\",r.define((({Boolean:t,Dict:i,Unknown:e})=\\u003e({prefer_coordgen:[t,!0],remove_hs:[t,!0],sanitize:[t,!0],kekulize:[t,!0],draw_options:[i(e),{}]})))},\\n\\\"59dcea9792\\\": function _(A,e,o,i,t){var r;i();const s=A(\\\"a3142aba83\\\"),n=A(\\\"1d76839fb6\\\");class a extends s.BaseHoverView{initialize(){super.initialize();const{formatters:A,smiles_column:e,width:o,height:i,prefer_coordgen:t,remove_hs:r,sanitize:s,kekulize:a,draw_options:d}=this.model;A[\\\"@\\\"+e]=new n.RDKitFormatter({width:o,height:i,prefer_coordgen:t,remove_hs:r,sanitize:s,kekulize:a,draw_options:d})}}o.RDKitHoverView=a,a.__name__=\\\"RDKitHoverView\\\";class d extends s.BaseHover{get computed_icon(){return\\\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAFVBMVEXc3NwUFP8UPP9kZP+MjP+0tP////9ZXZotAAAAAXRSTlMAQObYZgAAAAFiS0dEBmFmuH0AAAAHdElNRQfmAwsPGi+MyC9RAAAAQElEQVQI12NgQABGQUEBMENISUkRLKBsbGwEEhIyBgJFsICLC0iIUdnExcUZwnANQWfApKCK4doRBsKtQFgKAQC5Ww1JEHSEkAAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyMi0wMy0xMVQxNToyNjo0NyswMDowMDzr2J4AAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjItMDMtMTFUMTU6MjY6NDcrMDA6MDBNtmAiAAAAAElFTkSuQmCC\\\"}constructor(A){super(A),this.tool_name=\\\"RDKit Hover\\\"}}o.RDKitHover=d,r=d,d.__name__=\\\"RDKitHover\\\",d.__module__=\\\"bokehmol.models.rdkit_hover\\\",r.prototype.default_view=a,r.define((({Boolean:A,Dict:e,Unknown:o})=\\u003e({prefer_coordgen:[A,!0],remove_hs:[A,!0],sanitize:[A,!0],kekulize:[A,!0],draw_options:[e(o),{}]}))),r.register_alias(\\\"rdkit_hover\\\",(()=\\u003enew d))},\\n\\\"1ebfefbb31\\\": function _(t,e,r,s,i){var o;s();const n=t(\\\"ed5e284034\\\");class a extends n.BaseFormatter{constructor(t){super(t)}initialize(){super.initialize(),this.SmiDrawer=SmiDrawer}_make_svg_element(){const t=document.createElementNS(\\\"http://www.w3.org/2000/svg\\\",\\\"svg\\\");return t.setAttribute(\\\"xmlns\\\",\\\"http://www.w3.org/2000/svg\\\"),t.setAttribute(\\\"xmlns:xlink\\\",\\\"http://www.w3.org/1999/xlink\\\"),t.setAttributeNS(null,\\\"width\\\",\\\"\\\"+this.width),t.setAttributeNS(null,\\\"height\\\",\\\"\\\"+this.height),t.style.backgroundColor=this.background_colour,t}_setup_drawer(){const t=new this.SmiDrawer(this.mol_options,this.reaction_options);return this.drawer=t,t}draw_svg(t){var e;const r=null!==(e=this.drawer)\\u0026\\u0026void 0!==e?e:this._setup_drawer(),s=this._make_svg_element();r.draw(t,s,this.theme);const i=s.outerHTML;return s.remove(),i}}r.SmilesDrawerFormatter=a,o=a,a.__name__=\\\"SmilesDrawerFormatter\\\",a.__module__=\\\"bokehmol.models.smilesdrawer_formatter\\\",o.define((({String:t,Dict:e,Unknown:r})=\\u003e({theme:[t,\\\"light\\\"],background_colour:[t,\\\"transparent\\\"],mol_options:[e(r),{}],reaction_options:[e(r),{}]})))},\\n\\\"54f47c3230\\\": function _(e,o,r,i,t){var s;i();const n=e(\\\"a3142aba83\\\"),a=e(\\\"1ebfefbb31\\\");class l extends n.BaseHoverView{initialize(){super.initialize();const{formatters:e,smiles_column:o,width:r,height:i,theme:t,background_colour:s,mol_options:n,reaction_options:l}=this.model;e[\\\"@\\\"+o]=new a.SmilesDrawerFormatter({width:r,height:i,theme:t,background_colour:s,mol_options:n,reaction_options:l})}}r.SmilesDrawerHoverView=l,l.__name__=\\\"SmilesDrawerHoverView\\\";class _ extends n.BaseHover{constructor(e){super(e),this.tool_name=\\\"SmilesDrawer Hover\\\"}}r.SmilesDrawerHover=_,s=_,_.__name__=\\\"SmilesDrawerHover\\\",_.__module__=\\\"bokehmol.models.smilesdrawer_hover\\\",s.prototype.default_view=l,s.define((({String:e,Dict:o,Unknown:r})=\\u003e({theme:[e,\\\"light\\\"],background_colour:[e,\\\"transparent\\\"],mol_options:[o(r),{}],reaction_options:[o(r),{}]}))),s.register_alias(\\\"smiles_hover\\\",(()=\\u003enew _))},\\n}, \\\"af61f89f3f\\\", {\\\"index\\\":\\\"af61f89f3f\\\",\\\"models/index\\\":\\\"e6378f9e46\\\",\\\"models/base_formatter\\\":\\\"ed5e284034\\\",\\\"models/base_hover\\\":\\\"a3142aba83\\\",\\\"models/rdkit_formatter\\\":\\\"1d76839fb6\\\",\\\"models/rdkit_hover\\\":\\\"59dcea9792\\\",\\\"models/smilesdrawer_formatter\\\":\\\"1ebfefbb31\\\",\\\"models/smilesdrawer_hover\\\":\\\"54f47c3230\\\"}, {});});\\n\");\n }, function(Bokeh) {\n /*!\n * Copyright (c) 2012 - 2023, Anaconda, Inc., and Bokeh Contributors\n * All rights reserved.\n * \n * Redistribution and use in source and binary forms, with or without modification,\n * are permitted provided that the following conditions are met:\n * \n * Redistributions of source code must retain the above copyright notice,\n * this list of conditions and the following disclaimer.\n * \n * Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation\n * and/or other materials provided with the distribution.\n * \n * Neither the name of Anaconda nor the names of any contributors\n * may be used to endorse or promote products derived from this software\n * without specific prior written permission.\n * \n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n * THE POSSIBILITY OF SUCH DAMAGE.\n */\n (function(root, factory) {\n factory(root[\"Bokeh\"], undefined);\n })(this, function(Bokeh, version) {\n let define;\n return (function(modules, entry, aliases, externals) {\n const bokeh = typeof Bokeh !== \"undefined\" && (version != null ? Bokeh[version] : Bokeh);\n if (bokeh != null) {\n return bokeh.register_plugin(modules, entry, aliases);\n } else {\n throw new Error(\"Cannot find Bokeh \" + version + \". You have to load it prior to loading plugins.\");\n }\n })\n ({\n \"af61f89f3f\": function _(e,o,s,t,b){t();const i=e(\"tslib\").__importStar(e(\"e6378f9e46\"));s.bokehmol=i;(0,e(\"@bokehjs/base\").register_models)(i)},\n \"e6378f9e46\": function _(e,r,a,t,o){t(),o(\"BaseFormatter\",e(\"ed5e284034\").BaseFormatter),o(\"BaseHover\",e(\"a3142aba83\").BaseHover),o(\"RDKitFormatter\",e(\"1d76839fb6\").RDKitFormatter),o(\"RDKitHover\",e(\"59dcea9792\").RDKitHover),o(\"SmilesDrawerFormatter\",e(\"1ebfefbb31\").SmilesDrawerFormatter),o(\"SmilesDrawerHover\",e(\"54f47c3230\").SmilesDrawerHover)},\n \"ed5e284034\": function _(e,t,o,s,r){var _;s();const a=e(\"@bokehjs/models/tools/inspectors/customjs_hover\");class m extends a.CustomJSHover{constructor(e){super(e)}draw_svg(e){return\"\"}format(e,t,o){return this.draw_svg(e)}}o.BaseFormatter=m,_=m,m.__name__=\"BaseFormatter\",m.__module__=\"bokehmol.models.base_formatter\",_.define((({Int:e})=>({width:[e,160],height:[e,120]})))},\n \"a3142aba83\": function _(i,e,o,I,t){var s;I();const A=i(\"@bokehjs/core/dom\"),l=i(\"@bokehjs/core/util/templating\"),r=i(\"@bokehjs/core/util/types\"),h=i(\"@bokehjs/models/tools/inspectors/hover_tool\"),n=i(\"@bokehjs/styles/icons.css\");class a extends h.HoverToolView{_render_tooltips(i,e){var o;const{tooltips:I,smiles_column:t}=this.model,s=e.index;let h=I;if(null===h&&(h=\"\"),!(0,r.isString)(h)){const I=null!==(o=this._template_el)&&void 0!==o?o:this._template_el=this._create_template(h);h=this._render_template(I,h,i,e).outerHTML}const n=\"
@\"+t+\"{custom}
\"+h,a=(0,l.replace_placeholders)({html:n},i,s,this.model.formatters,e);return(0,A.div)(a)}}o.BaseHoverView=a,a.__name__=\"BaseHoverView\";class _ extends h.HoverTool{get computed_icon(){return\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAMAAADzapwJAAAAt1BMVEUAAAAAAAArKyskJCQcHBwrKyscHBwmJiYjIyMhISEgICAfHx8dHR0kJCQiIiIhISEhISEgICAkJCQkJCQjIyMiIiIiIiIhISEkJCQjIyMiIiIiIiIjIyMjIyMkJCQjIyMiIiIkJCQhISEjIyMiIiIiIiIiIiIkJCQjIyMiIiIiIiIiIiIiIiIhISEjIyMjIyMiIiIiIiIjIyMiIiIiIiIhISEiIiIiIiIiIiIiIiIhISEjIyP///9o30WSAAAAPHRSTlMAAQYHCQwSFBYXGBkaKy0uLzAxMjM0NTY5UVJTV1hdYHJyc3V3eHmBk5SVlpeZmpucnaqtrrCytLa7wMBTv07WAAAAAWJLR0Q8p2phzwAAAKRJREFUGBmtwQkagUAAgNF/ZAtZo2yRIrusofvfi+ab0gG8xx85gS8FDjlabJuS/db4WQ1RRksy+p3ZRZpxbZA6t8gYJxRzTc7WQhKPCjnlSJDwXEIdRQ9xPRKeS+eAcurjeiTEo8JhgNTdU44EUm9D9SlIRDV2FkrYZjHhazrHOJLS7xReRSi+CtzqZJYjmiUoNRn7/GixbUr2WyPHCXwpcPifD0UBD3u/QqniAAAAAElFTkSuQmCC\"}constructor(i){super(i),this.tool_icon=n.tool_icon_hover}}o.BaseHover=_,s=_,_.__name__=\"BaseHover\",_.__module__=\"bokehmol.models.base_hover\",s.prototype.default_view=a,s.define((({String:i,Number:e})=>({smiles_column:[i,\"SMILES\"],width:[e,160],height:[e,120]}))),s.override({tooltips:[]})},\n \"1d76839fb6\": function _(t,i,e,s,o){var r;s();const n=t(\"ed5e284034\");class _ extends n.BaseFormatter{constructor(t){super(t)}initialize(){super.initialize(),initRDKitModule().then((t=>{this.RDKitModule=t,console.log(\"RDKit version: \"+t.version())}))}_setup_options(){return this.RDKitModule.prefer_coordgen(this.prefer_coordgen),this.json_mol_opts=JSON.stringify({removeHs:this.remove_hs,sanitize:this.sanitize,kekulize:this.kekulize}),this.json_draw_opts=JSON.stringify(Object.assign({width:this.width,height:this.height},this.draw_options)),this.json_draw_opts}draw_svg(t){var i;const e=null!==(i=this.json_draw_opts)&&void 0!==i?i:this._setup_options(),s=this.RDKitModule.get_mol(t,this.json_mol_opts);if(null!==s&&s.is_valid()){const t=s.get_svg_with_highlights(e);return s.delete(),t}return super.draw_svg(t)}}e.RDKitFormatter=_,r=_,_.__name__=\"RDKitFormatter\",_.__module__=\"bokehmol.models.rdkit_formatter\",r.define((({Boolean:t,Dict:i,Unknown:e})=>({prefer_coordgen:[t,!0],remove_hs:[t,!0],sanitize:[t,!0],kekulize:[t,!0],draw_options:[i(e),{}]})))},\n \"59dcea9792\": function _(A,e,o,i,t){var r;i();const s=A(\"a3142aba83\"),n=A(\"1d76839fb6\");class a extends s.BaseHoverView{initialize(){super.initialize();const{formatters:A,smiles_column:e,width:o,height:i,prefer_coordgen:t,remove_hs:r,sanitize:s,kekulize:a,draw_options:d}=this.model;A[\"@\"+e]=new n.RDKitFormatter({width:o,height:i,prefer_coordgen:t,remove_hs:r,sanitize:s,kekulize:a,draw_options:d})}}o.RDKitHoverView=a,a.__name__=\"RDKitHoverView\";class d extends s.BaseHover{get computed_icon(){return\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAFVBMVEXc3NwUFP8UPP9kZP+MjP+0tP////9ZXZotAAAAAXRSTlMAQObYZgAAAAFiS0dEBmFmuH0AAAAHdElNRQfmAwsPGi+MyC9RAAAAQElEQVQI12NgQABGQUEBMENISUkRLKBsbGwEEhIyBgJFsICLC0iIUdnExcUZwnANQWfApKCK4doRBsKtQFgKAQC5Ww1JEHSEkAAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyMi0wMy0xMVQxNToyNjo0NyswMDowMDzr2J4AAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjItMDMtMTFUMTU6MjY6NDcrMDA6MDBNtmAiAAAAAElFTkSuQmCC\"}constructor(A){super(A),this.tool_name=\"RDKit Hover\"}}o.RDKitHover=d,r=d,d.__name__=\"RDKitHover\",d.__module__=\"bokehmol.models.rdkit_hover\",r.prototype.default_view=a,r.define((({Boolean:A,Dict:e,Unknown:o})=>({prefer_coordgen:[A,!0],remove_hs:[A,!0],sanitize:[A,!0],kekulize:[A,!0],draw_options:[e(o),{}]}))),r.register_alias(\"rdkit_hover\",(()=>new d))},\n \"1ebfefbb31\": function _(t,e,r,s,i){var o;s();const n=t(\"ed5e284034\");class a extends n.BaseFormatter{constructor(t){super(t)}initialize(){super.initialize(),this.SmiDrawer=SmiDrawer}_make_svg_element(){const t=document.createElementNS(\"http://www.w3.org/2000/svg\",\"svg\");return t.setAttribute(\"xmlns\",\"http://www.w3.org/2000/svg\"),t.setAttribute(\"xmlns:xlink\",\"http://www.w3.org/1999/xlink\"),t.setAttributeNS(null,\"width\",\"\"+this.width),t.setAttributeNS(null,\"height\",\"\"+this.height),t.style.backgroundColor=this.background_colour,t}_setup_drawer(){const t=new this.SmiDrawer(this.mol_options,this.reaction_options);return this.drawer=t,t}draw_svg(t){var e;const r=null!==(e=this.drawer)&&void 0!==e?e:this._setup_drawer(),s=this._make_svg_element();r.draw(t,s,this.theme);const i=s.outerHTML;return s.remove(),i}}r.SmilesDrawerFormatter=a,o=a,a.__name__=\"SmilesDrawerFormatter\",a.__module__=\"bokehmol.models.smilesdrawer_formatter\",o.define((({String:t,Dict:e,Unknown:r})=>({theme:[t,\"light\"],background_colour:[t,\"transparent\"],mol_options:[e(r),{}],reaction_options:[e(r),{}]})))},\n \"54f47c3230\": function _(e,o,r,i,t){var s;i();const n=e(\"a3142aba83\"),a=e(\"1ebfefbb31\");class l extends n.BaseHoverView{initialize(){super.initialize();const{formatters:e,smiles_column:o,width:r,height:i,theme:t,background_colour:s,mol_options:n,reaction_options:l}=this.model;e[\"@\"+o]=new a.SmilesDrawerFormatter({width:r,height:i,theme:t,background_colour:s,mol_options:n,reaction_options:l})}}r.SmilesDrawerHoverView=l,l.__name__=\"SmilesDrawerHoverView\";class _ extends n.BaseHover{constructor(e){super(e),this.tool_name=\"SmilesDrawer Hover\"}}r.SmilesDrawerHover=_,s=_,_.__name__=\"SmilesDrawerHover\",_.__module__=\"bokehmol.models.smilesdrawer_hover\",s.prototype.default_view=l,s.define((({String:e,Dict:o,Unknown:r})=>({theme:[e,\"light\"],background_colour:[e,\"transparent\"],mol_options:[o(r),{}],reaction_options:[o(r),{}]}))),s.register_alias(\"smiles_hover\",(()=>new _))},\n }, \"af61f89f3f\", {\"index\":\"af61f89f3f\",\"models/index\":\"e6378f9e46\",\"models/base_formatter\":\"ed5e284034\",\"models/base_hover\":\"a3142aba83\",\"models/rdkit_formatter\":\"1d76839fb6\",\"models/rdkit_hover\":\"59dcea9792\",\"models/smilesdrawer_formatter\":\"1ebfefbb31\",\"models/smilesdrawer_hover\":\"54f47c3230\"}, {});});\n\n },\n function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\nfunction(Bokeh) {\n }\n ];\n\n function run_inline_js() {\n if (root.Bokeh !== undefined || force === true) {\n for (let i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }\nif (force === true) {\n display_loaded();\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n const cell = $(document.getElementById(\"d8af742b-d92e-41af-90c9-a7d0fe1cb348\")).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));", "application/vnd.bokehjs_load.v0+json": "" }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import bokehmol\n", "\n", "from bokeh.models import ColumnDataSource\n", "from bokeh.plotting import figure, show\n", "from bokeh.io import output_notebook\n", "\n", "output_notebook()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Note on JupyterLab:\n", "\n", "Full compatibility would require too much efforts, but you can still use the library in JupyterLab by simply using `bokehmol.show` instead of `bokeh.plotting.show`" ] }, { "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\",\n", " \"c1ccccc1\",\n", " \"CN1C(=O)N(C)c2ncn(C)c2C1(=O)\",\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" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": "(function(root) {\n function embed_document(root) {\n const docs_json = {\"52a06db9-b085-4193-9885-062f9c885aab\":{\"version\":\"3.1.1\",\"title\":\"Bokeh Application\",\"defs\":[],\"roots\":[{\"type\":\"object\",\"name\":\"Figure\",\"id\":\"p1004\",\"attributes\":{\"height\":300,\"x_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1006\"},\"y_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1005\"},\"x_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1018\"},\"y_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1020\"},\"title\":{\"type\":\"object\",\"name\":\"Title\",\"id\":\"p1007\",\"attributes\":{\"text\":\"Basic RDKit Hover\"}},\"renderers\":[{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1049\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1001\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1003\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1002\"},\"data\":{\"type\":\"map\",\"entries\":[[\"x\",[1,2,3,4,5]],[\"y\",[6,7,2,4,5]],[\"SMILES\",[\"O=C1CCCN1C\",\"c1ccccc1\",\"CN1C(=O)N(C)c2ncn(C)c2C1(=O)\",\"C1C(=O)C=C2CCC3C4CCC(C(=O)CO)C4(C)CCC3C2(C)C1\",\"CC(=O)OC1=CC=CC=C1C(=O)O\"]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1050\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1051\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Circle\",\"id\":\"p1046\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"x\"},\"y\":{\"type\":\"field\",\"field\":\"y\"},\"size\":{\"type\":\"value\",\"value\":15},\"line_color\":{\"type\":\"value\",\"value\":\"#1f77b4\"},\"line_width\":{\"type\":\"value\",\"value\":0},\"fill_color\":{\"type\":\"value\",\"value\":\"firebrick\"}}},\"nonselection_glyph\":{\"type\":\"object\",\"name\":\"Circle\",\"id\":\"p1047\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"x\"},\"y\":{\"type\":\"field\",\"field\":\"y\"},\"size\":{\"type\":\"value\",\"value\":15},\"line_color\":{\"type\":\"value\",\"value\":\"#1f77b4\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.1},\"line_width\":{\"type\":\"value\",\"value\":0},\"fill_color\":{\"type\":\"value\",\"value\":\"firebrick\"},\"fill_alpha\":{\"type\":\"value\",\"value\":0.1},\"hatch_alpha\":{\"type\":\"value\",\"value\":0.1}}},\"muted_glyph\":{\"type\":\"object\",\"name\":\"Circle\",\"id\":\"p1048\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"x\"},\"y\":{\"type\":\"field\",\"field\":\"y\"},\"size\":{\"type\":\"value\",\"value\":15},\"line_color\":{\"type\":\"value\",\"value\":\"#1f77b4\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.2},\"line_width\":{\"type\":\"value\",\"value\":0},\"fill_color\":{\"type\":\"value\",\"value\":\"firebrick\"},\"fill_alpha\":{\"type\":\"value\",\"value\":0.2},\"hatch_alpha\":{\"type\":\"value\",\"value\":0.2}}}}}],\"toolbar\":{\"type\":\"object\",\"name\":\"Toolbar\",\"id\":\"p1012\",\"attributes\":{\"tools\":[{\"type\":\"object\",\"name\":\"bokehmol.models.rdkit_hover.RDKitHover\",\"id\":\"p1036\",\"attributes\":{\"renderers\":\"auto\"}},{\"type\":\"object\",\"name\":\"PanTool\",\"id\":\"p1037\"},{\"type\":\"object\",\"name\":\"WheelZoomTool\",\"id\":\"p1038\"}]}},\"left\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1029\",\"attributes\":{\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1031\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1030\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1032\"}}}],\"below\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1022\",\"attributes\":{\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1024\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1023\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1025\"}}}],\"center\":[{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1028\",\"attributes\":{\"axis\":{\"id\":\"p1022\"}}},{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1035\",\"attributes\":{\"dimension\":1,\"axis\":{\"id\":\"p1029\"}}}],\"background_fill_color\":\"#efefef\"}}],\"callbacks\":{\"type\":\"map\"}}};\n const render_items = [{\"docid\":\"52a06db9-b085-4193-9885-062f9c885aab\",\"roots\":{\"p1004\":\"ffc5a22e-37aa-47d2-acdf-073567ae45bc\"},\"root_ids\":[\"p1004\"]}];\n root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n }\n if (root.Bokeh !== undefined) {\n embed_document(root);\n } else {\n let attempts = 0;\n const timer = setInterval(function(root) {\n if (root.Bokeh !== undefined) {\n clearInterval(timer);\n embed_document(root);\n } else {\n attempts++;\n if (attempts > 100) {\n clearInterval(timer);\n console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n }\n }\n }, 10, root)\n }\n})(window);", "application/vnd.bokehjs_exec.v0+json": "" }, "metadata": { "application/vnd.bokehjs_exec.v0+json": { "id": "p1004" } }, "output_type": "display_data" } ], "source": [ "plot = figure(\n", " width=600, height=300,\n", " title=\"Basic RDKit Hover\",\n", " background_fill_color=\"#efefef\",\n", " tools=\"rdkit_hover,pan,wheel_zoom\",\n", ")\n", "\n", "plot.circle(\"x\", \"y\", size=15, line_width=0, fill_color=\"firebrick\", source=source)\n", "\n", "show(plot)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": "(function(root) {\n function embed_document(root) {\n const docs_json = {\"08d1ca66-eae2-4f00-9872-517d96570ca8\":{\"version\":\"3.1.1\",\"title\":\"Bokeh Application\",\"defs\":[],\"roots\":[{\"type\":\"object\",\"name\":\"Figure\",\"id\":\"p1124\",\"attributes\":{\"height\":300,\"x_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1126\"},\"y_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1125\"},\"x_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1138\"},\"y_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1140\"},\"title\":{\"type\":\"object\",\"name\":\"Title\",\"id\":\"p1127\",\"attributes\":{\"text\":\"Basic SmilesDrawer Hover\"}},\"renderers\":[{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1169\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1001\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1003\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1002\"},\"data\":{\"type\":\"map\",\"entries\":[[\"x\",[1,2,3,4,5]],[\"y\",[6,7,2,4,5]],[\"SMILES\",[\"O=C1CCCN1C\",\"c1ccccc1\",\"CN1C(=O)N(C)c2ncn(C)c2C1(=O)\",\"C1C(=O)C=C2CCC3C4CCC(C(=O)CO)C4(C)CCC3C2(C)C1\",\"CC(=O)OC1=CC=CC=C1C(=O)O\"]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1170\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1171\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Circle\",\"id\":\"p1166\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"x\"},\"y\":{\"type\":\"field\",\"field\":\"y\"},\"size\":{\"type\":\"value\",\"value\":15},\"line_color\":{\"type\":\"value\",\"value\":\"#1f77b4\"},\"line_width\":{\"type\":\"value\",\"value\":0},\"fill_color\":{\"type\":\"value\",\"value\":\"firebrick\"}}},\"nonselection_glyph\":{\"type\":\"object\",\"name\":\"Circle\",\"id\":\"p1167\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"x\"},\"y\":{\"type\":\"field\",\"field\":\"y\"},\"size\":{\"type\":\"value\",\"value\":15},\"line_color\":{\"type\":\"value\",\"value\":\"#1f77b4\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.1},\"line_width\":{\"type\":\"value\",\"value\":0},\"fill_color\":{\"type\":\"value\",\"value\":\"firebrick\"},\"fill_alpha\":{\"type\":\"value\",\"value\":0.1},\"hatch_alpha\":{\"type\":\"value\",\"value\":0.1}}},\"muted_glyph\":{\"type\":\"object\",\"name\":\"Circle\",\"id\":\"p1168\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"x\"},\"y\":{\"type\":\"field\",\"field\":\"y\"},\"size\":{\"type\":\"value\",\"value\":15},\"line_color\":{\"type\":\"value\",\"value\":\"#1f77b4\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.2},\"line_width\":{\"type\":\"value\",\"value\":0},\"fill_color\":{\"type\":\"value\",\"value\":\"firebrick\"},\"fill_alpha\":{\"type\":\"value\",\"value\":0.2},\"hatch_alpha\":{\"type\":\"value\",\"value\":0.2}}}}}],\"toolbar\":{\"type\":\"object\",\"name\":\"Toolbar\",\"id\":\"p1132\",\"attributes\":{\"tools\":[{\"type\":\"object\",\"name\":\"bokehmol.models.smilesdrawer_hover.SmilesDrawerHover\",\"id\":\"p1156\",\"attributes\":{\"renderers\":\"auto\"}},{\"type\":\"object\",\"name\":\"PanTool\",\"id\":\"p1157\"},{\"type\":\"object\",\"name\":\"WheelZoomTool\",\"id\":\"p1158\"}]}},\"left\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1149\",\"attributes\":{\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1151\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1150\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1152\"}}}],\"below\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1142\",\"attributes\":{\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1144\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1143\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1145\"}}}],\"center\":[{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1148\",\"attributes\":{\"axis\":{\"id\":\"p1142\"}}},{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1155\",\"attributes\":{\"dimension\":1,\"axis\":{\"id\":\"p1149\"}}}],\"background_fill_color\":\"#efefef\"}}],\"callbacks\":{\"type\":\"map\"}}};\n const render_items = [{\"docid\":\"08d1ca66-eae2-4f00-9872-517d96570ca8\",\"roots\":{\"p1124\":\"e242fd0f-f0e8-4966-be36-4a3bfffd0248\"},\"root_ids\":[\"p1124\"]}];\n root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n }\n if (root.Bokeh !== undefined) {\n embed_document(root);\n } else {\n let attempts = 0;\n const timer = setInterval(function(root) {\n if (root.Bokeh !== undefined) {\n clearInterval(timer);\n embed_document(root);\n } else {\n attempts++;\n if (attempts > 100) {\n clearInterval(timer);\n console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n }\n }\n }, 10, root)\n }\n})(window);", "application/vnd.bokehjs_exec.v0+json": "" }, "metadata": { "application/vnd.bokehjs_exec.v0+json": { "id": "p1124" } }, "output_type": "display_data" } ], "source": [ "plot = figure(\n", " width=600, height=300,\n", " title=\"Basic SmilesDrawer Hover\",\n", " background_fill_color=\"#efefef\",\n", " tools=\"smiles_hover,pan,wheel_zoom\",\n", ")\n", "\n", "plot.circle(\"x\", \"y\", size=15, line_width=0, fill_color=\"firebrick\", source=source)\n", "\n", "show(plot)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If your SMILES column has a different name, you can instantiate the molecule hover tool directly and parametrize it further. With this, the `bokehmol.register_alias()` call in the example above is not necessary." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": "(function(root) {\n function embed_document(root) {\n const docs_json = {\"c988ed96-ff40-4ee5-8805-ce8a188f936f\":{\"version\":\"3.1.1\",\"title\":\"Bokeh Application\",\"defs\":[],\"roots\":[{\"type\":\"object\",\"name\":\"Figure\",\"id\":\"p1256\",\"attributes\":{\"height\":300,\"x_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1258\"},\"y_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1257\"},\"x_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1270\"},\"y_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1272\"},\"title\":{\"type\":\"object\",\"name\":\"Title\",\"id\":\"p1259\",\"attributes\":{\"text\":\"Configured RDKit Hover\"}},\"renderers\":[{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1301\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1001\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1003\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1002\"},\"data\":{\"type\":\"map\",\"entries\":[[\"x\",[1,2,3,4,5]],[\"y\",[6,7,2,4,5]],[\"SMILES\",[\"O=C1CCCN1C\",\"c1ccccc1\",\"CN1C(=O)N(C)c2ncn(C)c2C1(=O)\",\"C1C(=O)C=C2CCC3C4CCC(C(=O)CO)C4(C)CCC3C2(C)C1\",\"CC(=O)OC1=CC=CC=C1C(=O)O\"]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1302\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1303\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Circle\",\"id\":\"p1298\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"x\"},\"y\":{\"type\":\"field\",\"field\":\"y\"},\"size\":{\"type\":\"value\",\"value\":15},\"line_color\":{\"type\":\"value\",\"value\":\"#1f77b4\"},\"line_width\":{\"type\":\"value\",\"value\":0},\"fill_color\":{\"type\":\"value\",\"value\":\"firebrick\"}}},\"nonselection_glyph\":{\"type\":\"object\",\"name\":\"Circle\",\"id\":\"p1299\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"x\"},\"y\":{\"type\":\"field\",\"field\":\"y\"},\"size\":{\"type\":\"value\",\"value\":15},\"line_color\":{\"type\":\"value\",\"value\":\"#1f77b4\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.1},\"line_width\":{\"type\":\"value\",\"value\":0},\"fill_color\":{\"type\":\"value\",\"value\":\"firebrick\"},\"fill_alpha\":{\"type\":\"value\",\"value\":0.1},\"hatch_alpha\":{\"type\":\"value\",\"value\":0.1}}},\"muted_glyph\":{\"type\":\"object\",\"name\":\"Circle\",\"id\":\"p1300\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"x\"},\"y\":{\"type\":\"field\",\"field\":\"y\"},\"size\":{\"type\":\"value\",\"value\":15},\"line_color\":{\"type\":\"value\",\"value\":\"#1f77b4\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.2},\"line_width\":{\"type\":\"value\",\"value\":0},\"fill_color\":{\"type\":\"value\",\"value\":\"firebrick\"},\"fill_alpha\":{\"type\":\"value\",\"value\":0.2},\"hatch_alpha\":{\"type\":\"value\",\"value\":0.2}}}}}],\"toolbar\":{\"type\":\"object\",\"name\":\"Toolbar\",\"id\":\"p1264\",\"attributes\":{\"tools\":[{\"type\":\"object\",\"name\":\"PanTool\",\"id\":\"p1288\"},{\"type\":\"object\",\"name\":\"WheelZoomTool\",\"id\":\"p1289\"},{\"type\":\"object\",\"name\":\"bokehmol.models.rdkit_hover.RDKitHover\",\"id\":\"p1293\",\"attributes\":{\"renderers\":\"auto\",\"tooltips\":[[\"smiles\",\"@SMILES\"]],\"draw_options\":{\"type\":\"map\",\"entries\":[[\"comicMode\",true]]}}}]}},\"left\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1281\",\"attributes\":{\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1283\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1282\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1284\"}}}],\"below\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1274\",\"attributes\":{\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1276\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1275\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1277\"}}}],\"center\":[{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1280\",\"attributes\":{\"axis\":{\"id\":\"p1274\"}}},{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1287\",\"attributes\":{\"dimension\":1,\"axis\":{\"id\":\"p1281\"}}}],\"background_fill_color\":\"#efefef\"}}],\"callbacks\":{\"type\":\"map\"}}};\n const render_items = [{\"docid\":\"c988ed96-ff40-4ee5-8805-ce8a188f936f\",\"roots\":{\"p1256\":\"d1fd5adf-7357-461c-b809-8309bad018a1\"},\"root_ids\":[\"p1256\"]}];\n root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n }\n if (root.Bokeh !== undefined) {\n embed_document(root);\n } else {\n let attempts = 0;\n const timer = setInterval(function(root) {\n if (root.Bokeh !== undefined) {\n clearInterval(timer);\n embed_document(root);\n } else {\n attempts++;\n if (attempts > 100) {\n clearInterval(timer);\n console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n }\n }\n }, 10, root)\n }\n})(window);", "application/vnd.bokehjs_exec.v0+json": "" }, "metadata": { "application/vnd.bokehjs_exec.v0+json": { "id": "p1256" } }, "output_type": "display_data" } ], "source": [ "plot = figure(\n", " width=600, height=300,\n", " title=\"Configured RDKit Hover\",\n", " background_fill_color=\"#efefef\",\n", " tools=\"pan,wheel_zoom\",\n", ")\n", "\n", "mol_hover = bokehmol.hover.rdkit(\n", " smiles_column=\"SMILES\",\n", " tooltips=[\n", " (\"smiles\", \"@SMILES\"),\n", " ],\n", " draw_options={\n", " \"comicMode\": True\n", " }\n", ")\n", "\n", "plot.add_tools(mol_hover)\n", "plot.circle(\"x\", \"y\", size=15, line_width=0, fill_color=\"firebrick\", source=source)\n", "\n", "show(plot)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;31mSignature:\u001b[0m\n", "\u001b[0mbokehmol\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mhover\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mrdkit\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m\n", "\u001b[0m \u001b[0msmiles_column\u001b[0m\u001b[1;33m:\u001b[0m \u001b[0mstr\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;34m'SMILES'\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\n", "\u001b[0m \u001b[0mtooltips\u001b[0m\u001b[1;33m:\u001b[0m \u001b[0mUnion\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mstr\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mList\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mTuple\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mstr\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mstr\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mNoneType\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\n", "\u001b[0m \u001b[0mwidth\u001b[0m\u001b[1;33m:\u001b[0m \u001b[0mint\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;36m160\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\n", "\u001b[0m \u001b[0mheight\u001b[0m\u001b[1;33m:\u001b[0m \u001b[0mint\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;36m120\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\n", "\u001b[0m \u001b[0mremove_hs\u001b[0m\u001b[1;33m:\u001b[0m \u001b[0mbool\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mTrue\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\n", "\u001b[0m \u001b[0msanitize\u001b[0m\u001b[1;33m:\u001b[0m \u001b[0mbool\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mTrue\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\n", "\u001b[0m \u001b[0mkekulize\u001b[0m\u001b[1;33m:\u001b[0m \u001b[0mbool\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mTrue\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\n", "\u001b[0m \u001b[0mprefer_coordgen\u001b[0m\u001b[1;33m:\u001b[0m \u001b[0mbool\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mTrue\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\n", "\u001b[0m \u001b[0mdraw_options\u001b[0m\u001b[1;33m:\u001b[0m \u001b[0mUnion\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mDict\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mstr\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mAny\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mNoneType\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\n", "\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[1;33m:\u001b[0m \u001b[0mAny\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\n", "\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m->\u001b[0m \u001b[1;34m'RDKitHover'\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", "\u001b[1;31mDocstring:\u001b[0m\n", "Hover tool that uses RDKit.js and the RDKit's Minimal Lib to depict\n", "SMILES strings on hover.\n", "\n", "Notes\n", "-----\n", "See https://www.npmjs.com/package/@rdkit/rdkit for the readme.\n", "\n", "Parameters\n", "----------\n", "smiles_column: str = \"SMILES\"\n", " Column in the `ColumnDataSource` object containing the SMILES string.\n", "tooltips: t.Union[str, t.List[t.Tuple[str, str]]] = None\n", " Tooltips to render below the depiction. Can be an HTML string, or a list of\n", " tuples specifying the display name and column name that you want to display.\n", " Column names must be prefixed with `@` (or `$` for bokeh's internal\n", " variables), see bokeh's docs for more info on tooltips formats::\n", "\n", " >>> bokehmol.hover.rdkit(\n", " ... tooltips=[\n", " ... (\"SMILES\", \"@SMILES\"),\n", " ... (\"Name\", \"@{Molecule name}\"),\n", " ... ]\n", " ... )\n", "\n", "width: int = 160\n", " Image width in pixels\n", "height: int = 120\n", " Image height in pixels\n", "remove_hs: bool = True\n", " Remove hydrogens from the depiction\n", "sanitize: bool = True\n", " Sanitize the molecule\n", "kekulize: bool = True\n", " Kekulize the molecule\n", "prefer_coordgen: bool = True\n", " Prefer the CoordGen library for macrocycle rendering\n", "draw_options: t.Dict[str, t.Any] = None\n", " RDKit's MolDrawOptions to control the style of the drawing:\n", " https://www.rdkitjs.com/#drawing-molecules-all-options.::\n", "\n", " >>> bokehmol.hover.rdkit(\n", " ... draw_options={\n", " ... \"addAtomIndices\": True,\n", " ... }\n", " ... )\n", "\n", "**kwargs: t.Any\n", " Additional parameters passed to bokeh's Hover tool.\n", "\n", "Returns\n", "-------\n", "An RDKit-based hover tool ready to be added to a bokeh plot::\n", "\n", " >>> from bokeh.plotting import figure\n", " >>> plot = figure(...)\n", " >>> hover_tool = bokehmol.hover.rdkit()\n", " >>> plot.add_tools(hover_tool)\n", "\u001b[1;31mFile:\u001b[0m c:\\users\\bouys\\dev\\bokehmol\\bokehmol\\hover.py\n", "\u001b[1;31mType:\u001b[0m function" ] } ], "source": [ "# options available\n", "bokehmol.hover.rdkit?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Same with SmilesDrawer:" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": "(function(root) {\n function embed_document(root) {\n const docs_json = {\"9578ba45-b601-45e4-b71a-192a5ce52e16\":{\"version\":\"3.1.1\",\"title\":\"Bokeh Application\",\"defs\":[],\"roots\":[{\"type\":\"object\",\"name\":\"Figure\",\"id\":\"p1400\",\"attributes\":{\"height\":300,\"x_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1402\"},\"y_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1401\"},\"x_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1414\"},\"y_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1416\"},\"title\":{\"type\":\"object\",\"name\":\"Title\",\"id\":\"p1403\",\"attributes\":{\"text\":\"Configured SmilesDrawer Hover\"}},\"renderers\":[{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1445\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1001\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1003\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1002\"},\"data\":{\"type\":\"map\",\"entries\":[[\"x\",[1,2,3,4,5]],[\"y\",[6,7,2,4,5]],[\"SMILES\",[\"O=C1CCCN1C\",\"c1ccccc1\",\"CN1C(=O)N(C)c2ncn(C)c2C1(=O)\",\"C1C(=O)C=C2CCC3C4CCC(C(=O)CO)C4(C)CCC3C2(C)C1\",\"CC(=O)OC1=CC=CC=C1C(=O)O\"]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1446\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1447\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Circle\",\"id\":\"p1442\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"x\"},\"y\":{\"type\":\"field\",\"field\":\"y\"},\"size\":{\"type\":\"value\",\"value\":15},\"line_color\":{\"type\":\"value\",\"value\":\"#1f77b4\"},\"line_width\":{\"type\":\"value\",\"value\":0},\"fill_color\":{\"type\":\"value\",\"value\":\"firebrick\"}}},\"nonselection_glyph\":{\"type\":\"object\",\"name\":\"Circle\",\"id\":\"p1443\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"x\"},\"y\":{\"type\":\"field\",\"field\":\"y\"},\"size\":{\"type\":\"value\",\"value\":15},\"line_color\":{\"type\":\"value\",\"value\":\"#1f77b4\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.1},\"line_width\":{\"type\":\"value\",\"value\":0},\"fill_color\":{\"type\":\"value\",\"value\":\"firebrick\"},\"fill_alpha\":{\"type\":\"value\",\"value\":0.1},\"hatch_alpha\":{\"type\":\"value\",\"value\":0.1}}},\"muted_glyph\":{\"type\":\"object\",\"name\":\"Circle\",\"id\":\"p1444\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"x\"},\"y\":{\"type\":\"field\",\"field\":\"y\"},\"size\":{\"type\":\"value\",\"value\":15},\"line_color\":{\"type\":\"value\",\"value\":\"#1f77b4\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.2},\"line_width\":{\"type\":\"value\",\"value\":0},\"fill_color\":{\"type\":\"value\",\"value\":\"firebrick\"},\"fill_alpha\":{\"type\":\"value\",\"value\":0.2},\"hatch_alpha\":{\"type\":\"value\",\"value\":0.2}}}}}],\"toolbar\":{\"type\":\"object\",\"name\":\"Toolbar\",\"id\":\"p1408\",\"attributes\":{\"tools\":[{\"type\":\"object\",\"name\":\"PanTool\",\"id\":\"p1432\"},{\"type\":\"object\",\"name\":\"WheelZoomTool\",\"id\":\"p1433\"},{\"type\":\"object\",\"name\":\"bokehmol.models.smilesdrawer_hover.SmilesDrawerHover\",\"id\":\"p1437\",\"attributes\":{\"renderers\":\"auto\",\"tooltips\":[[\"smiles\",\"@SMILES\"]],\"theme\":\"cyberpunk\",\"background_colour\":\"#3d3d3b\",\"mol_options\":{\"type\":\"map\",\"entries\":[[\"atomVisualization\",\"balls\"]]}}}]}},\"left\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1425\",\"attributes\":{\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1427\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1426\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1428\"}}}],\"below\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1418\",\"attributes\":{\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1420\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1419\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1421\"}}}],\"center\":[{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1424\",\"attributes\":{\"axis\":{\"id\":\"p1418\"}}},{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1431\",\"attributes\":{\"dimension\":1,\"axis\":{\"id\":\"p1425\"}}}],\"background_fill_color\":\"#efefef\"}}],\"callbacks\":{\"type\":\"map\"}}};\n const render_items = [{\"docid\":\"9578ba45-b601-45e4-b71a-192a5ce52e16\",\"roots\":{\"p1400\":\"d997f5cd-4686-4cde-a06f-36b1c7f965f8\"},\"root_ids\":[\"p1400\"]}];\n root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n }\n if (root.Bokeh !== undefined) {\n embed_document(root);\n } else {\n let attempts = 0;\n const timer = setInterval(function(root) {\n if (root.Bokeh !== undefined) {\n clearInterval(timer);\n embed_document(root);\n } else {\n attempts++;\n if (attempts > 100) {\n clearInterval(timer);\n console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n }\n }\n }, 10, root)\n }\n})(window);", "application/vnd.bokehjs_exec.v0+json": "" }, "metadata": { "application/vnd.bokehjs_exec.v0+json": { "id": "p1400" } }, "output_type": "display_data" } ], "source": [ "plot = figure(\n", " width=600, height=300,\n", " title=\"Configured SmilesDrawer Hover\",\n", " background_fill_color=\"#efefef\",\n", " tools=\"pan,wheel_zoom\",\n", ")\n", "\n", "mol_hover = bokehmol.hover.smiles_drawer(\n", " smiles_column=\"SMILES\",\n", " tooltips=[\n", " (\"smiles\", \"@SMILES\"),\n", " ],\n", " theme=\"cyberpunk\",\n", " background_colour=\"#3d3d3b\",\n", " mol_options={\n", " \"atomVisualization\": \"balls\"\n", " }\n", ")\n", "\n", "plot.add_tools(mol_hover)\n", "plot.circle(\"x\", \"y\", size=15, line_width=0, fill_color=\"firebrick\", source=source)\n", "\n", "show(plot)" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;31mSignature:\u001b[0m\n", "\u001b[0mbokehmol\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mhover\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msmiles_drawer\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m\n", "\u001b[0m \u001b[0msmiles_column\u001b[0m\u001b[1;33m:\u001b[0m \u001b[0mstr\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;34m'SMILES'\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\n", "\u001b[0m \u001b[0mtooltips\u001b[0m\u001b[1;33m:\u001b[0m \u001b[0mUnion\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mstr\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mList\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mTuple\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mstr\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mstr\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mNoneType\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\n", "\u001b[0m \u001b[0mwidth\u001b[0m\u001b[1;33m:\u001b[0m \u001b[0mint\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;36m160\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\n", "\u001b[0m \u001b[0mheight\u001b[0m\u001b[1;33m:\u001b[0m \u001b[0mint\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;36m120\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\n", "\u001b[0m \u001b[0mtheme\u001b[0m\u001b[1;33m:\u001b[0m \u001b[0mLiteral\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'light'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'dark'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'oldschool'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'solarized'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'solarized-dark'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'matrix'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'github'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'carbon'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'cyberpunk'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'gruvbox'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'gruvbox-dark'\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;34m'light'\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\n", "\u001b[0m \u001b[0mbackground_colour\u001b[0m\u001b[1;33m:\u001b[0m \u001b[0mstr\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;34m'transparent'\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\n", "\u001b[0m \u001b[0mmol_options\u001b[0m\u001b[1;33m:\u001b[0m \u001b[0mUnion\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mDict\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mstr\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mAny\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mNoneType\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\n", "\u001b[0m \u001b[0mreaction_options\u001b[0m\u001b[1;33m:\u001b[0m \u001b[0mUnion\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mDict\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mstr\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mAny\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mNoneType\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\n", "\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[1;33m:\u001b[0m \u001b[0mAny\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\n", "\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m->\u001b[0m \u001b[1;34m'SmilesDrawerHover'\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", "\u001b[1;31mDocstring:\u001b[0m\n", "Hover tool that uses SmilesDrawer to depict SMILES strings on hover.\n", "\n", "Notes\n", "-----\n", "See https://github.com/reymond-group/smilesDrawer#readme for the readme.\n", "Please cite the SmilesDrawer paper doi:10.1021/acs.jcim.7b00425 if you use this\n", "in academic work.\n", "\n", "Parameters\n", "----------\n", "smiles_column: str = \"SMILES\"\n", " Column in the `ColumnDataSource` object containing the SMILES string.\n", "tooltips: t.Union[str, t.List[t.Tuple[str, str]]] = None\n", " Tooltips to render below the depiction. Can be an HTML string, or a list of\n", " tuples specifying the display name and column name that you want to display.\n", " Column names must be prefixed with `@` (or `$` for bokeh's internal\n", " variables), see bokeh's docs for more info on tooltips formats::\n", "\n", " >>> bokehmol.hover.smiles_drawer(\n", " ... tooltips=[\n", " ... (\"SMILES\", \"@SMILES\"),\n", " ... (\"Name\", \"@{Molecule name}\"),\n", " ... ]\n", " ... )\n", "\n", "width: int = 160\n", " Image width in pixels\n", "height: int = 120\n", " Image height in pixels\n", "theme: str = \"light\"\n", " Theme used for the rendering. One of the following list: light, dark,\n", " oldschool, solarized, solarized-dark, matrix, github, carbon, cyberpunk,\n", " gruvbox, gruvbox-dark.\n", "background_colour: str = \"transparent\"\n", " Any valid CSS color specification.\n", "mol_options: t.Dict[str, t.Any] = None\n", " SmilesDrawer options to control the style of the molecule's drawing:\n", " https://smilesdrawer.surge.sh/playground.html.::\n", "\n", " >>> bokehmol.hover.smiles_drawer(\n", " ... mol_options={\n", " ... \"atomVisualization\": \"balls\",\n", " ... }\n", " ... )\n", "\n", "reaction_options: t.Dict[str, t.Any] = None\n", " Same as above for reaction's drawing.\n", "**kwargs: t.Any\n", " Additional parameters passed to bokeh's Hover tool.\n", "\n", "Returns\n", "-------\n", "A SmilesDrawer-based hover tool ready to be added to a bokeh plot::\n", "\n", " >>> from bokeh.plotting import figure\n", " >>> plot = figure(...)\n", " >>> hover_tool = bokehmol.hover.smiles_drawer()\n", " >>> plot.add_tools(hover_tool)\n", "\u001b[1;31mFile:\u001b[0m c:\\users\\bouys\\dev\\bokehmol\\bokehmol\\hover.py\n", "\u001b[1;31mType:\u001b[0m function" ] } ], "source": [ "# options available\n", "bokehmol.hover.smiles_drawer?" ] } ], "metadata": { "kernelspec": { "display_name": "bokehmol", "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.8.17" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }