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

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.3.dev4.tar.gz (63.9 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.3.dev4-cp37-abi3-win_amd64.whl (6.5 MB view details)

Uploaded CPython 3.7+Windows x86-64

cosmol_viewer-0.1.3.dev4-cp37-abi3-win32.whl (6.3 MB view details)

Uploaded CPython 3.7+Windows x86

cosmol_viewer-0.1.3.dev4-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.7 MB view details)

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

cosmol_viewer-0.1.3.dev4-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (9.5 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ ARM64

cosmol_viewer-0.1.3.dev4-cp37-abi3-macosx_11_0_arm64.whl (6.4 MB view details)

Uploaded CPython 3.7+macOS 11.0+ ARM64

cosmol_viewer-0.1.3.dev4-cp37-abi3-macosx_10_12_x86_64.whl (6.6 MB view details)

Uploaded CPython 3.7+macOS 10.12+ x86-64

File details

Details for the file cosmol_viewer-0.1.3.dev4.tar.gz.

File metadata

  • Download URL: cosmol_viewer-0.1.3.dev4.tar.gz
  • Upload date:
  • Size: 63.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.9.4

File hashes

Hashes for cosmol_viewer-0.1.3.dev4.tar.gz
Algorithm Hash digest
SHA256 774f5d7b1282f895c65deaf2bde94db6840bd5318295b5253cecdb0090d0e988
MD5 bc617b121ff8b13053dac4a22dc8c160
BLAKE2b-256 89beba784311334ff652d4dbb42004db09c821d5a4bf3968f5d6c6901df55d5c

See more details on using hashes here.

File details

Details for the file cosmol_viewer-0.1.3.dev4-cp37-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for cosmol_viewer-0.1.3.dev4-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 acbb66e1ed9e786694a6d4ea6f629fd16f7ea8fde743c36c37e58e67542da331
MD5 d1b6ee7a209e34406dde1717694d5786
BLAKE2b-256 085648b01665ab825d6f65daeae6bcbf3cace11fefcc88a2aefe9b4b31e1291c

See more details on using hashes here.

File details

Details for the file cosmol_viewer-0.1.3.dev4-cp37-abi3-win32.whl.

File metadata

File hashes

Hashes for cosmol_viewer-0.1.3.dev4-cp37-abi3-win32.whl
Algorithm Hash digest
SHA256 cdb812c54988282e3800fff4b7c766743053d82e0ab1fcba2b2d3b93d90d59bd
MD5 76c84634e754deb497d6ce8cf2e1762f
BLAKE2b-256 6397b380bc22915c9f158003e45193841eff346737bca0a5ad08c08540a8e812

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.3.dev4-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a38e56d8beb5bbe0fc6c2cc94bae3898930649f8a175b2a318f4af308bfea1fe
MD5 c8f5c8c19aa0bbfc1850ec2303c1b374
BLAKE2b-256 212bae65f32efeb9d8fec07db6acc795073a9899340ad444c03e2fd13352eb0e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.3.dev4-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 bf2798d40a2578c5e5661ea4a0d81409dffcac3c1afad6e501e398a2d641d286
MD5 37420157b555c48e446fe2b2fde9f20d
BLAKE2b-256 5e60af2756de4662cc29836200b7797695633249e2c9149e8d410e617ae9db65

See more details on using hashes here.

File details

Details for the file cosmol_viewer-0.1.3.dev4-cp37-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cosmol_viewer-0.1.3.dev4-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6e2767f880a18058c1dfca061476b3269f7532fcd44cc4324860c185374f04e1
MD5 b9bcb021e4d94092df91268c100cb403
BLAKE2b-256 299861f07c511c8b5bcef5f2d69e7fc128489e90cd08169bc5fc94a75b3da9c0

See more details on using hashes here.

File details

Details for the file cosmol_viewer-0.1.3.dev4-cp37-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for cosmol_viewer-0.1.3.dev4-cp37-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 6255a3cea68af38d1d9e5a9022283203ade8054ba80fb102b34bfbb49890e873
MD5 f07b569d1d192421ffa53ec77bb0b8b1
BLAKE2b-256 84fc62b7696f5cae2aa2f360a3f4657b68b73010c34cf16c433513e3e7403c9e

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