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.dev4.tar.gz (76.2 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.dev4-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (10.9 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

cosmol_viewer-0.1.5.dev4-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.dev4-cp37-abi3-win_arm64.whl (7.2 MB view details)

Uploaded CPython 3.7+Windows ARM64

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

Uploaded CPython 3.7+Windows x86-64

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

Uploaded CPython 3.7+Windows x86

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

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

cosmol_viewer-0.1.5.dev4-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.dev4-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.dev4-cp37-abi3-macosx_11_0_arm64.whl (7.4 MB view details)

Uploaded CPython 3.7+macOS 11.0+ ARM64

cosmol_viewer-0.1.5.dev4-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.dev4.tar.gz.

File metadata

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

File hashes

Hashes for cosmol_viewer-0.1.5.dev4.tar.gz
Algorithm Hash digest
SHA256 8fc8b2a2e768adea2cb59a98db980d09a3f61d826f5aa7c0834c041b441bf987
MD5 80b1c8728e0bd7176c3dcdcad7a24986
BLAKE2b-256 b5bc61b1cc73071c5c942499999d5078e4a1a361f98a537facadce628b47f9c8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev4-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1d522a8007ea1d808b2b87e622d8f7ed886e03c113ff0fd3c67012d34ebfe1a6
MD5 bfea8f61c6ec99f31778d82611524a81
BLAKE2b-256 345fe23cb9fbc0bc94d358064de8286b521a71ebcf33e64787f75b9678c359d1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev4-pp311-pypy311_pp73-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 ba77daf9092956a42981ab9fcf916f642abc5bb086b516378be95115075ab2e0
MD5 1a87f53123c17e45b1a6f9ddbadd7637
BLAKE2b-256 d29fde7b1c3cb0223aeea2205c379933252bbed5c23132095500a3ec198d3ddc

See more details on using hashes here.

File details

Details for the file cosmol_viewer-0.1.5.dev4-cp37-abi3-win_arm64.whl.

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev4-cp37-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 8bdc85a18bd32901427371cebe87c73827330b991d7759693765c010fc6c867a
MD5 8a77cfbe7c2d299c8faaa44c5cdd9c46
BLAKE2b-256 c89167f9a206a18d4903537e09253ca4412623b2a8a2b37605cd59211a4eb9c6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev4-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 5112d39ea3416c606622c85aae1804e005a2c66bbfe9409e74dc44444124aa43
MD5 265eb11eb4b12ab945a490c2883251e2
BLAKE2b-256 226499591652f1d4b9b7980b9c21511808e0cd251c243624f95a5aa60c4f28dd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev4-cp37-abi3-win32.whl
Algorithm Hash digest
SHA256 43acc57da998ac2b8b9ab2171adb0b95cee3e0ce17102875dd6fbed3a6bc6a00
MD5 ffb32a4d249d0655b67ae083b7849872
BLAKE2b-256 84dc441c55593550e101507af81d0c98ab4a696c063da56dd0e42f5fc26a638b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev4-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 95f53355ca228bc20b1c672859dc6644a02343819cfe31a47a7d9adaa77bd881
MD5 ad8460a8b2d241e125ba00686f5889f8
BLAKE2b-256 29b7b36a9e4a42ef9896928b872db0ed04af38130e411cdc56ab9bdc59f55a26

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev4-cp37-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 8ac63b2a4d21af19c2d1fb0bc3f67e3bbeced0f0fdaee6f128189f3bc820d1c9
MD5 4a31aa5e0bd600b4f7297c6c921fa4a6
BLAKE2b-256 fb67f9d189a7f88487adaac01675d02909eef5f1b8a6f61d1cf12ca57a74f297

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev4-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c42950e9ea041cdc23c1b9fa01faebc6518d47eaf628b0bf4105189630f0281f
MD5 5dd63016b7e8defb57cb771d8261a1d1
BLAKE2b-256 ac1cae1f092b87c9a1751db01ec2928b075b691a2f4630c7e986e6cccceef0ea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev4-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 df2e612b132e637e80b9835788eb439d3a24a91e321c64ae3bcd36a6157d0c0d
MD5 aa7755aa2bed92815d465759b59bdf87
BLAKE2b-256 4b23e589ca830cf7a5637d84305f113d95054232df4fb72e4c83bfd3ca196ce0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev4-cp37-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 9a39e75e74ec6485d449fb17f32f58298f37749954af6d865b9fca632c0a4a92
MD5 351b3f30ce65cbc94d94e8419295a1c5
BLAKE2b-256 e75f150fb6f72fb2e079ee23b80db36d246612513e8599f077cc5790201812e6

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