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

Uploaded CPython 3.7+Windows x86-64

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

Uploaded CPython 3.7+Windows x86

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

File metadata

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

File hashes

Hashes for cosmol_viewer-0.1.5.dev5.tar.gz
Algorithm Hash digest
SHA256 3c66eaf7f251f89953e33dafe25a6c6c39b1dfc7818a441b637ab10e4e241dc9
MD5 7ab982e0916592edbda193f17b18ac94
BLAKE2b-256 f4ad9153fe69eccb0228fa2a48847d167093c5e2325c6e6e1802c7bd50fa07bb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev5-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ea7f94b27594fbc145796315fc0443394d28047a0646dc9fed4f0de8814f05e3
MD5 15bec86fbcf873deee7a3344bc0a736a
BLAKE2b-256 3996793fa548845866b9eb628c63452c5467dfbf00e8877ffe23793540df58fb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev5-pp311-pypy311_pp73-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 84857ba1db83ca04b4260fa19932d76cff6f6d82be6738265a9a87ecbcf3d761
MD5 28a797f3f947be6bf7deac19c4a758ec
BLAKE2b-256 3b3583494a77b82316cf755abf822d9ae47e45bcecef707cef8bd2d86260feb5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev5-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 9613877c575f1c8a646b44ae13d33a786917d72b11a5028fce50b5933868fdb7
MD5 b498c879c5fbb78c673c55218a979f2e
BLAKE2b-256 d306cc4c517c052f86bc2dbeede5d71889e5f0df2588062c7061caa14bfa1760

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev5-cp37-abi3-win32.whl
Algorithm Hash digest
SHA256 3fa9b3d5ad2b39c412db88e8f22a409efe73ecaf06710de222d443f321b43edc
MD5 61561b3f9b61115b2a93a07248fa7e85
BLAKE2b-256 45ce69cbf18d659265c72add1616c887974f2aa148a9f3f3403b85cbec0a95c0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev5-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cdf81de823e25bc682a4981b010cc129a4f15f37d2ec0eb087f6ef2336095f4e
MD5 9a5451cafa51acc31fa1714b1b9082bc
BLAKE2b-256 e60fa96f1068b6d4768ecb3c14d717ed5622424e974fed293a9f002fb591b297

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev5-cp37-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 19d18129a7dd19bd598ac44509875bb40f55f8b67c75bce981a5431ec0525be7
MD5 ba41e7e63406fa5f3f244755fc112768
BLAKE2b-256 4c40f4576c3eac2fde5a8265d5de7d8bb2683389ff54e352a38e2057989c74b6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev5-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d868343c8a430c869ed56bf9ea4a1c52665bc1fde40c888e8de11dfe78360a0f
MD5 9fe89d8e5091a4bb4bd57b4d5c4cd9e0
BLAKE2b-256 0b752f6f9773f5df74aa8799b8b0a578b3a08138d04d9a0676f4389b66bbb85a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev5-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b45059240d4e6d9a27560a8c3e46f78d62cb42988233a3d4bdb4b183b26958f9
MD5 b8d8ec7b40ce84d32c1132aabbdc6397
BLAKE2b-256 e871f48456e9a531c90c41b19ccd6e73a3adda7dbc11e5376a18dd61d21b56d1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev5-cp37-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 aee455e239ef7c7214f9802b38cdba7a69f61fe68a3601810a4b39f6c04a1407
MD5 a0153f44fde6959ee743b3f718f6c084
BLAKE2b-256 596e2b7d9ccdc3b4cee985ddeebfbfee6cb9fb6acd94bbcafad33d73b7dbfe71

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