cosmol-viewer 0.2.0.dev2__cp310-abi3-win32.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
Binary file
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cosmol-viewer
|
|
3
|
+
Version: 0.2.0.dev2
|
|
4
|
+
Summary: Molecular visualization tools
|
|
5
|
+
Author-email: 95028 <wjt@cosmol.org>
|
|
6
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
7
|
+
Project-URL: Repository, https://github.com/COSMol-repl/COSMol-viewer
|
|
8
|
+
|
|
9
|
+
# COSMol-viewer
|
|
10
|
+
A high-performance molecular viewer for Python and Rust, powered by a unified Rust core.
|
|
11
|
+
It supports both in-notebook visualization and native desktop rendering, with smooth playback for scientific animations.
|
|
12
|
+
|
|
13
|
+
<div align="center">
|
|
14
|
+
<a href="https://crates.io/crates/cosmol_viewer">
|
|
15
|
+
<img src="https://img.shields.io/crates/v/cosmol_viewer.svg" alt="crates.io Latest Release" />
|
|
16
|
+
</a>
|
|
17
|
+
<a href="https://pypi.org/project/cosmol_viewer/">
|
|
18
|
+
<img src="https://img.shields.io/pypi/v/cosmol_viewer.svg" alt="PyPi Latest Release" />
|
|
19
|
+
</a>
|
|
20
|
+
<a href="https://cosmol-repl.github.io/COSMol-viewer">
|
|
21
|
+
<img src="https://img.shields.io/badge/docs-latest-blue.svg" alt="Documentation Status" />
|
|
22
|
+
</a>
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
COSMol-viewer is a compact, cross-platform renderer for molecular and geometric scenes.
|
|
26
|
+
Unlike purely notebook-bound solutions such as py3Dmol, COSMol-viewer runs everywhere:
|
|
27
|
+
|
|
28
|
+
- Native desktop window (Python or Rust) via `egui`
|
|
29
|
+
- Jupyter / IPython notebook via WASM backend
|
|
30
|
+
- Rust applications
|
|
31
|
+
|
|
32
|
+
All implementations share the same Rust rendering engine, ensuring consistent performance and visual output.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Quick concepts
|
|
37
|
+
|
|
38
|
+
- **Scene**: container for shapes (molecules, proteins, spheres, etc.).
|
|
39
|
+
- **Viewer.render(scene, ...)**: create a static viewer bound to a canvas (native or notebook). Good for static visualization.
|
|
40
|
+
- **viewer.update(scene)**: push incremental changes after `Viewer.render()` (real-time / streaming use-cases).
|
|
41
|
+
- **Viewer.play(frames, interval, loops, width, height, smooth)**: *recommended* for precomputed animations and demonstrations. The viewer takes care of playback timing and looping.
|
|
42
|
+
|
|
43
|
+
**Why prefer `play` for demos?**
|
|
44
|
+
- Single call API (hand off responsibility to the viewer).
|
|
45
|
+
- Built-in timing & loop control.
|
|
46
|
+
- Optional `smooth` interpolation between frames for visually pleasing playback even when input frame rate is low.
|
|
47
|
+
|
|
48
|
+
**Why keep `update`?**
|
|
49
|
+
- `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.
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
# Usage
|
|
54
|
+
|
|
55
|
+
## python
|
|
56
|
+
See examples in [Google Colab](https://colab.research.google.com/drive/1Sw72QWjQh_sbbY43jGyBOfF1AQCycmIx?usp=sharing).
|
|
57
|
+
|
|
58
|
+
Install with `pip install cosmol-viewer`
|
|
59
|
+
|
|
60
|
+
### 1. Static molecular rendering
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from cosmol_viewer import Scene, Viewer, parse_sdf, Molecules
|
|
64
|
+
|
|
65
|
+
mol_data = parse_sdf(open("molecule.sdf", "r", encoding="utf-8").read())
|
|
66
|
+
|
|
67
|
+
mol = Molecules(mol_data).centered()
|
|
68
|
+
|
|
69
|
+
scene = Scene()
|
|
70
|
+
scene.add_shape(mol, "mol")
|
|
71
|
+
|
|
72
|
+
viewer = Viewer.render(scene, width=600, height=400)
|
|
73
|
+
|
|
74
|
+
print("Press Any Key to exit...", end='', flush=True)
|
|
75
|
+
_ = input() # Keep the viewer open until you decide to close
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### 2. Animation playback with `Viewer.play`
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
from cosmol_viewer import Scene, Viewer, parse_sdf, Molecules
|
|
82
|
+
|
|
83
|
+
frames = []
|
|
84
|
+
|
|
85
|
+
for i in range(1, 10):
|
|
86
|
+
with open(f"frames/frame_{i}.sdf", "r") as f:
|
|
87
|
+
sdf = f.read()
|
|
88
|
+
mol = Molecules(parse_sdf(sdf)).centered()
|
|
89
|
+
|
|
90
|
+
scene = Scene()
|
|
91
|
+
scene.add_shape(mol, "mol")
|
|
92
|
+
frames.append(scene)
|
|
93
|
+
|
|
94
|
+
Viewer.play(frames, interval=0.033, loops=-1, width=800, height=500, smooth=True) # loops=-1 for infinite repeat
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
more examples can be found in the [examples](https://github.com/COSMol-repl/COSMol-viewer/tree/main/cosmol_viewer/examples) folder:
|
|
98
|
+
```bash
|
|
99
|
+
cd cosmol_viewer
|
|
100
|
+
python .\examples\render_protein.py
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
# Documentation
|
|
104
|
+
|
|
105
|
+
Please check out our documentation at [here](https://cosmol-repl.github.io/COSMol-viewer/).
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
# Contact
|
|
110
|
+
|
|
111
|
+
For any questions, issues, or suggestions, please contact [wjt@cosmol.org](mailto:wjt@cosmol.org) or open an issue in the repository. We will review and address them as promptly as possible.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
cosmol_viewer\__init__.py,sha256=K33zoYpHqUVvpFdMVxmCtw4uKj9ZXrGuQD4D4DuUmjk,135
|
|
2
|
+
cosmol_viewer\cosmol_viewer.pyd,sha256=cDx8CE6dvIkZt4spSNA0DqKqfJGXo5Q0FUMgGgoNNII,9802752
|
|
3
|
+
cosmol_viewer-0.2.0.dev2.dist-info\METADATA,sha256=bWVIJiiactjDZVf4wCacGXVCOfsmilG7J_nc8cDNTBo,4091
|
|
4
|
+
cosmol_viewer-0.2.0.dev2.dist-info\WHEEL,sha256=z9yqb7908wvFs7GY83MYuVP32iUSjiPZrYKqUOj5aiM,92
|
|
5
|
+
cosmol_viewer-0.2.0.dev2.dist-info\RECORD,,
|