Skip to main content

Molecular visualization tools

Project description

COSMol-viewer

A high-performance molecular viewer for Python and Rust, backed by Rust. Supports both static rendering and smooth animation playback — including inside Jupyter notebooks.

A compact, high-performance renderer for molecular and scientific shapes with two usage patterns:

  • Static rendering + update — push individual scene updates from your application or simulation.
  • Play (recommended for demonstrations & smooth playback) — precompute frames and hand the sequence to the viewer to play back with optional interpolation (smooth).

Quick concepts

  • Scene: container for shapes (molecules, spheres, lines, etc.).
  • Viewer.render(scene, ...): create a static viewer bound to a canvas (native or notebook). Good for static visualization.
  • viewer.update(scene): push incremental changes (real-time / streaming use-cases).
  • Viewer.play(frames, interval, loops, width, height, smooth): recommended for precomputed animations and demonstrations. The viewer takes care of playback timing and looping.

Why prefer play for demos?

  • Single call API (hand off responsibility to the viewer).
  • Built-in timing & loop control.
  • Optional smooth interpolation between frames for visually pleasing playback even when input frame rate is low.

Why keep update?

  • update is ideal for real-time simulations, MD runs, or streaming data where frames are not precomputed. It provides strict fidelity (no interpolation) and minimal latency.

Installation

pip install cosmol-viewer

Quick Start

See examples in Google Colab.

1. Static molecular rendering

from cosmol_viewer import Scene, Viewer, parse_sdf, Molecules

with open("molecule.sdf", "r") as f:
    sdf = f.read()
    mol = Molecules(parse_sdf(sdf)).centered()

scene = Scene()
scene.scale(0.1)
scene.add_shape(mol, "mol")

viewer = Viewer.render(scene, width=600, height=400)

print("Press Any Key to exit...", end='', flush=True)
_ = input()  # Keep the viewer open until you decide to close

2. Animation playback with Viewer.play

from cosmol_viewer import Scene, Viewer, parse_sdf, Molecules
import time

interval = 0.033   # ~30 FPS

frames = []

for i in range(1, 10):
    with open(f"frames/frame_{i}.sdf", "r") as f:
        sdf = f.read()
        mol = Molecules(parse_sdf(sdf)).centered()

    scene = Scene()
    scene.scale(0.1)
    scene.add_shape(mol, "mol")

    frames.append(scene)

Viewer.play(frames, interval=interval, loops=1, width=600, height=400, smooth=True)

Documentation

For API reference and advanced usage, please see the latest documentation.

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

cosmol_viewer-0.1.5.dev7.tar.gz (87.4 kB view details)

Uploaded Source

Built Distributions

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

cosmol_viewer-0.1.5.dev7-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.0 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

cosmol_viewer-0.1.5.dev7-pp311-pypy311_pp73-manylinux_2_17_i686.manylinux2014_i686.whl (11.5 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ i686

cosmol_viewer-0.1.5.dev7-cp37-abi3-win_amd64.whl (7.5 MB view details)

Uploaded CPython 3.7+Windows x86-64

cosmol_viewer-0.1.5.dev7-cp37-abi3-win32.whl (7.3 MB view details)

Uploaded CPython 3.7+Windows x86

cosmol_viewer-0.1.5.dev7-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.0 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ x86-64

cosmol_viewer-0.1.5.dev7-cp37-abi3-manylinux_2_17_i686.manylinux2014_i686.whl (11.5 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ i686

cosmol_viewer-0.1.5.dev7-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (10.8 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ ARM64

cosmol_viewer-0.1.5.dev7-cp37-abi3-macosx_11_0_arm64.whl (7.5 MB view details)

Uploaded CPython 3.7+macOS 11.0+ ARM64

cosmol_viewer-0.1.5.dev7-cp37-abi3-macosx_10_12_x86_64.whl (7.6 MB view details)

Uploaded CPython 3.7+macOS 10.12+ x86-64

File details

Details for the file cosmol_viewer-0.1.5.dev7.tar.gz.

File metadata

  • Download URL: cosmol_viewer-0.1.5.dev7.tar.gz
  • Upload date:
  • Size: 87.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.10.2

File hashes

Hashes for cosmol_viewer-0.1.5.dev7.tar.gz
Algorithm Hash digest
SHA256 b68427065f542b939683c2c34be061734f75c4ae2d0718d1161056148e895bdf
MD5 c7202983a0a348374dabaf95a1b21ce0
BLAKE2b-256 2cf98375a1b3543e38aff5240b69b9121325cc1e4e613ce80cfba7c6a0654832

See more details on using hashes here.

File details

Details for the file cosmol_viewer-0.1.5.dev7-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev7-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1f8fc3de20b67da571ae71bc8369670491ba4aeb0570d9f4271f62284094dc49
MD5 1aa3fd0da1a4fb74fc9f9fb6c58c04e4
BLAKE2b-256 b6f8e8a86f55689feb021069651fd724be5bc14e7b2a840a2378caad23024037

See more details on using hashes here.

File details

Details for the file cosmol_viewer-0.1.5.dev7-pp311-pypy311_pp73-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev7-pp311-pypy311_pp73-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 975d89b5d860081c972fb19e127ce311681d65a44cc10b194df72f22a65385e8
MD5 607beffde7d49c07f9aef76a160c34c2
BLAKE2b-256 82169d99e8a206b985b30998adb17ac12a57d32c2c55b8dc8b99254f783b31f6

See more details on using hashes here.

File details

Details for the file cosmol_viewer-0.1.5.dev7-cp37-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev7-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 ef01e7feb5649f86ebc45766936d643e1b13c32e720df90d3a286ff687353611
MD5 f9245a18e6ebc6d12fff1e4a368199ef
BLAKE2b-256 adbd48e855a619266a435e414756ec0ea6fcffcf1ca0f844d9359c3b7a4e6fb4

See more details on using hashes here.

File details

Details for the file cosmol_viewer-0.1.5.dev7-cp37-abi3-win32.whl.

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev7-cp37-abi3-win32.whl
Algorithm Hash digest
SHA256 7f4358fa5c8e8e54807987af4e72217fd2265596d3d13d105741d0000ccde8c5
MD5 d834925b4d373d2eeae86ccddeeb28e5
BLAKE2b-256 0d70f36567ade86b41c0e5a7b585aa7d6bcad193edd656fb10a8c50146ee8868

See more details on using hashes here.

File details

Details for the file cosmol_viewer-0.1.5.dev7-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev7-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cb8df6b558aa2c5feda89a1c7cb8a730eb9376dd583435ce4ddbeb92683066d6
MD5 1897e83b16abe0e654fe5634e8f1e38e
BLAKE2b-256 4a742fd7eb9e53c499eace10cd69f4324f3ea277d5fb6d35669810e24c816a66

See more details on using hashes here.

File details

Details for the file cosmol_viewer-0.1.5.dev7-cp37-abi3-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev7-cp37-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 31d794714f2633b1d7f6a3b41f86c436929e23b2367165e7a2b6debd05bce44f
MD5 0671a5a04993bb4f560f9549d912fef0
BLAKE2b-256 81a2f29bac00a82da9fee9dc1d41945aa0845ac047bbf15dc4915353180c1216

See more details on using hashes here.

File details

Details for the file cosmol_viewer-0.1.5.dev7-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev7-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 fd4bc51a59682307f40f207bfb5f335b3e607731e2481db5eaa00c161efaa6a3
MD5 67026d4bead3dfc2a1a1799d591059da
BLAKE2b-256 aba8a48ea412c1ef27470df55795b9520d2c612c021602a88a41091a24cc593f

See more details on using hashes here.

File details

Details for the file cosmol_viewer-0.1.5.dev7-cp37-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev7-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 df85935e581f6711902ea403f2c571f5601ba03c1ba3a9999e830bb50e9bf7ac
MD5 560b76fd6d9ae80e0236e2ddad72e7aa
BLAKE2b-256 9dc4767e61751c5722893cf090ed79bf9b7265bdc39dde6108606ee29be97d78

See more details on using hashes here.

File details

Details for the file cosmol_viewer-0.1.5.dev7-cp37-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev7-cp37-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 8ff8c5054ca15133395fcdeceb248b74f41e796a7eaa7795f4910aac2af6ff01
MD5 7df974b83ea25a7b9ac5952b1c7eb314
BLAKE2b-256 7e760c905b2d8bd05e71e79203b64387ae3ae1bf9cc56ad16a3c990043c40fd8

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