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.4.dev2.tar.gz (65.1 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.dev2-cp37-abi3-win_amd64.whl (6.5 MB view details)

Uploaded CPython 3.7+Windows x86-64

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

Uploaded CPython 3.7+Windows x86

cosmol_viewer-0.1.4.dev2-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.dev2-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.dev2-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.dev2-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.dev2-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.4.dev2.tar.gz.

File metadata

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

File hashes

Hashes for cosmol_viewer-0.1.4.dev2.tar.gz
Algorithm Hash digest
SHA256 fbe42bf556c7f9f7dc83c80af09fcf429a82b5e10dc2cd5033b25beef380887f
MD5 3d921ddc0843d24b354854e6e7bca715
BLAKE2b-256 efe0f94c4de2f2d8843aaeaf54d6bb9beef7d01462e4befe8a1f122631379e06

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.4.dev2-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 46a26f40fe087fd04245da5ffea68ee9e5e4aac1feb07e94e1cd583c7415c52c
MD5 8ddf1d40c18484d42f81f22facd55747
BLAKE2b-256 ca983349cf7aff403a4bf7dd0457c5cdafccdf518d5142c5be0128610e900e5f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.4.dev2-cp37-abi3-win32.whl
Algorithm Hash digest
SHA256 d0389bf9630d4fa5fff383ee0896822516814462a52096a301d5e8f54235fd02
MD5 957354172b879c868228db78b7268faa
BLAKE2b-256 100ba78a20d307a70762615b61a19831967d5e794d4a9f7c7d26f95bf66687e4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.4.dev2-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 35fd7801bde1659c783c6ecd964a9486641cf86f0c148d0094520d0f100f0bcb
MD5 ee60512895eb43e5c66b91d71e2d5f98
BLAKE2b-256 b3ae9418e3d08d56d752e9ee68840909f611cb52cb31b3f1d25d36309cab53f9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.4.dev2-cp37-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 3383a594516da47eb110688cd4950b63c1168e723a0229d2037d81d06d6a50fd
MD5 18f33204fc9c2b97ea1fffdb3bd365da
BLAKE2b-256 5f8f21dff2efc1271dd92d76584e8339701d3153b5e3052f59b8ddb0d3dfcbb4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.4.dev2-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c3971d59093c75bd292d008401dfd0f1ae465c61c149476dbf97ca797d0046b9
MD5 d91d002b1f594b9a62e8131faef46e6a
BLAKE2b-256 4840b6d916875f9779765d6b4b211ee20b7d35fc8e6d1f639dbd251f60b2f4fd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.4.dev2-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 66c75186689de5e9969430bd5d598bd2587c3712ac1116903aa0b4565d436c26
MD5 c55a25a7f599fe8d44291687371b4f0b
BLAKE2b-256 1f10e4bf12e2c49a3f448cf63a7d483dbac0b1e0165c86190ac5d7acc59550a8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.4.dev2-cp37-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 592e217fd360cdd4e9822f9110e4081f56d6888d9c92c7565362ec12bdf87111
MD5 91736bd2317b9bf06d37d2ca1c7cd95a
BLAKE2b-256 aa3309324a64634f9b4fb0122b4e3ebd16818af7605eebb111a57dcb3233250d

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