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.4.tar.gz (65.4 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.4-cp37-abi3-win_arm64.whl (6.1 MB view details)

Uploaded CPython 3.7+Windows ARM64

cosmol_viewer-0.1.4-cp37-abi3-win_amd64.whl (6.4 MB view details)

Uploaded CPython 3.7+Windows x86-64

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

Uploaded CPython 3.7+Windows x86

cosmol_viewer-0.1.4-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.4-cp37-abi3-manylinux_2_17_i686.manylinux2014_i686.whl (10.1 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ i686

cosmol_viewer-0.1.4-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.4-cp37-abi3-macosx_11_0_arm64.whl (6.4 MB view details)

Uploaded CPython 3.7+macOS 11.0+ ARM64

cosmol_viewer-0.1.4-cp37-abi3-macosx_10_12_x86_64.whl (6.5 MB view details)

Uploaded CPython 3.7+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for cosmol_viewer-0.1.4.tar.gz
Algorithm Hash digest
SHA256 b7c91d6a92d75bb4e58011721e852377c3aadc50a13670118c731797929eaee2
MD5 fba334978e1f522c0b349c1946915cb1
BLAKE2b-256 f2b0e4698fead480c89cbed4c5fddddf6265284d6d25b82138cd8bd65074cfe7

See more details on using hashes here.

File details

Details for the file cosmol_viewer-0.1.4-cp37-abi3-win_arm64.whl.

File metadata

File hashes

Hashes for cosmol_viewer-0.1.4-cp37-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 5eb24491d760e211eb3b116f22f554e4cbd9a777dad15fc1cba233909606f1d1
MD5 703d8a9dc4d8c04e7438b6183bea12d4
BLAKE2b-256 f911905e8816d6f97c1798781b78c83bb7bda119ead3b2634f438459d78ae183

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.4-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 7b5783bb5f16955f4afa8b907df2e6c0de04ad001da75ce5af2a63a7302949fe
MD5 f2963bfb3235519dbebfa63babfa85e6
BLAKE2b-256 689f80759e756689831667c2009dfda0f0f05ad42d06541dc989aa4d742af306

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.4-cp37-abi3-win32.whl
Algorithm Hash digest
SHA256 44e7925fdc0963ac0172205fd9dce229a813fe6f19e44192c14740370adfe375
MD5 7fc64c6b15ddd2cdc27d87f07974ac65
BLAKE2b-256 c9ce9ad10f2bec2e7cca76409c9f480912014dbd4c1175b6e4ec307c054b59e4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.4-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 27384c6a0bd77602ffd526285da9cac2829f56538b5deba8bd13c01e11cdade1
MD5 98da4e9f6148891799f2645da8b30b4c
BLAKE2b-256 064f231737566fa959cbdd0e1163a7aee04dec6675ea7476fa1b167dc31f5e4a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.4-cp37-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 78f851165dcaa9d1f7393c0711752b8bac426ec24c5f5a7f527d24666ffbe7ad
MD5 3276057c4d9f70b30e11516df1eb0259
BLAKE2b-256 bc19c4ed57ded5d227e450b8daf569d5e2ff7b7f4ff9cf5a1eb257d23907ce7f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.4-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d1081cebdd028a58d8d0e0aa2b18b988804600cba1fbad85197c3676066ddd97
MD5 0b6ab9d4aa6fa676d7b18e257d8b502e
BLAKE2b-256 8960de4f9795b18ad25b4b7d523919fcaf19c4f8a830077dda035e7ae7bdf907

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.4-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 37b83f0c07784362d408e23c418776ace372da184b9cb964ae4c8555b35d4b6d
MD5 ce0dc55e09ab339c4241eb47fa0ae2cf
BLAKE2b-256 528a4fa9fbeb34e85803041e714f7c899d09ba62bc0bd7581e498b0e19d75860

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.4-cp37-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 6dd0465e70465e9f8135cab493deb97333f6d48374fb9a0c68a578d9fd481f15
MD5 be7235bc0b737835a89b46f2ab1933c8
BLAKE2b-256 87b5618d086e03652558eebda19bcc21964641f512e0ab2a849c18078dec09b8

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