cosmol-viewer 0.1.3.dev3__cp37-abi3-win32.whl → 0.1.4__cp37-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.
Potentially problematic release.
This version of cosmol-viewer might be problematic. Click here for more details.
- cosmol_viewer/__init__.pyi +6 -2
- cosmol_viewer/cosmol_viewer.pyd +0 -0
- cosmol_viewer-0.1.4.dist-info/METADATA +107 -0
- cosmol_viewer-0.1.4.dist-info/RECORD +7 -0
- {cosmol_viewer-0.1.3.dev3.dist-info → cosmol_viewer-0.1.4.dist-info}/WHEEL +1 -1
- cosmol_viewer-0.1.3.dev3.dist-info/METADATA +0 -179
- cosmol_viewer-0.1.3.dev3.dist-info/RECORD +0 -7
cosmol_viewer/__init__.pyi
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Optional, Union, List
|
|
1
|
+
from typing import Optional, Union, List
|
|
2
2
|
|
|
3
3
|
def parse_sdf(
|
|
4
4
|
sdf: str,
|
|
@@ -189,7 +189,8 @@ class Viewer:
|
|
|
189
189
|
interval: float,
|
|
190
190
|
loops: int,
|
|
191
191
|
width: float = 800.0,
|
|
192
|
-
height: float = 600.0
|
|
192
|
+
height: float = 600.0,
|
|
193
|
+
smooth: bool = False
|
|
193
194
|
) -> "Viewer":
|
|
194
195
|
"""
|
|
195
196
|
Play an animation of multiple frames.
|
|
@@ -200,6 +201,8 @@ class Viewer:
|
|
|
200
201
|
- loops: Number of loops to repeat (-1 for infinite).
|
|
201
202
|
- width: The viewport width in pixels.
|
|
202
203
|
- height: The viewport height in pixels.
|
|
204
|
+
- smooth: Whether to smooth the animation by
|
|
205
|
+
interpolating between frames.
|
|
203
206
|
|
|
204
207
|
# Returns
|
|
205
208
|
- Viewer: The created viewer instance.
|
|
@@ -303,6 +306,7 @@ class Molecules:
|
|
|
303
306
|
"""
|
|
304
307
|
|
|
305
308
|
def __init__(self, molecule_data: "MoleculeData") -> None: ...
|
|
309
|
+
def get_center(self) -> List[float]: ...
|
|
306
310
|
def centered(self) -> "Molecules": ...
|
|
307
311
|
def color(self, color: List[float]) -> "Molecules": ...
|
|
308
312
|
def color_rgba(self, color: List[float]) -> "Molecules": ...
|
cosmol_viewer/cosmol_viewer.pyd
CHANGED
|
Binary file
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cosmol-viewer
|
|
3
|
+
Version: 0.1.4
|
|
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
|
+
|
|
11
|
+
<div align="center">
|
|
12
|
+
<a href="https://crates.io/crates/cosmol_viewer">
|
|
13
|
+
<img src="https://img.shields.io/crates/v/cosmol_viewer.svg" alt="crates.io Latest Release"/>
|
|
14
|
+
</a>
|
|
15
|
+
<a href="https://pypi.org/project/cosmol_viewer/">
|
|
16
|
+
<img src="https://img.shields.io/pypi/v/cosmol_viewer.svg" alt="PyPi Latest Release"/>
|
|
17
|
+
</a>
|
|
18
|
+
<a href="https://cosmol-repl.github.io/COSMol-viewer">
|
|
19
|
+
<img src="https://img.shields.io/badge/docs-latest-blue.svg" alt="Documentation Status"/>
|
|
20
|
+
</a>
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
A high-performance molecular viewer for `Python` and `Rust`, backed by `Rust`.
|
|
24
|
+
Supports both static rendering and smooth animation playback — including inside Jupyter notebooks.
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
A compact, high-performance renderer for molecular and scientific shapes with two usage patterns:
|
|
28
|
+
|
|
29
|
+
- **Static rendering + update** — push individual scene updates from your application or simulation.
|
|
30
|
+
- **Play (recommended for demonstrations & smooth playback)** — precompute frames and hand the sequence to the viewer to play back with optional interpolation (`smooth`).
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Quick concepts
|
|
35
|
+
|
|
36
|
+
- **Scene**: container for shapes (molecules, spheres, lines, etc.).
|
|
37
|
+
- **Viewer.render(scene, ...)**: create a static viewer bound to a canvas (native or notebook). Good for static visualization.
|
|
38
|
+
- **viewer.update(scene)**: push incremental changes (real-time / streaming use-cases).
|
|
39
|
+
- **Viewer.play(frames, interval, loops, width, height, smooth)**: *recommended* for precomputed animations and demonstrations. The viewer takes care of playback timing and looping.
|
|
40
|
+
|
|
41
|
+
**Why prefer `play` for demos?**
|
|
42
|
+
- Single call API (hand off responsibility to the viewer).
|
|
43
|
+
- Built-in timing & loop control.
|
|
44
|
+
- Optional `smooth` interpolation between frames for visually pleasing playback even when input frame rate is low.
|
|
45
|
+
|
|
46
|
+
**Why keep `update`?**
|
|
47
|
+
- `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.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Installation
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
pip install cosmol-viewer
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Quick Start
|
|
60
|
+
See examples in [Google Colab](https://colab.research.google.com/drive/1Sw72QWjQh_sbbY43jGyBOfF1AQCycmIx?usp=sharing).
|
|
61
|
+
### 1. Static molecular rendering
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
from cosmol_viewer import Scene, Viewer, parse_sdf, Molecules
|
|
65
|
+
|
|
66
|
+
with open("molecule.sdf", "r") as f:
|
|
67
|
+
sdf = f.read()
|
|
68
|
+
mol = Molecules(parse_sdf(sdf)).centered()
|
|
69
|
+
|
|
70
|
+
scene = Scene()
|
|
71
|
+
scene.scale(0.1)
|
|
72
|
+
scene.add_shape(mol, "mol")
|
|
73
|
+
|
|
74
|
+
viewer = Viewer.render(scene, width=600, height=400)
|
|
75
|
+
|
|
76
|
+
print("Press Any Key to exit...", end='', flush=True)
|
|
77
|
+
_ = input() # Keep the viewer open until you decide to close
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### 2. Animation playback with `Viewer.play`
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
from cosmol_viewer import Scene, Viewer, parse_sdf, Molecules
|
|
84
|
+
import time
|
|
85
|
+
|
|
86
|
+
interval = 0.033 # ~30 FPS
|
|
87
|
+
|
|
88
|
+
frames = []
|
|
89
|
+
|
|
90
|
+
for i in range(1, 10):
|
|
91
|
+
with open(f"frames/frame_{i}.sdf", "r") as f:
|
|
92
|
+
sdf = f.read()
|
|
93
|
+
mol = Molecules(parse_sdf(sdf)).centered()
|
|
94
|
+
|
|
95
|
+
scene = Scene()
|
|
96
|
+
scene.scale(0.1)
|
|
97
|
+
scene.add_shape(mol, "mol")
|
|
98
|
+
|
|
99
|
+
frames.append(scene)
|
|
100
|
+
|
|
101
|
+
Viewer.play(frames, interval=interval, loops=1, width=600, height=400, smooth=True)
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Documentation
|
|
105
|
+
|
|
106
|
+
For API reference and advanced usage, please see the [latest documentation](https://cosmol-repl.github.io/COSMol-viewer).
|
|
107
|
+
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
cosmol_viewer-0.1.4.dist-info/METADATA,sha256=lV0EkCNT7HLm_rQiI14-dGzhh1Jjp1Hj-LnPWfDZU6o,3672
|
|
2
|
+
cosmol_viewer-0.1.4.dist-info/WHEEL,sha256=sECm0kUL3yjM43BAfLHkWZpgahvZsaN6MUYDUv4ZsnY,90
|
|
3
|
+
cosmol_viewer/__init__.py,sha256=K33zoYpHqUVvpFdMVxmCtw4uKj9ZXrGuQD4D4DuUmjk,135
|
|
4
|
+
cosmol_viewer/__init__.pyi,sha256=Hc3iWytKJjh6WSg3n2SO7vYb5gePB7GvE2Pq2F--Luc,8746
|
|
5
|
+
cosmol_viewer/cosmol_viewer.pyd,sha256=7SwAOM5xbRM7Fa8miUAIn0DFsFPJoz7UAVlZgsRf18U,14890496
|
|
6
|
+
cosmol_viewer/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
+
cosmol_viewer-0.1.4.dist-info/RECORD,,
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: cosmol-viewer
|
|
3
|
-
Version: 0.1.3.dev3
|
|
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
|
-
|
|
11
|
-
<div align="center">
|
|
12
|
-
<a href="https://crates.io/crates/cosmol_viewer">
|
|
13
|
-
<img src="https://img.shields.io/crates/v/cosmol_viewer.svg" alt="crates.io Latest Release"/>
|
|
14
|
-
</a>
|
|
15
|
-
<a href="https://pypi.org/project/cosmol_viewer/">
|
|
16
|
-
<img src="https://img.shields.io/pypi/v/cosmol_viewer.svg" alt="PyPi Latest Release"/>
|
|
17
|
-
</a>
|
|
18
|
-
<a href="https://cosmol-repl.github.io/COSMol-viewer">
|
|
19
|
-
<img src="https://img.shields.io/badge/docs-latest-blue.svg" alt="Documentation Status"/>
|
|
20
|
-
</a>
|
|
21
|
-
</div>
|
|
22
|
-
|
|
23
|
-
**COSMol-viewer** is a high-performance molecular visualization library, written in **Rust** and powered by **WebGPU**, designed for seamless integration into **Python** workflows.
|
|
24
|
-
|
|
25
|
-
- ⚡ **High-speed rendering** — GPU-accelerated performance at native speed
|
|
26
|
-
- 🧬 **Flexible input** — Load structures from `.sdf`, `.pdb`, or dynamically generated coordinates
|
|
27
|
-
- 📓 **Notebook-ready** — Fully compatible with Jupyter and Google Colab, ideal for teaching, research, and interactive demos
|
|
28
|
-
- 🔁 **Dynamic visualization** — Update molecular structures on-the-fly or play smooth preloaded animations
|
|
29
|
-
- 🎨 **Customizable** — Fine-grained control of rendering styles, camera, and scene parameters
|
|
30
|
-
|
|
31
|
-
---
|
|
32
|
-
|
|
33
|
-
## Installation
|
|
34
|
-
|
|
35
|
-
```sh
|
|
36
|
-
pip install cosmol-viewer
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
---
|
|
40
|
-
|
|
41
|
-
## Quick Start
|
|
42
|
-
|
|
43
|
-
```python
|
|
44
|
-
from cosmol_viewer import Scene, Viewer, parse_sdf, Molecules
|
|
45
|
-
|
|
46
|
-
# === Step 1: Load and render a molecule ===
|
|
47
|
-
with open("molecule.sdf", "r") as f:
|
|
48
|
-
sdf = f.read()
|
|
49
|
-
mol = Molecules(parse_sdf(sdf)).centered()
|
|
50
|
-
|
|
51
|
-
scene = Scene()
|
|
52
|
-
scene.scale(0.1)
|
|
53
|
-
scene.add_shape(mol, "mol")
|
|
54
|
-
|
|
55
|
-
viewer = Viewer.render(scene, width=600, height=400) # Launch viewer
|
|
56
|
-
|
|
57
|
-
print("Press Any Key to exit...", end='', flush=True)
|
|
58
|
-
_ = input() # Keep the viewer open until you decide to close
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
---
|
|
62
|
-
|
|
63
|
-
## Animation Modes
|
|
64
|
-
|
|
65
|
-
COSMol-viewer supports **two complementary animation workflows**, depending on whether you prefer **real-time updates** or **preloaded playback**.
|
|
66
|
-
|
|
67
|
-
### 1. Real-Time Updates (Frame-by-Frame Streaming)
|
|
68
|
-
|
|
69
|
-
Update the molecule directly inside an existing scene:
|
|
70
|
-
|
|
71
|
-
```python
|
|
72
|
-
import time
|
|
73
|
-
from cosmol_viewer import Scene, Viewer, parse_sdf, Molecules
|
|
74
|
-
|
|
75
|
-
scene = Scene()
|
|
76
|
-
scene.scale(0.1)
|
|
77
|
-
|
|
78
|
-
# Initial load
|
|
79
|
-
with open("frames/frame_1.sdf", "r") as f:
|
|
80
|
-
sdf = f.read()
|
|
81
|
-
mol = Molecules(parse_sdf(sdf)).centered()
|
|
82
|
-
scene.add_shape(mol, "mol")
|
|
83
|
-
|
|
84
|
-
viewer = Viewer.render(scene, width=600, height=400)
|
|
85
|
-
|
|
86
|
-
# Update in real time
|
|
87
|
-
for i in range(2, 10):
|
|
88
|
-
with open(f"frames/frame_{i}.sdf", "r") as f:
|
|
89
|
-
sdf = f.read()
|
|
90
|
-
updated_mol = Molecules(parse_sdf(sdf)).centered()
|
|
91
|
-
|
|
92
|
-
scene.update_shape("mol", updated_mol)
|
|
93
|
-
viewer.update(scene)
|
|
94
|
-
|
|
95
|
-
time.sleep(0.033) # ~30 FPS
|
|
96
|
-
|
|
97
|
-
print("Press Any Key to exit...", end='', flush=True)
|
|
98
|
-
_ = input()
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
**Use cases:**
|
|
102
|
-
- Visualizing the *progress* of a simulation step-by-step
|
|
103
|
-
- Interactive experiments or streaming scenarios where frames are not known in advance
|
|
104
|
-
|
|
105
|
-
**Trade-offs:**
|
|
106
|
-
- ✅ Low memory usage — no need to preload frames
|
|
107
|
-
- ⚠️ Playback smoothness depends on computation / I/O speed → may stutter if frame generation is slow
|
|
108
|
-
|
|
109
|
-
---
|
|
110
|
-
|
|
111
|
-
### 2. Preloaded Playback (One-Shot Animation) (Start from 0.1.3)
|
|
112
|
-
|
|
113
|
-
Load all frames into memory first, then play them back smoothly:
|
|
114
|
-
|
|
115
|
-
```python
|
|
116
|
-
from cosmol_viewer import Scene, Viewer, parse_sdf, Molecules
|
|
117
|
-
|
|
118
|
-
frames = []
|
|
119
|
-
interval = 0.033 # ~30 FPS
|
|
120
|
-
|
|
121
|
-
# Preload all frames
|
|
122
|
-
for i in range(1, 10):
|
|
123
|
-
with open(f"frames/frame_{i}.sdf", "r") as f:
|
|
124
|
-
sdf = f.read()
|
|
125
|
-
mol = Molecules(parse_sdf(sdf)).centered()
|
|
126
|
-
|
|
127
|
-
scene = Scene()
|
|
128
|
-
scene.scale(0.1)
|
|
129
|
-
scene.add_shape(mol, "mol")
|
|
130
|
-
frames.append(scene)
|
|
131
|
-
|
|
132
|
-
# Playback once
|
|
133
|
-
Viewer.play(frames, interval=interval, loops=1, width=600, height=400)
|
|
134
|
-
|
|
135
|
-
print("Press Any Key to exit...", end='', flush=True)
|
|
136
|
-
_ = input()
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
**Use cases:**
|
|
140
|
-
- Smooth, stable playback for presentations or teaching
|
|
141
|
-
- Demonstrating precomputed trajectories (e.g., molecular dynamics snapshots)
|
|
142
|
-
|
|
143
|
-
**Trade-offs:**
|
|
144
|
-
- ✅ Very smooth playback, independent of computation speed
|
|
145
|
-
- ⚠️ Requires preloading all frames → higher memory usage
|
|
146
|
-
- ⚠️ Longer initial load time for large trajectories
|
|
147
|
-
|
|
148
|
-
---
|
|
149
|
-
|
|
150
|
-
## Choosing the Right Mode
|
|
151
|
-
|
|
152
|
-
- ✅ Use **real-time updates** if your frames are generated on-the-fly or memory is limited
|
|
153
|
-
- ✅ Use **preloaded playback** if you want guaranteed smooth animations and can preload your trajectory
|
|
154
|
-
|
|
155
|
-
---
|
|
156
|
-
|
|
157
|
-
## Exiting the Viewer
|
|
158
|
-
|
|
159
|
-
> **Important:** The viewer is bound to the Python process.
|
|
160
|
-
> When your script finishes, the rendering window will close automatically.
|
|
161
|
-
|
|
162
|
-
To keep the visualization alive until you are ready to exit, always add:
|
|
163
|
-
|
|
164
|
-
```python
|
|
165
|
-
print("Press Any Key to exit...", end='', flush=True)
|
|
166
|
-
_ = input()
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
This ensures:
|
|
170
|
-
- The window stays open for inspection
|
|
171
|
-
- The user decides when to end visualization
|
|
172
|
-
- Prevents premature termination at the end of the script
|
|
173
|
-
|
|
174
|
-
---
|
|
175
|
-
|
|
176
|
-
## Documentation
|
|
177
|
-
|
|
178
|
-
For API reference and advanced usage, please see the [latest documentation](https://cosmol-repl.github.io/COSMol-viewer).
|
|
179
|
-
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
cosmol_viewer-0.1.3.dev3.dist-info/METADATA,sha256=VcrxV2Qa_ZCtF7Fzdr_VamQlzk5oHq4zimIRO-4AHm4,5459
|
|
2
|
-
cosmol_viewer-0.1.3.dev3.dist-info/WHEEL,sha256=69Fxjyxr2c5wP5wLO9JJYwUSZfKn5u-MGzPh56ikWHw,90
|
|
3
|
-
cosmol_viewer/__init__.py,sha256=K33zoYpHqUVvpFdMVxmCtw4uKj9ZXrGuQD4D4DuUmjk,135
|
|
4
|
-
cosmol_viewer/__init__.pyi,sha256=WSHHU8xHrrDch7D8102T6wlLqm2PeTY0hV-WJGE7EHQ,8571
|
|
5
|
-
cosmol_viewer/cosmol_viewer.pyd,sha256=8r1602FHqv_qjGlD3spnWmmZ0iYSgixBCz6LM7oDkls,12830720
|
|
6
|
-
cosmol_viewer/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
-
cosmol_viewer-0.1.3.dev3.dist-info/RECORD,,
|