Skip to content

Jhsmit/ipymolstar

Repository files navigation

ipymolstar

image

Live Demos

Give ipymolstar a spin without even installing python!

You can find other examples in the examples directory.

Preview

You can run a quick preview of ipymolstar in a notebook with juv:

juv run example.ipynb

Installation

pip install ipymolstar

Warning

Make sure you install ipymolstar in an environment that contains your installation of Jupyter. If you have installed Jupyter in a different environment from your project (requiring you to use a named, non-default kernel), you will have to install ipymolstar (or only anywidget) in your Jupyter environment as well.

Use

from ipymolstar import PDBeMolstar
view = PDBeMolstar(molecule_id='1qyn', theme='light', hide_water=True)
view

Loading local data, hiding the buttons:

from pathlib import Path 
fpth = Path().resolve() / 'assets' / '6vsb.bcif'
custom_data = {
    'data': fpth.read_bytes(),
    'format': 'cif',
    'binary': True,
    }
view = PDBeMolstar(
    custom_data=custom_data, 
    hide_controls_icon=True, 
    hide_expand_icon=True, 
    hide_settings_icon=True, 
    hide_selection_icon=True, 
    hide_animation_icon=True,
    hide_water=True,
    hide_carbs=True,
)
view

See the example notebook for more advanced usage. Solara example code can be found here

Citing

ipymolstar uses anywidget to create a widgets based on Mol*

To cite Mol*:

David Sehnal, Sebastian Bittrich, Mandar Deshpande, Radka Svobodová, Karel Berka, Václav Bazgier, Sameer Velankar, Stephen K Burley, Jaroslav Koča, Alexander S Rose: Mol* Viewer: modern web app for 3D visualization and analysis of large biomolecular structures, Nucleic Acids Research, 2021; 10.1093/nar/gkab31.

PDBeMolstar

The PDBeMolstar widget is based on the PDBe integration of Mol*.

MolViewSpec

The MolViewSpec widget is based on MolViewSpec. To cite MolViewSpec:

Sebastian Bittrich, Adam Midlik, Mihaly Varadi, Sameer Velankar, Stephen K. Burley, Jasmine Y. Young, David Sehnal, Brinda Vallat: Describing and Sharing Molecular Visualizations Using the MolViewSpec Toolkit, Current Protocols, 2024; 10.1002/cpz1.1099

See also the RCSB citation policies for additional citation information.

Development

The molviewspec widget front-end code bundles it's JavaScript dependencies. After setting up Python, make sure to install these dependencies locally:

npm install

While developing, you can run the following in a separate terminal to automatically rebuild JavaScript as you make changes:

npm run dev

Creating a new release

  • update __version__ in __init__.py
  • create a new release on GitHub, choose as tag 'v' + __version__; ie 'v0.0.3'
  • GitHub actions should automatically deploy to PyPi

Hot reloading

To enable anywidget hot reloading, you need to set the env var ANYWIDGET_HMR to 1.

Windows:

set ANYWIDGET_HMR=1
jupyter lab