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.dev8.tar.gz (91.3 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.dev8-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.dev8-pp311-pypy311_pp73-manylinux_2_17_i686.manylinux2014_i686.whl (11.6 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ i686

cosmol_viewer-0.1.5.dev8-cp37-abi3-win_amd64.whl (7.6 MB view details)

Uploaded CPython 3.7+Windows x86-64

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

Uploaded CPython 3.7+Windows x86

cosmol_viewer-0.1.5.dev8-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.dev8-cp37-abi3-manylinux_2_17_i686.manylinux2014_i686.whl (11.6 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ i686

cosmol_viewer-0.1.5.dev8-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (10.9 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ ARM64

cosmol_viewer-0.1.5.dev8-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.dev8-cp37-abi3-macosx_10_12_x86_64.whl (7.7 MB view details)

Uploaded CPython 3.7+macOS 10.12+ x86-64

File details

Details for the file cosmol_viewer-0.1.5.dev8.tar.gz.

File metadata

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

File hashes

Hashes for cosmol_viewer-0.1.5.dev8.tar.gz
Algorithm Hash digest
SHA256 0003c24a4a5334b2c4ed6b849ae5420f27eb36c6259fe7165fec104698cf57f9
MD5 0a38c34c4bc3681e839f794f5ec4bfab
BLAKE2b-256 390f224370664aeefb13b9c08af7fb70a18c3b5fa02999266be72d411b366153

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev8-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 142ed0615d0776b916137631cf321dcb576ab06bd9a5de7571d06d01a9489719
MD5 ef1d322c5d15f962db3c447c19b39da1
BLAKE2b-256 c531076db5a8da87ee15a5ddfa161255f7c2122be9ff9a0af5c4218674ddaa53

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev8-pp311-pypy311_pp73-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 b43daebe039ad28b0e17b47e6ffdd4b296f9aa67a8580bfb2680e96df6d554b3
MD5 0e6167a1dd89bdacec74072f02efc626
BLAKE2b-256 2f0f3cf58a0a3ba67a54d803334806bb2a6e3dbff0548ee50328331bb579e992

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev8-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 39a4a0eed4b22c43999b69c33f664392b20348a41b79998cbfaccfb6ea685896
MD5 f21548d5f9861494b40d70f396444ae4
BLAKE2b-256 72a12c7b6a91ec7eaf12462567d112e32bcd7c44a261380e3e2d97cb45032d15

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev8-cp37-abi3-win32.whl
Algorithm Hash digest
SHA256 ccf6750b5baa286dab9cd646eb9907da402bedd832b0822b9c8b7c1c961f976e
MD5 921abc116fef242771d7f7279692b207
BLAKE2b-256 4b28d4bc2b4327f36ebc5170e033645d852293c8f7e5d42e2ed76506b7a9e023

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev8-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 488e900ce836c36f8ab290076d857e166961bbcc9c747122fe09fccc6a13a4ae
MD5 228ae3197a637ef63766b3427d66c54e
BLAKE2b-256 3607f14c2c585cc5d9664043e80afc57c8b69f2a235a317ecac6dd757a5b314d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev8-cp37-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 06261b362c890c36792fefcea3cb6dffa733d409908aad11952671c46db6ccc6
MD5 b4db3a2741c0cf4f3be33b08d523980f
BLAKE2b-256 b73bb75e1c1f2374f9e72bab41d76a6499cd13eda9442c6a670f7351c3cb49e4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev8-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d201c757e25c3253a4fccbdd7f1732e2c06c8972cc1bffb92def8e1fd4e150de
MD5 8747c0b3710ff0f3b6edad4e654dd06c
BLAKE2b-256 015a91fa8cdd88658581ed7300deb0f836278830b8b738f6afb89b044d7c3920

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev8-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 17fdecc395a42320197b701527bdc5bbbe80a155b4235f51c50395c56aa0e2cd
MD5 fcf444433c8080ceb03a3c2d1d1f0708
BLAKE2b-256 431494c59d5ebf5fb1dbe59de32eeda3c14d19a80ec8310219a74c3b86fe2c94

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev8-cp37-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 2cafc2a6f15839a392dd8bdce810d38f0d552ee3c0f62beaec6b214256e203c3
MD5 dd663bb9428d7a09b4ce41a69b292557
BLAKE2b-256 3f85641ca8a6a0783a8caafc18d69f44efbba19c4e4a667fc3c8fcf668c6bf6a

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