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.dev6.tar.gz (87.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.dev6-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.dev6-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.dev6-cp37-abi3-win_amd64.whl (7.5 MB view details)

Uploaded CPython 3.7+Windows x86-64

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

Uploaded CPython 3.7+Windows x86

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

File metadata

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

File hashes

Hashes for cosmol_viewer-0.1.5.dev6.tar.gz
Algorithm Hash digest
SHA256 fe6ee60007c6e6e0671703858fe4a520085f04f26464c3a9ff8795eec8a61a71
MD5 04078ceaff696175d89f0d61e4589035
BLAKE2b-256 756b2622d6602a18915438574d6a08de5e572849199a6834526c6ba2f63ac252

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev6-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cd0f84b8ec569cdb4029c1dc3765c6096688aee4234286171dfa33808c842072
MD5 d2533411b563590cca53d42dedc62ee4
BLAKE2b-256 6f5cb827ad838cb0da16bdc534451c1db015c446b462fcd8700557621ccdc45f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev6-pp311-pypy311_pp73-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 4ee41fbaa4054695bb2b07ae0436c0f471a64f5882a5273c2ddc5ffbc71989a6
MD5 0c6757ab482df29df7a042df8480b5f3
BLAKE2b-256 ad249c12c408531254fd294025899f82a7c61683865cc59981612aee309a9b90

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev6-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 fa09d879f0b3bc0147e34236ebaef95684e0ed1f092d538c122d13e4dc645acb
MD5 2d060ace054a5446f96d64eea2bd491d
BLAKE2b-256 0624924087f2991b9974ded57adec3684d08d4ada6753d3f387c4121b5118c57

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev6-cp37-abi3-win32.whl
Algorithm Hash digest
SHA256 47c4c18ed77b11a73828b84d623e395ef4c38034c98ac53f216392495c39222c
MD5 e6254d9d1fda912afad7a7e91b3fc1ea
BLAKE2b-256 89ab76b7baf2536ecf20e193a594e6453a19b042396185c3a2b3fa29b682863d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev6-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 df4649a96ec5d678230d792526e8f0429bfc9e5bb2d9d58609f43b5ecba6217d
MD5 f3ef152576f4107c05b3f9ac8e8a8a4c
BLAKE2b-256 bc8558ace989c45c2f806120010f7e40c05ef0cf6b035f5aad7fbf50248ce31d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev6-cp37-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 1bb08be8d4528a761a325d833c9bb845f5b4319284d4bf09450809098272c41d
MD5 75653c8868a85fe46c0db588271d5c82
BLAKE2b-256 fd1fc98466e887ab18549f775822dc4b8e27411df6d851ac279322848b31f701

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev6-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 209c9d8e4f3cf0d2826dc7bead0a514a681ad0535db2330b6d7b8b74b2b43201
MD5 e2ba7a4759a49420341a0246ea4274fd
BLAKE2b-256 d9f2688c06285d270de5b05a3956283fe4512868395d2b5bb8250c0333c50674

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev6-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9decec976528f1e914bab883b2e30130f85310ec939bddbc2a429e07ea429d2d
MD5 52eda9e3c75dc1eab43b00802a8d681d
BLAKE2b-256 a006da588f63d9c1813b87d40a7e1dd3324e32c826f4bc3db03e822c9484da98

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev6-cp37-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 73d72432d0ba2ba480d39ef90f9c93f0721c99a862958861fbd1f1a32f924fc8
MD5 486b8ca07dc440fac40f3951dc8e083b
BLAKE2b-256 a12ed9ede9426b78357ac84732030f888630e399a8a0ee3f3dc883a62c1599c0

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