A package to create interactive molecular visualizations using Plotly
Project description
plotlyMol
Interactive molecular visualizations with Plotly. Supports SMILES, XYZ, MOL/PDB, and cube orbitals.
Features
- 3D ball-and-stick, stick, and VDW representations
- SMILES-to-3D embedding via RDKit
- XYZ, MOL/SDF (single), and PDB input support
- Cube file orbital isosurfaces
- Vibrational mode visualization (Gaussian, ORCA, Molden formats)
- Static displacement arrows
- Animated vibrations with interactive controls
- Heatmap coloring by displacement magnitude
- Streamlit GUI for interactive exploration
Installation
From source (recommended for now)
git clone https://github.com/The-Schultz-Lab/plotlyMol.git
cd plotlyMol
# Create and activate the conda environment (includes all dependencies)
conda env create -f environment.yml
conda activate plotlymol
# Install the package in editable mode
pip install -e .
Note: Conda is required. If you don't have it, install Miniforge (recommended) or Miniconda. All packages are installed from the
conda-forgechannel.
Updating the environment
If environment.yml changes after pulling new commits:
conda env update -f environment.yml --prune
Quick start
from plotlymol3d import draw_3D_rep
# Draw a molecule from SMILES
fig = draw_3D_rep(smiles="CCNCOCSC", mode="ball+stick", ambient=0.1)
fig.show()
# Draw from XYZ file
fig = draw_3D_rep(xyzfile="path/to/file.xyz", mode="ball+stick", ambient=0.1)
fig.show()
Orbitals from cube files
from plotlymol3d import draw_3D_rep
fig = draw_3D_rep(
cubefile="path/to/file.cube",
molfile="path/to/file.mol",
mode="ball+stick",
ambient=0.1,
cubedraw="orbitals",
orbital_opacity=0.25,
orbital_colors=["darkorange", "darkblue"],
)
fig.show()
Vibrational mode visualization
Visualize molecular vibrations from quantum chemistry calculations. Supports Gaussian .log, ORCA .out, and Molden .molden files.
Static displacement arrows:
from plotlymol3d import draw_3D_rep
fig = draw_3D_rep(
smiles="O", # Water molecule
vibration_file="water_freq.log",
vibration_mode=1, # First vibrational mode
vibration_display="arrows",
vibration_amplitude=1.5,
)
fig.show()
Animated vibration:
from plotlymol3d import parse_vibrations, create_vibration_animation
from rdkit.Chem import MolFromSmiles, AddHs
from rdkit.Chem.AllChem import EmbedMolecule
# Parse vibration data
vib_data = parse_vibrations("water_freq.log")
# Create molecule
mol = MolFromSmiles("O")
mol = AddHs(mol)
EmbedMolecule(mol)
# Generate animation
fig = create_vibration_animation(
vib_data=vib_data,
mode_number=1,
mol=mol,
amplitude=0.5,
n_frames=20, # Smoother with more frames
mode="ball+stick"
)
fig.show()
Heatmap coloring by displacement:
from plotlymol3d import draw_3D_rep, parse_vibrations, add_vibrations_to_figure
# Create molecular figure
fig = draw_3D_rep(smiles="O", mode="ball+stick")
# Parse vibrations and add heatmap
vib_data = parse_vibrations("water_freq.log")
fig = add_vibrations_to_figure(
fig=fig,
vib_data=vib_data,
mode_number=1,
display_type="heatmap",
heatmap_colorscale="Reds"
)
fig.show()
Available parsers:
from plotlymol3d import (
parse_gaussian_vibrations, # Gaussian .log files
parse_orca_vibrations, # ORCA .out files
parse_molden_vibrations, # Molden .molden files
parse_vibrations, # Auto-detect format
)
# Auto-detect format from file extension
vib_data = parse_vibrations("calculation.log")
# Access mode data
for mode in vib_data.modes:
print(f"Mode {mode.mode_number}: {mode.frequency:.1f} cm⁻¹")
if mode.ir_intensity:
print(f" IR Intensity: {mode.ir_intensity:.1f} km/mol")
GUI
Launch the Streamlit app for interactive controls:
streamlit run examples/gui_app.py
Examples
Demo Scripts
- Demo script:
python examples/demo_visualizations.py - Package data includes sample XYZ/MOL/CUBE files under src/plotlymol3d/
Jupyter Notebooks
Vibration Visualization:
- Vibration Visualization Basics - Getting started with vibrational modes
- Advanced Vibration Analysis - Batch processing, IR spectra, publication figures
Performance Testing:
- Performance Benchmarking - Quantitative performance analysis and optimization
Launch notebooks:
jupyter notebook examples/
Performance Testing
Quantitatively measure and optimize rendering performance:
Standalone script:
python tests/test_performance.py
Interactive notebook:
jupyter notebook examples/performance_benchmarking.ipynb
Full guide: Performance Testing Guide
Key metrics tracked:
- Rendering time vs molecule size
- Resolution impact (8-64)
- Memory usage profiling
- Vibration parsing speed
- Animation generation performance
Use these tools to identify bottlenecks and optimize GUI responsiveness.
Repository layout
plotlyMol/
├─ src/
│ └─ plotlymol3d/ # Library package code + sample data files
├─ examples/ # Demo scripts and GUI app
├─ tests/ # Pytest suite
├─ docs/ # Roadmap and documentation assets
├─ pyproject.toml # Packaging and tooling configuration
├─ requirements.txt # Consolidated dependencies
└─ README.md
Roadmap
See the current roadmap in docs/ROADMAP.md.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file plotlymol-0.2.0.tar.gz.
File metadata
- Download URL: plotlymol-0.2.0.tar.gz
- Upload date:
- Size: 1.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ef7dc36bae20786cff746737eafed88efa4c26bec5c63a45da8dc226605aa7b
|
|
| MD5 |
1da53085716fa310fadb6ab3ff616e83
|
|
| BLAKE2b-256 |
a047cf0420484716cdb96c9e4363496594265341249114cf27259bfdd6814b6e
|
Provenance
The following attestation bundles were made for plotlymol-0.2.0.tar.gz:
Publisher:
publish.yml on The-Schultz-Lab/plotlyMol
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
plotlymol-0.2.0.tar.gz -
Subject digest:
7ef7dc36bae20786cff746737eafed88efa4c26bec5c63a45da8dc226605aa7b - Sigstore transparency entry: 1333009512
- Sigstore integration time:
-
Permalink:
The-Schultz-Lab/plotlyMol@687b785785ac849473cb95cc10d7d6f094f3b0c7 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/The-Schultz-Lab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@687b785785ac849473cb95cc10d7d6f094f3b0c7 -
Trigger Event:
push
-
Statement type:
File details
Details for the file plotlymol-0.2.0-py3-none-any.whl.
File metadata
- Download URL: plotlymol-0.2.0-py3-none-any.whl
- Upload date:
- Size: 1.3 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1989d3efa68c60ce6f1de03b780762d6bf8cefdc4272db14a72b1769b940024d
|
|
| MD5 |
5b67711a571fb8ad741335a7d84159d1
|
|
| BLAKE2b-256 |
de5ac3c7b15c276580ffc6ef9fad896f798a5776860ad1f9473392610531ec70
|
Provenance
The following attestation bundles were made for plotlymol-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on The-Schultz-Lab/plotlyMol
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
plotlymol-0.2.0-py3-none-any.whl -
Subject digest:
1989d3efa68c60ce6f1de03b780762d6bf8cefdc4272db14a72b1769b940024d - Sigstore transparency entry: 1333009592
- Sigstore integration time:
-
Permalink:
The-Schultz-Lab/plotlyMol@687b785785ac849473cb95cc10d7d6f094f3b0c7 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/The-Schultz-Lab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@687b785785ac849473cb95cc10d7d6f094f3b0c7 -
Trigger Event:
push
-
Statement type: