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.dev9.tar.gz (90.9 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.dev9-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (10.9 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

cosmol_viewer-0.1.5.dev9-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.dev9-cp37-abi3-win_amd64.whl (7.5 MB view details)

Uploaded CPython 3.7+Windows x86-64

cosmol_viewer-0.1.5.dev9-cp37-abi3-win32.whl (7.2 MB view details)

Uploaded CPython 3.7+Windows x86

cosmol_viewer-0.1.5.dev9-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (10.9 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ x86-64

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

File metadata

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

File hashes

Hashes for cosmol_viewer-0.1.5.dev9.tar.gz
Algorithm Hash digest
SHA256 0ad11e524095d4bb3b3ffa4940b74fa8b5086b98c2f34525e101a4fa2efa0fd2
MD5 9ae1071b4e46b84666d8c3235955ec5c
BLAKE2b-256 2e70a9ddddb7f412d2c7160c3a4e446b8a6280dabbeaa32f40a250b1ebc7984f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev9-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 427e6f03cc22ef6621c200058effa76d5b5f62502b03bf97b54079c3c9161ffb
MD5 e338ccba78dff4c407c0aeb24dd6512c
BLAKE2b-256 65726443e7e5bd4ef5b77bf2fc52bc568d40964147ce23280852163c0b2d63b9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev9-pp311-pypy311_pp73-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 2a8b1bbf16512791891f161b94ef65c8f410f61aee1f36bf3a07b1637aaee997
MD5 cb8a4d87a060256b0a8be34111e94f00
BLAKE2b-256 9c3878624950ed316a32443675553b8856fff8fdc1481071a0fade9346ff1e1c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev9-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 85d6c2e4cd9b81b175b7f96032cc4ac32a720ce5eebbbfef31c1caa0790a71f5
MD5 ae2243e5567bd61f8305aad44437aa98
BLAKE2b-256 77cc85fc72ddf8a4df1e070ab4e1a4f2f0778cec0c50282f649db5b8ee07454e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev9-cp37-abi3-win32.whl
Algorithm Hash digest
SHA256 a96ee388beb4c81520338a53ac19fb5ccf0bd3090b200fefe788ea0a6790070c
MD5 e1800a58cbde1c18fcc2e831318e9a8a
BLAKE2b-256 4f0ab097c1adf570b8b5fa5ad0746260c8ad0a977cb309bb7185aaca20eef504

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev9-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ba1c0fb23198c0611dd4599e684c2931ab249d9a2edf20a8b274264c3d2f18d4
MD5 84ca6d309f4eb2456d0084e4eef9547b
BLAKE2b-256 488290518fbc23349b0915a64c4ec9c9f53250332c85d836056d541782986145

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev9-cp37-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 db2b24c237b4b3e025253fda27b90a5fd304d3f7b59af3b0ab20072010f96d97
MD5 713695d48ab1ef2fa92e27867a225f82
BLAKE2b-256 edc4be699c3c5134ef059909f2d8a0eca59ac957ff7261f6048e229a4fcfe508

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev9-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5f8dac685f2e87e62a598ea586adff9e481438ee2bb1d9af7d9572ad47301ed1
MD5 56a29dca88444ee5c6e1c475fc6a771a
BLAKE2b-256 c2b109514ce37d7e75738516885353b78ef742af23226e1151ff22789e277d5d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev9-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a019393498ccbac687bdab67ec211503f9f1d6770b692331ef0890a4ffc073b8
MD5 ae3f0654079b124dfc1de5d8aa4a945f
BLAKE2b-256 26398ed03c812cbf5e5469e07261a74884bb7d740c15f25f8d9cc19fb49d1628

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev9-cp37-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 2d0807a40f31da79d9a32841aa1960f3b92904f96d56b6d458f9092a689902e2
MD5 8b58c40251f4e02a8d94224898b71a48
BLAKE2b-256 5031453fe5b4b6d9ed78ebcfcdbfc183b160d3e54a4696f5340ba75b637d1131

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