cosmol-viewer 0.1.4.dev2__cp37-abi3-manylinux_2_17_i686.manylinux2014_i686.whl → 0.1.7__cp37-abi3-manylinux_2_17_i686.manylinux2014_i686.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.

@@ -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,
@@ -7,10 +7,10 @@ def parse_sdf(
7
7
  onemol: bool = False
8
8
  ) -> "MoleculeData":
9
9
  """
10
- Parse an SDF file or string into molecule data.
10
+ Parse an SDF string into molecule data.
11
11
 
12
12
  # Args
13
- - sdf: Path to an SDF file or a string containing SDF content.
13
+ - sdf: Path to an SD string containing SDF content.
14
14
  - keep_h: Whether to keep explicit hydrogen atoms (default: True).
15
15
  - multimodel: Whether to allow multiple models in one file (default: True).
16
16
  - onemol: Whether to merge multiple models into one molecule (default: False).
@@ -21,11 +21,30 @@ def parse_sdf(
21
21
  # Example
22
22
  ```python
23
23
  from cosmol_viewer import parse_sdf
24
- mol = parse_sdf("molecule.sdf")
24
+ mol = parse_sdf(open("./molecule.sdf", "r", encoding="utf-8").read())
25
25
  ```
26
26
  """
27
27
  ...
28
28
 
29
+ def parse_mmcif(
30
+ mmcif: str
31
+ ) -> "ProteinData":
32
+ """
33
+ Parse an MMCIF string into protein data.
34
+
35
+ # Args
36
+ - mmcif: Path to an MMCIF string containing MMCIF content.
37
+
38
+ # Returns
39
+ - ProteinData: Parsed protein data object.
40
+
41
+ # Example
42
+ ```python
43
+ from cosmol_viewer import parse_mmcif
44
+ prot = parse_mmcif(open("./protein.cif", "r", encoding="utf-8").read())
45
+ ```
46
+ """
47
+ ...
29
48
 
30
49
  class Scene:
31
50
  """
@@ -54,12 +73,12 @@ class Scene:
54
73
  """
55
74
  ...
56
75
 
57
- def add_shape(self, shape: Union["Sphere", "Stick", "Molecules"], id: Optional[str] = None) -> None:
76
+ def add_shape(self, shape: Union["Sphere", "Stick", "Molecules", "Protein"], id: Optional[str] = None) -> None:
58
77
  """
59
78
  Add a shape to the scene.
60
79
 
61
80
  # Args
62
- - shape: A shape instance (PySphere, PyStick, or PyMolecules).
81
+ - shape: A shape instance (Sphere, Stick, Molecules, or Protein).
63
82
  - id: Optional string ID to associate with the shape.
64
83
 
65
84
  If the `id` is provided and a shape with the same ID exists,
@@ -73,7 +92,7 @@ class Scene:
73
92
  """
74
93
  ...
75
94
 
76
- def update_shape(self, id: str, shape: Union["Sphere", "Stick", "Molecules"]) -> None:
95
+ def update_shape(self, id: str, shape: Union["Sphere", "Stick", "Molecules", "Protein"]) -> None:
77
96
  """
78
97
  Update an existing shape in the scene by its ID.
79
98
 
@@ -102,6 +121,20 @@ class Scene:
102
121
  """
103
122
  ...
104
123
 
124
+ def recenter(self, center: List[float]) -> None:
125
+ """
126
+ Recenter the scene at a given point.
127
+
128
+ # Args
129
+ - center: An XYZ array of 3 float values representing the new center.
130
+
131
+ # Example
132
+ ```python
133
+ scene.recenter([0.0, 0.0, 0.0])
134
+ ```
135
+ """
136
+ ...
137
+
105
138
  def scale(self, scale: float) -> None:
106
139
  """
107
140
  Set the global scale factor of the scene.
@@ -132,6 +165,17 @@ class Scene:
132
165
  """
133
166
  ...
134
167
 
168
+ def use_black_background(self) -> None:
169
+ """
170
+ Set the background color of the scene to black.
171
+
172
+ # Example
173
+ ```python
174
+ scene.use_black_background()
175
+ ```
176
+ """
177
+ ...
178
+
135
179
  class Viewer:
136
180
  """
137
181
  A viewer that renders 3D scenes in different runtime environments
@@ -201,7 +245,7 @@ class Viewer:
201
245
  - loops: Number of loops to repeat (-1 for infinite).
202
246
  - width: The viewport width in pixels.
203
247
  - height: The viewport height in pixels.
204
- - smooth: Whether to smooth the animation by
248
+ - smooth: Whether to smooth the animation by
205
249
  interpolating between frames.
206
250
 
207
251
  # Returns
@@ -296,23 +340,50 @@ class Stick:
296
340
 
297
341
  class Molecules:
298
342
  """
299
- A molecular shape object parsed from SDF data.
343
+ A molecular shape object.
300
344
 
301
345
  # Example
302
346
  ```python
303
- mol = parse_sdf("molecule.sdf")
347
+ mol = parse_sdf(open("molecule.sdf", "r", encoding="utf-8").read())
304
348
  molecules = Molecules(mol).centered().color([0,1,0])
305
349
  ```
306
350
  """
307
351
 
308
352
  def __init__(self, molecule_data: "MoleculeData") -> None: ...
353
+ def get_center(self) -> List[float]: ...
309
354
  def centered(self) -> "Molecules": ...
310
355
  def color(self, color: List[float]) -> "Molecules": ...
311
356
  def color_rgba(self, color: List[float]) -> "Molecules": ...
312
357
  def opacity(self, opacity: float) -> "Molecules": ...
358
+ def reset_color(self) -> "Molecules": ...
313
359
 
314
360
  class MoleculeData:
315
361
  """
316
362
  Internal representation of molecule data returned by `parse_sdf`.
317
363
  """
318
364
  ...
365
+
366
+ class Protein:
367
+ """
368
+ A protein shape object.
369
+
370
+ # Example
371
+ ```python
372
+ mmcif_data = parse_mmcif(open("2AMD.cif", "r", encoding="utf-8").read())
373
+ prot = Protein(mmcif_data).centered().color([0,1,0])
374
+ ```
375
+ """
376
+
377
+ def __init__(self, mmcif_data: "ProteinData") -> None: ...
378
+ def get_center(self) -> List[float]: ...
379
+ def centered(self) -> "Protein": ...
380
+ def color(self, color: List[float]) -> "Protein": ...
381
+ def color_rgba(self, color: List[float]) -> "Protein": ...
382
+ def opacity(self, opacity: float) -> "Protein": ...
383
+ def reset_color(self) -> "Protein": ...
384
+
385
+ class ProteinData:
386
+ """
387
+ Internal representation of protein data returned by `parse_mmcif`.
388
+ """
389
+ ...
Binary file
@@ -1,41 +1,43 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cosmol-viewer
3
- Version: 0.1.4.dev2
3
+ Version: 0.1.7
4
4
  Summary: Molecular visualization tools
5
5
  Author-email: 95028 <wjt@cosmol.org>
6
6
  Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
7
7
  Project-URL: Repository, https://github.com/COSMol-repl/COSMol-viewer
8
8
 
9
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.
10
12
 
11
13
  <div align="center">
12
14
  <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"/>
15
+ <img src="https://img.shields.io/crates/v/cosmol_viewer.svg" alt="crates.io Latest Release" />
14
16
  </a>
15
17
  <a href="https://pypi.org/project/cosmol_viewer/">
16
- <img src="https://img.shields.io/pypi/v/cosmol_viewer.svg" alt="PyPi Latest Release"/>
18
+ <img src="https://img.shields.io/pypi/v/cosmol_viewer.svg" alt="PyPi Latest Release" />
17
19
  </a>
18
20
  <a href="https://cosmol-repl.github.io/COSMol-viewer">
19
- <img src="https://img.shields.io/badge/docs-latest-blue.svg" alt="Documentation Status"/>
21
+ <img src="https://img.shields.io/badge/docs-latest-blue.svg" alt="Documentation Status" />
20
22
  </a>
21
23
  </div>
22
24
 
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
+ 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:
25
27
 
28
+ - Native desktop window (Python or Rust) via `egui`
29
+ - Jupyter / IPython notebook via WASM backend
30
+ - Rust applications
26
31
 
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`).
32
+ All implementations share the same Rust rendering engine, ensuring consistent performance and visual output.
31
33
 
32
34
  ---
33
35
 
34
36
  ## Quick concepts
35
37
 
36
- - **Scene**: container for shapes (molecules, spheres, lines, etc.).
38
+ - **Scene**: container for shapes (molecules, proteins, spheres, etc.).
37
39
  - **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).
40
+ - **viewer.update(scene)**: push incremental changes after `Viewer.render()` (real-time / streaming use-cases).
39
41
  - **Viewer.play(frames, interval, loops, width, height, smooth)**: *recommended* for precomputed animations and demonstrations. The viewer takes care of playback timing and looping.
40
42
 
41
43
  **Why prefer `play` for demos?**
@@ -48,27 +50,23 @@ A compact, high-performance renderer for molecular and scientific shapes with tw
48
50
 
49
51
  ---
50
52
 
51
- ## Installation
52
-
53
- ```sh
54
- pip install cosmol-viewer
55
- ```
53
+ # Usage
56
54
 
57
- ---
55
+ ## python
56
+ See examples in [Google Colab](https://colab.research.google.com/drive/1Sw72QWjQh_sbbY43jGyBOfF1AQCycmIx?usp=sharing).
58
57
 
59
- ## Quick Start
58
+ Install with `pip install cosmol-viewer`
60
59
 
61
60
  ### 1. Static molecular rendering
62
61
 
63
62
  ```python
64
63
  from cosmol_viewer import Scene, Viewer, parse_sdf, Molecules
64
+
65
+ mol_data = parse_sdf(open("molecule.sdf", "r", encoding="utf-8").read())
65
66
 
66
- with open("molecule.sdf", "r") as f:
67
- sdf = f.read()
68
- mol = Molecules(parse_sdf(sdf)).centered()
67
+ mol = Molecules(mol_data).centered()
69
68
 
70
69
  scene = Scene()
71
- scene.scale(0.1)
72
70
  scene.add_shape(mol, "mol")
73
71
 
74
72
  viewer = Viewer.render(scene, width=600, height=400)
@@ -81,9 +79,6 @@ _ = input() # Keep the viewer open until you decide to close
81
79
 
82
80
  ```python
83
81
  from cosmol_viewer import Scene, Viewer, parse_sdf, Molecules
84
- import time
85
-
86
- interval = 0.033 # ~30 FPS
87
82
 
88
83
  frames = []
89
84
 
@@ -93,15 +88,24 @@ for i in range(1, 10):
93
88
  mol = Molecules(parse_sdf(sdf)).centered()
94
89
 
95
90
  scene = Scene()
96
- scene.scale(0.1)
97
91
  scene.add_shape(mol, "mol")
98
-
99
92
  frames.append(scene)
100
93
 
101
- Viewer.play(frames, interval=interval, loops=1, width=600, height=400, smooth=True)
94
+ Viewer.play(frames, interval=0.033, loops=-1, width=800, height=500, smooth=True) # loops=-1 for infinite repeat
102
95
  ```
103
96
 
104
- ## Documentation
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
+ ---
105
108
 
106
- For API reference and advanced usage, please see the [latest documentation](https://cosmol-repl.github.io/COSMol-viewer).
109
+ # Contact
107
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,7 @@
1
+ cosmol_viewer-0.1.7.dist-info/METADATA,sha256=vcEi0GjgyKTUmhvB-LJxpoqdUE6JzQKf8W1zte1ESVs,3984
2
+ cosmol_viewer-0.1.7.dist-info/WHEEL,sha256=oB91FzNpC-hO8c8ewOPvbQZBthpYN_59_Trh5rKisIg,139
3
+ cosmol_viewer/__init__.py,sha256=K33zoYpHqUVvpFdMVxmCtw4uKj9ZXrGuQD4D4DuUmjk,135
4
+ cosmol_viewer/__init__.pyi,sha256=dHeDzQd2wiBI2j6byAn6bxnVRxXNGVRBDYLaHPYVr4c,10210
5
+ cosmol_viewer/cosmol_viewer.abi3.so,sha256=mqNEkOROmnWhd4kx8xQ040MG8XjawSgRvuY2z_6ifII,14092820
6
+ cosmol_viewer/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ cosmol_viewer-0.1.7.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: maturin (1.10.2)
3
+ Root-Is-Purelib: false
4
+ Tag: cp37-abi3-manylinux_2_17_i686
5
+ Tag: cp37-abi3-manylinux2014_i686
@@ -1,7 +0,0 @@
1
- cosmol_viewer-0.1.4.dev2.dist-info/METADATA,sha256=ntIjMLqgxfDlGAyBDKLqv7yYLjx_iSvEtdwizEyrPqU,3466
2
- cosmol_viewer-0.1.4.dev2.dist-info/WHEEL,sha256=GiWFiSsWOslMBN41z1mfBeDroO-c1QlctGEFpKcYtJE,123
3
- cosmol_viewer/__init__.py,sha256=K33zoYpHqUVvpFdMVxmCtw4uKj9ZXrGuQD4D4DuUmjk,135
4
- cosmol_viewer/__init__.pyi,sha256=haGIhR4cKSfwOsni4Vk9dG4r9ApSfDN0Z2Zui-BD3e0,8384
5
- cosmol_viewer/cosmol_viewer.abi3.so,sha256=SerZm9h3s6aLbm0qQUhV623jq-ci3otUR-vvj2nKv30,26447488
6
- cosmol_viewer/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- cosmol_viewer-0.1.4.dev2.dist-info/RECORD,,
@@ -1,4 +0,0 @@
1
- Wheel-Version: 1.0
2
- Generator: maturin (1.9.6)
3
- Root-Is-Purelib: false
4
- Tag: cp37-abi3-manylinux_2_17_i686.manylinux2014_i686