Skip to main content

A JupyterLab launcher extension to view the molecular orbitals.

Project description

jupyterlab-mol-visualizer: A JupyterLab Extension to Visualize Molecular Orbitals

Build

A JupyterLab launcher extension to view the molecular orbitals (MOs). NGL JavaScript package was employed to visualize the MOs. The icon of the extension (bundled as style/molecule.svg) is adapted from SVG Repo.

demo

Features

  • Large interactive viewer — the molecular visualization fills the available screen space with a sidebar control panel
  • Structure & isosurface loading — load .sdf, .cif, .xyz (structure) and .cube (Gaussian cube) files from the current JupyterLab directory
  • Auto-rotate, visibility toggles, camera modes — toggle spin, show/hide structure and positive/negative isosurfaces, and switch between perspective, orthographic, and stereo cameras
  • Opacity & isovalue sliders — fine-tune the display with real-time sliders
  • Viewer background color controls — choose from 8 preset swatches or use the custom color palette picker
  • Auto Centre — re-centre the camera on the molecule with a smooth animation
  • Save PNG — export the current view as a high-resolution PNG image
  • Dark & light theme — adapts to JupyterLab's theme automatically

Try it with Binder

Binder

Requirements

  • JupyterLab >= 4.0.0

Install

To install the extension, execute:

pip install jupyterlab_mol_visualizer

Uninstall

To remove the extension, execute:

pip uninstall jupyterlab_mol_visualizer

Contributing

Development install

Note: You will need NodeJS to build the extension package.

The jlpm command is JupyterLab's pinned version of yarn that is installed with JupyterLab. You may use yarn or npm in lieu of jlpm below. For a faster editable install, npm is recommended.

# Clone the repo to your local environment
# Change directory to the jupyterlab_mol_visualizer directory
# Install npm dependencies (only needed first time)
npm install
# Install package in development mode
pip install -e "."

After the first install, subsequent pip install -e . runs are near-instant (the build step is skipped once the labextension exists). To rebuild the extension after making TypeScript changes:

npm run build

You can watch the source directory and run JupyterLab at the same time in different terminals to watch for changes in the extension's source and automatically rebuild the extension.

# Watch the source directory in one terminal, automatically rebuilding when needed
npm run watch
# Run JupyterLab in another terminal
jupyter lab

With the watch command running, every saved change will immediately be built locally and available in your running JupyterLab. Refresh JupyterLab to load the change in your browser (you may need to wait several seconds for the extension to be rebuilt).

By default, the build generates the source maps for this extension to make it easier to debug using the browser dev tools. To also generate source maps for the JupyterLab core extensions, you can run the following command:

jupyter lab build --minimize=False

Development uninstall

pip uninstall jupyterlab_mol_visualizer

In development mode, you will also need to remove the symlink created by jupyter labextension develop command. To find its location, you can run jupyter labextension list to figure out where the labextensions folder is located. Then you can remove the symlink named jupyterlab_mol_visualizer within that folder.

Testing the extension

Frontend tests

This extension is using Jest for JavaScript code testing.

To execute them, execute:

npm install
npm test

Integration tests

This extension uses Playwright for the integration tests (aka user level tests). More precisely, the JupyterLab helper Galata is used to handle testing the extension in JupyterLab.

More information are provided within the ui-tests README.

Packaging the extension

See RELEASE

How to cite

When using the content of this repository, please cite the following two articles:

  1. D. Du, T. J. Baird, S. Bonella and G. Pizzi, OSSCAR, an open platform for collaborative development of computational tools for education in science, Computer Physics Communications, 282, 108546 (2023). https://doi.org/10.1016/j.cpc.2022.108546

  2. D. Du, T. J. Baird, K. Eimre, S. Bonella, G. Pizzi, Jupyter widgets and extensions for education and research in computational physics and chemistry, Computer Physics Communications, 305, 109353 (2024). https://doi.org/10.1016/j.cpc.2024.109353

Acknowledgements

We acknowledge support from the EPFL Open Science Fund via the OSSCAR project.

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

jupyterlab_mol_visualizer-1.0.2.tar.gz (2.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jupyterlab_mol_visualizer-1.0.2-py3-none-any.whl (2.3 MB view details)

Uploaded Python 3

File details

Details for the file jupyterlab_mol_visualizer-1.0.2.tar.gz.

File metadata

File hashes

Hashes for jupyterlab_mol_visualizer-1.0.2.tar.gz
Algorithm Hash digest
SHA256 3a3b6723eb1a7ce634100f9764eb0c299ba522984f7a1dd28d40801b525f63da
MD5 61a738a27fef7723d3833f0ce7521e48
BLAKE2b-256 68b989d33ff9cf95ddea76656ad813a377b823a0b88318380ead4cbdfb886e70

See more details on using hashes here.

File details

Details for the file jupyterlab_mol_visualizer-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for jupyterlab_mol_visualizer-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ec7cf16f6a0b63f1aad2d8bc6164055f0d50b1bbf8eaba3261817420dbcf273b
MD5 8a875e0bd92f3b6bf4316a294c10b2de
BLAKE2b-256 d4470124eaf887f202943bd1fb1c794949a280db625d49a1680ffeb23a0e6641

See more details on using hashes here.

Supported by

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