Skip to main content

bokeh extension for jsmol

Project description

Build Status

JSmol bokeh extension

This extension lets you visualize atomic structures in bokeh using JSmol.

Features

  • Works both using bokeh and bokeh server
  • See example.html. Structure displays in standalone html, button will start working in bokeh server

Prerequisites

Note: As of 2019-06, NodeJS is required to compile the .ts / .coffee files. Once bokeh provides guidelines on how to bundle compiled javascript, the NodeJS dependency may be dropped.

Installation

Versioning

  • jsmol-bokeh-extension 0.1.x works with bokeh < 1.1 (written in CoffeScript)
  • jsmol-bokeh-extension 0.2 and above works with bokeh >= 1.1 (written in TypeScript)
pip install jsmol-bokeh-extension

Usage

Below a complete example.py demonstrating how to use the jsmol bokeh extension:

rom bokeh.models import ColumnDataSource
from bokeh.io import show, curdoc
from bokeh.models.widgets import Button, TextInput
from bokeh.layouts import layout, widgetbox

from jsmol_bokeh_extension import JSMol

script_source = ColumnDataSource()

info = dict(
    height="100%",
    width="100%",
    serverURL="https://chemapps.stolaf.edu/jmol/jsmol/php/jsmol.php",
    use="HTML5",
    j2sPath="https://chemapps.stolaf.edu/jmol/jsmol/j2s",
    script=
    "background black;load https://chemapps.stolaf.edu/jmol/jsmol-2013-09-18/data/caffeine.mol",
)

applet = JSMol(
    width=600,
    height=600,
    script_source=script_source,
    info=info,
)

button = Button(label='Execute')
inp_script = TextInput(value='background white;')


def run_script():
    script_source.data['script'] = [inp_script.value]


button.on_click(run_script)

ly = layout([applet, widgetbox(button, inp_script)])

show(ly)
curdoc().add_root(ly)

Note: The example can be run both using bokeh and bokeh server:

# run locally (displays structure but button won't work)
python example.py

# run using bokeh server (displays structure and button should work)
bokeh serve example.py --show

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jsmol-bokeh-extension-0.2.0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

jsmol_bokeh_extension-0.2.0-py2.py3-none-any.whl (6.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file jsmol-bokeh-extension-0.2.0.tar.gz.

File metadata

  • Download URL: jsmol-bokeh-extension-0.2.0.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.16

File hashes

Hashes for jsmol-bokeh-extension-0.2.0.tar.gz
Algorithm Hash digest
SHA256 9169541266859b55ba9e8905ab27016b3ab7df60dd76f203d0e72bda672073dc
MD5 c65dbca34c23eb6048523cb51e222355
BLAKE2b-256 2b9d05ba001d7a0faa5a12de66358f77b6e25ac0813e4b1a52e0680e3fe32b74

See more details on using hashes here.

Provenance

File details

Details for the file jsmol_bokeh_extension-0.2.0-py2.py3-none-any.whl.

File metadata

  • Download URL: jsmol_bokeh_extension-0.2.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.16

File hashes

Hashes for jsmol_bokeh_extension-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 3f25ae342817391a0a74ce204ffafe2e270ab42e12c997b5245cb4e27601fa46
MD5 89536ec51b214eb18273a01be66173b1
BLAKE2b-256 78a14f510551787fcf2bb84f6453ea9d1ef27b66bf627674fe41f36d67912753

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page