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.dev1.tar.gz (63.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.dev1-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.8 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

cosmol_viewer-0.1.5.dev1-pp311-pypy311_pp73-manylinux_2_17_i686.manylinux2014_i686.whl (10.4 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ i686

cosmol_viewer-0.1.5.dev1-cp37-abi3-win_arm64.whl (6.4 MB view details)

Uploaded CPython 3.7+Windows ARM64

cosmol_viewer-0.1.5.dev1-cp37-abi3-win_amd64.whl (6.6 MB view details)

Uploaded CPython 3.7+Windows x86-64

cosmol_viewer-0.1.5.dev1-cp37-abi3-win32.whl (6.4 MB view details)

Uploaded CPython 3.7+Windows x86

cosmol_viewer-0.1.5.dev1-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.8 MB view details)

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

cosmol_viewer-0.1.5.dev1-cp37-abi3-manylinux_2_17_i686.manylinux2014_i686.whl (10.4 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ i686

cosmol_viewer-0.1.5.dev1-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (9.7 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ ARM64

cosmol_viewer-0.1.5.dev1-cp37-abi3-macosx_11_0_arm64.whl (6.5 MB view details)

Uploaded CPython 3.7+macOS 11.0+ ARM64

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

File metadata

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

File hashes

Hashes for cosmol_viewer-0.1.5.dev1.tar.gz
Algorithm Hash digest
SHA256 967bcc6d1102fa935fdf2fef610c5984a6316eed5a419152a89b8be81693233b
MD5 f3f19e8dc40ec570c9d97207d1f15994
BLAKE2b-256 4f05c70d84fe8ad22f7426ae30c2753d865f62e61959ba0a27a14a20a8ff3b83

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev1-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ed3a1e4b46cd0495a6b9694010888af9d94de27fb684c3fbc2bc1bc53f7e1af0
MD5 55879e231237a526cd06e925013342d6
BLAKE2b-256 056821f545716a5ae0a8ce70aebcfa1b5a285c9e89625ced25d4fe8491e247c4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev1-pp311-pypy311_pp73-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 10e14d54fbfa8d1504966a523d732c16013d53c37ed8d66772706f04fee85fe8
MD5 6d960d76b81e3fde83524206396b04ab
BLAKE2b-256 24891fc33a578c23ba78e243a559cdeeb7a31462c57120e8b904b82585014a94

See more details on using hashes here.

File details

Details for the file cosmol_viewer-0.1.5.dev1-cp37-abi3-win_arm64.whl.

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev1-cp37-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 6d49dd2bfae2d4d2a4dc7cbd9c5d912c7a514088f942f07e09b88c6584ce1b54
MD5 e2cec2f572102a12c7703acdeaf0f5be
BLAKE2b-256 712b7d1e5d96091701d819d6c89bd2863c6b24b22866c09771ab7df296e2a6d4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev1-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 3fba73dad3935604f7862e5b48e6a99a78b7f8dd0f508a54b64befc4932cf536
MD5 488a72f677ff9b3b275ab1499b24f935
BLAKE2b-256 d7e837937b696b4136639e8133a9ff75e96a09739550668ff0e3f2f231f53d8c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev1-cp37-abi3-win32.whl
Algorithm Hash digest
SHA256 e07ad1661b5f92ab09940b201f7954ef1163a0b5001ec4a6252e58b03b6487e8
MD5 12dbfce6fe76a131e41f7099747d7913
BLAKE2b-256 c1320d19b1e4688abcf9b7797f971faa7651d03b1a6762cc5346dea6d7bc99a1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev1-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ee3a8d9f292c11c67228c82c3252867e58cc32666c34cc244330e53452d04a90
MD5 e910db6411b16b6c110c12acf890bfcc
BLAKE2b-256 25715d6305d316aa563ee0b6f7c616c3ad9a05de7e0be45040c31b28a1762212

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev1-cp37-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 9eb69a5d8021d977f27ad38c616bf376936cc9cdfc259c660872913c8dfcbc97
MD5 5e82f2f1972889bc4b7dccff42d2478d
BLAKE2b-256 20936311438435d6a16e52a3f19bc133c0bad57f2ba6e3387d906f995dea7a93

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev1-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6428ea817040ee5dc28ccac3da6c66cfa2ae44b8ff390bd8447716f1610b1ef1
MD5 67008ba9cc4dabd847fee2a011c6a906
BLAKE2b-256 d32e73d2f238b96804d72e90fa281693bd398c650bc8757ebe992a5645164e30

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev1-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b00fff9e94c5b6719bbcbba886cdd88683515efe9645b2334ffc4977447ba16d
MD5 a6336a99902dc0af64b45af983ef6998
BLAKE2b-256 b4b77c564eac83ff0adf06bbf4190bc834da296a216610b21fa4a9bac24f17ae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cosmol_viewer-0.1.5.dev1-cp37-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 fb154eb4e6db0dcaa84096847b26cfb26b80f2d207f55bc80dcaea5dc222fb74
MD5 b0553bc86a27bcb0c4bc2eaa636baf05
BLAKE2b-256 48383a3436bb8855b669cf489d4aee16d35c090a4f1ce992f4fe2021d3de0742

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