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
    
mol_data  = parse_sdf(open("molecule.sdf", "r", encoding="utf-8").read())

mol = Molecules(mol_data).centered()

scene = Scene()
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.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.tar.gz (89.6 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-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.3 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

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

Uploaded PyPymanylinux: glibc 2.17+ i686

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

Uploaded CPython 3.7+Windows x86-64

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

Uploaded CPython 3.7+Windows x86

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

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

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

Uploaded CPython 3.7+manylinux: glibc 2.17+ i686

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

Uploaded CPython 3.7+manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.7+macOS 11.0+ ARM64

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

Uploaded CPython 3.7+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for cosmol_viewer-0.1.5.tar.gz
Algorithm Hash digest
SHA256 5a742daf2425756bb073b4adb53fc2d2ba7a0bab45cb151b16e30fc3376ea8fd
MD5 2d81fe8c189510c109b510c510c0bf49
BLAKE2b-256 56323d0b5d1d4c92feb724d8e836b0ffc9cf3af8f454058bff70868b8af19fb3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0038cc8c50057d8c66a7b6a49ad548f65934f928534ec8895eaa1ce31e9dde2d
MD5 d5b9b2556bf49ab222a36f08fe516e2d
BLAKE2b-256 5577017fd2de76227d3e2478dcf9454294473049ef659ff5863449a53bf77ccb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5-pp311-pypy311_pp73-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 83a068d8c1733355b6797d428dda46d97d9ff10602ee6051d53e78b6b3d22102
MD5 dfc36bfde3059de13fd2cbf6df17a41f
BLAKE2b-256 c05cb95a0c783f7a12083da58e1890c0b421d149b7ce85b3982cbb77f240d53e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 a1a0b0c534f739838593798a9df66e69b33a185bcc0267b824894829e3e9e096
MD5 e91b69746e917f8a9dbd6dbd6714402b
BLAKE2b-256 9fbb16785d9cdc4450b84ab25f5e461b8ca37c0a0f010d781066ce58cb2a0c42

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5-cp37-abi3-win32.whl
Algorithm Hash digest
SHA256 eec6dd70adaee0dcebdd13909d369e83676abedc5c7e19671e72962b340577a3
MD5 78796235ebf27b1fb0ab1bf52c420243
BLAKE2b-256 ed691dfe93329d6e7cd7dcfa0dec71d898652853fa6f4787349a961b6589259a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ea7d6c86ee51ed311826f382a9051b8aed1cd1705923ef6786e5d6ddcc7b7939
MD5 7ffe53bb94662938b8639301dc50327b
BLAKE2b-256 a05050b36ad274569749e01e33374e84ebb846faffeb8bf5f715c292756bb041

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5-cp37-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 7e16b1b41f9ac01947c463c466747a3be41a0086c40bfe994ae1dcb337b874ec
MD5 6601068f432b43b8a92b5d137f8a4ac0
BLAKE2b-256 9f93a33c295d65f7ae309a379c065d08fbe272f1a8f33c6c0e9eeddeccd85c53

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e08e66b85e481bbe13b2e0fef0b6630c2578733963bfa4e1ae4f4bc753fa343d
MD5 a2532ad76d465da7abbe4781acfc677b
BLAKE2b-256 4e2937765d4451bb3ea1e52dd80986c5646130669ee4219cd2094e589b36b904

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a89e00aca0cc820ad16e181ca296662bdc3e3b5e28e971e51bf7cb9779e7bd96
MD5 e3ebbf33c4b170623060b8c5b0148ba1
BLAKE2b-256 cd5435158b1ef8cf7afabc6b5b4acd7070032d4889a94b7035d2747844903f13

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5-cp37-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 344caa0eeeed5804d4d82ba4f1199c895e37ee3cd015cff465f6cb7a794d2b04
MD5 373e5955fd3280b21e00df2d572b4a76
BLAKE2b-256 ae837f811bd8543e231389073ba4b999a9653f42b634d53f64f60e3eb4230abf

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