stspeck
The Speck molecule viewer for Streamlit, with the
same renderer and settings as the ipyspeck Jupyter widget: ambient occlusion,
cartoons, molecular surfaces (optionally transparent), metallic and glossy
materials, shadows, fog, outlines, highlighting, trajectories and unit cells.
pip install stspeck # Python 3.8+, Streamlit 1.20+
import streamlit as st
import stspeck
# Any structure as PDB or (extended) XYZ text
stspeck.speck(data=open("1ubq.pdb").read(), cartoon=True, surface=True, surfaceOpacity=0.35)
# Loaders return keyword arguments to splat into speck()
stspeck.speck(**stspeck.fetch_alphafold("Q8W3K0"), preset="cover", height=500)
stspeck.speck(**stspeck.fetch_pdb("4HHB"), highlight={"resName": "HEM"}, ghost=0.6)
stspeck.speck(**stspeck.from_ase(atoms), preset="metal") # also from_rdkit, from_pymatgen
- Settings: every ipyspeck setting is a keyword argument; see
stspeck.SETTINGSfor names and defaults, andstspeck.PRESETSfor named looks (preset="cover"). - Toolbar: styles, a looks menu, cartoon / surface / ligand toggles, standard views,
auto-rotate, tap to focus (or Alt-click), a depth-of-field toggle, a color menu for cartoon, surface and atoms,
and a camera button that downloads a high-resolution PNG
(
export_width=3000,export_scale=...). Toolbar choices persist across reruns. - Colors:
colorScheme="jmol"(speck, jmol, rasmol, newcpk) and per-elementatomColors={"Au": "#ffcc33"}('#rrggbb'or[r, g, b]in 0 - 1). - Touch and keyboard: one finger rotates, two fingers pinch to zoom and pan; arrows rotate, Shift+arrows pan, + / - zoom, 0 recenters, F focuses at the center.
- State: with
return_state=Truethe call returns the camera, the current settings andnframes; pass the camera back ascamera=to restore a view. - Trajectories: multi-frame XYZ or multi-model PDB; drive
frame=with a slider (stspeck.count_frames(data)gives the range).
Run the demo with streamlit run example/app.py.
Gallery
Rendered with the ipyspeck / stspeck renderer (see example/showcase.ipynb for the settings behind these looks). Click an image to open that scene in the live demo.
Macro photography (depth of field)
Gold nanoparticle, 923 atoms |
Copper surface |
Heme in hemoglobin (4HHB) |
Imatinib in ABL kinase (1IEP) |
Nucleosome DNA (1KX5) |
AlphaFold RPP7 repeat domain |
Proteins and complexes
Nucleic acids
Nucleosome (1KX5) |
Transfer RNA (1EHZ) |
G-quadruplex with K⁺ (1KF1) |
Chemistry and materials
Gold–thiolate cluster |
Copper crystal and unit cell |
SrTiO₃ perovskite |
MoS₂ monolayer |
Graphene |
Carbon nanotube |
C₆₀ buckminsterfullerene |
Taxol (paclitaxel) |
Chlorophyll a |
Caffeine |
For Jupyter, use ipyspeck, which has the same settings.
Development
The frontend (frontend/) bundles the viewer shared with ipyspeck (../core).
Build it with cd frontend && npm install && npm run build, which also compiles
../core. pip install . runs the same build when stspeck/static is missing.
License
BSD-3-Clause (see LICENSE). stspeck is based on Speck by wwwtyro,
which is in the public domain (see LICENSE-SPECK).
Release files for stspeck 0.8.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| stspeck-0.8.2.tar.gz | 77.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| stspeck-0.8.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 134.8 kB
Release files / stspeck-0.8.2.tar.gz
| Download URL | stspeck-0.8.2.tar.gz |
|---|---|
| Size | 77.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
34bb8cf0c2bc9f539148696aa8451761a74250182f277dac419bde847e65d959
|
|
BLAKE2b-256 checksum How to use checksums |
c14c0b8e1f6a97740ee9b2afd0e20198e3c1a42fb798cebf2cb4bfcb19563393
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Release files / stspeck-0.8.2-py3-none-any.whl
| Download URL | stspeck-0.8.2-py3-none-any.whl |
|---|---|
| Size | 57.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0c85a8ef2f92ff664ff6b941b356657fe5c5e66d9cdc8648a7adb753a6e8604d
|
|
BLAKE2b-256 checksum How to use checksums |
99c56b1514e1e7ef6837683a5d53c490e8c7bed2ebc5802d868d5b901b086a4f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|