vimol 0.1.2__tar.gz → 0.1.4__tar.gz

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.
Files changed (67) hide show
  1. vimol-0.1.4/PKG-INFO +142 -0
  2. vimol-0.1.4/README.md +106 -0
  3. {vimol-0.1.2 → vimol-0.1.4}/pyproject.toml +2 -1
  4. {vimol-0.1.2 → vimol-0.1.4}/src/vimol/__init__.py +7 -2
  5. vimol-0.1.4/src/vimol/align.py +934 -0
  6. vimol-0.1.4/src/vimol/app.py +299 -0
  7. vimol-0.1.4/src/vimol/bonds.py +110 -0
  8. vimol-0.1.4/src/vimol/cistrans.py +142 -0
  9. vimol-0.1.4/src/vimol/data/c60.xyz +62 -0
  10. {vimol-0.1.2 → vimol-0.1.4}/src/vimol/editor.py +8 -0
  11. vimol-0.1.4/src/vimol/file_browser.py +65 -0
  12. {vimol-0.1.2 → vimol-0.1.4}/src/vimol/gl_adapter.py +55 -0
  13. {vimol-0.1.2 → vimol-0.1.4}/src/vimol/gl_render.py +176 -3
  14. vimol-0.1.4/src/vimol/glyph_font.py +176 -0
  15. vimol-0.1.4/src/vimol/glyph_mesh.py +311 -0
  16. vimol-0.1.4/src/vimol/glyph_outlines.py +171 -0
  17. vimol-0.1.4/src/vimol/glyphs.py +954 -0
  18. {vimol-0.1.2 → vimol-0.1.4}/src/vimol/input.py +32 -0
  19. {vimol-0.1.2 → vimol-0.1.4}/src/vimol/kitty.py +13 -0
  20. {vimol-0.1.2 → vimol-0.1.4}/src/vimol/molecule.py +27 -0
  21. {vimol-0.1.2 → vimol-0.1.4}/src/vimol/parsers/pdb.py +10 -0
  22. {vimol-0.1.2 → vimol-0.1.4}/src/vimol/render.py +108 -47
  23. vimol-0.1.4/src/vimol/render_glyph.py +409 -0
  24. vimol-0.1.4/src/vimol/residues.py +399 -0
  25. {vimol-0.1.2 → vimol-0.1.4}/src/vimol/scene.py +50 -1
  26. vimol-0.1.4/src/vimol/select.py +267 -0
  27. vimol-0.1.4/src/vimol/structures.py +802 -0
  28. {vimol-0.1.2 → vimol-0.1.4}/src/vimol/theme.py +3 -2
  29. {vimol-0.1.2 → vimol-0.1.4}/src/vimol/viewer.py +2243 -128
  30. {vimol-0.1.2 → vimol-0.1.4}/src/vimol/widget.py +165 -17
  31. vimol-0.1.4/src/vimol.egg-info/PKG-INFO +142 -0
  32. {vimol-0.1.2 → vimol-0.1.4}/src/vimol.egg-info/SOURCES.txt +17 -0
  33. {vimol-0.1.2 → vimol-0.1.4}/src/vimol.egg-info/requires.txt +3 -0
  34. vimol-0.1.4/tests/test_add_file.py +380 -0
  35. vimol-0.1.4/tests/test_align.py +1399 -0
  36. vimol-0.1.4/tests/test_bonds.py +449 -0
  37. vimol-0.1.4/tests/test_cistrans.py +146 -0
  38. {vimol-0.1.2 → vimol-0.1.4}/tests/test_editing.py +420 -10
  39. vimol-0.1.4/tests/test_file_browser.py +84 -0
  40. vimol-0.1.4/tests/test_glyphs.py +691 -0
  41. {vimol-0.1.2 → vimol-0.1.4}/tests/test_render_fast.py +33 -8
  42. {vimol-0.1.2 → vimol-0.1.4}/tests/test_structures.py +56 -0
  43. {vimol-0.1.2 → vimol-0.1.4}/tests/test_vimol.py +2041 -117
  44. vimol-0.1.2/PKG-INFO +0 -106
  45. vimol-0.1.2/README.md +0 -72
  46. vimol-0.1.2/src/vimol/app.py +0 -268
  47. vimol-0.1.2/src/vimol/bonds.py +0 -79
  48. vimol-0.1.2/src/vimol/structures.py +0 -398
  49. vimol-0.1.2/src/vimol.egg-info/PKG-INFO +0 -106
  50. {vimol-0.1.2 → vimol-0.1.4}/LICENSE +0 -0
  51. {vimol-0.1.2 → vimol-0.1.4}/setup.cfg +0 -0
  52. {vimol-0.1.2 → vimol-0.1.4}/src/vimol/__main__.py +0 -0
  53. {vimol-0.1.2 → vimol-0.1.4}/src/vimol/_render_fast.py +0 -0
  54. {vimol-0.1.2 → vimol-0.1.4}/src/vimol/arrows.py +0 -0
  55. {vimol-0.1.2 → vimol-0.1.4}/src/vimol/camera.py +0 -0
  56. {vimol-0.1.2 → vimol-0.1.4}/src/vimol/elements.py +0 -0
  57. {vimol-0.1.2 → vimol-0.1.4}/src/vimol/parsers/__init__.py +0 -0
  58. {vimol-0.1.2 → vimol-0.1.4}/src/vimol/parsers/mol.py +0 -0
  59. {vimol-0.1.2 → vimol-0.1.4}/src/vimol/parsers/xyz.py +0 -0
  60. {vimol-0.1.2 → vimol-0.1.4}/src/vimol/periodic_table.py +0 -0
  61. {vimol-0.1.2 → vimol-0.1.4}/src/vimol/py.typed +0 -0
  62. {vimol-0.1.2 → vimol-0.1.4}/src/vimol/templates.py +0 -0
  63. {vimol-0.1.2 → vimol-0.1.4}/src/vimol.egg-info/dependency_links.txt +0 -0
  64. {vimol-0.1.2 → vimol-0.1.4}/src/vimol.egg-info/entry_points.txt +0 -0
  65. {vimol-0.1.2 → vimol-0.1.4}/src/vimol.egg-info/top_level.txt +0 -0
  66. {vimol-0.1.2 → vimol-0.1.4}/tests/test_gl_render.py +0 -0
  67. {vimol-0.1.2 → vimol-0.1.4}/tests/test_scene_structures.py +0 -0
vimol-0.1.4/PKG-INFO ADDED
@@ -0,0 +1,142 @@
1
+ Metadata-Version: 2.4
2
+ Name: vimol
3
+ Version: 0.1.4
4
+ Summary: A terminal molecular viewer and editor using the Kitty graphics protocol
5
+ Author: vimol contributors
6
+ License-Expression: MIT
7
+ Keywords: molecular,viewer,editor,terminal,kitty,chemistry,visualization,xyz,pdb,sdf,cli,tui
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Environment :: Console
10
+ Classifier: Intended Audience :: Science/Research
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Scientific/Engineering :: Chemistry
22
+ Classifier: Topic :: Scientific/Engineering :: Visualization
23
+ Classifier: Topic :: Multimedia :: Graphics :: Viewers
24
+ Classifier: Typing :: Typed
25
+ Requires-Python: >=3.8
26
+ Description-Content-Type: text/markdown
27
+ License-File: LICENSE
28
+ Requires-Dist: numpy>=1.20
29
+ Requires-Dist: moderngl>=5.6
30
+ Requires-Dist: numba>=0.59
31
+ Provides-Extra: test
32
+ Requires-Dist: pytest>=7; extra == "test"
33
+ Provides-Extra: align
34
+ Requires-Dist: scipy>=1.4; extra == "align"
35
+ Dynamic: license-file
36
+
37
+ # vimol
38
+
39
+ A molecular viewer and editor that runs **in your terminal**. Open an `.xyz`,
40
+ `.pdb`, `.mol` or `.sdf` file and get a shaded, rotatable, editable 3D
41
+ structure right where you are already working — over SSH, in tmux, beside your
42
+ editor.
43
+
44
+ ```bash
45
+ pip install vimol
46
+ vimol molecule.xyz
47
+ ```
48
+
49
+ ![C60 spinning in the terminal, rendered by vimol](https://raw.githubusercontent.com/hanimustafa/vimol/main/docs/media/spin.gif)
50
+
51
+ That is the C60 bundled with vimol, which `vimol` opens with no arguments.
52
+ Drag to rotate, scroll to zoom, option-drag empty space to pan, hover an atom
53
+ to identify it, `?` for every binding.
54
+
55
+ You need Python 3.8 or newer and a terminal that speaks the
56
+ [Kitty graphics protocol](https://sw.kovidgoyal.net/kitty/graphics-protocol/) —
57
+ **kitty, Ghostty or WezTerm**. Rendering is pure software, with an OpenGL path
58
+ used automatically where a GPU is available. MIT licensed.
59
+
60
+ ## Proteins out of bare coordinates
61
+
62
+ ![vimol opening a bare xyz protein and switching to the lettered residue view](https://raw.githubusercontent.com/hanimustafa/vimol/main/docs/media/protein.gif)
63
+
64
+ An `.xyz` file has no residue names, no atom names and no chains. vimol finds
65
+ the backbone anyway, opens the file as a ribbon, and on `6` letters every
66
+ residue onto it. The trp-cage above is PDB 1RIJ stripped to bare coordinates,
67
+ which vimol reads back as `ALQELLGQWLKDGGPSSGRPPPS` — character for character
68
+ the sequence in that entry.
69
+
70
+ ## Overlays and RMSD
71
+
72
+ ![vimol overlaying 72 CREST conformers on a reference structure and reporting each RMSD](https://raw.githubusercontent.com/hanimustafa/vimol/main/docs/media/align.gif)
73
+
74
+ Open several files, or a trajectory, and every structure lands in one session,
75
+ overlaid and colour-coded down the left. `r` aligns the whole overlay onto the
76
+ active structure and reports each RMSD in a column beside the list — above, a
77
+ chignolin crystal structure and 72 CREST conformers of it. `R` runs the same
78
+ fit on only the atoms you pick.
79
+
80
+ ## Editing
81
+
82
+ ![vimol growing a methyl group onto threonine's side-chain hydroxyl](https://raw.githubusercontent.com/hanimustafa/vimol/main/docs/media/methyl.gif)
83
+
84
+ Editing is on by default. Click a hydrogen to grow a fragment in its place, a
85
+ heavy atom to swap the element, empty space to start something new — one click
86
+ turns threonine into O-methylthreonine. Bonds, deletion, clash cleanup, undo
87
+ and save are a keystroke each.
88
+
89
+ ## As a library
90
+
91
+ ![a C60 painted into the middle of a terminal by three lines of vimol](https://raw.githubusercontent.com/hanimustafa/vimol/main/docs/media/library.png)
92
+
93
+ Three lines put a molecule anywhere on the screen:
94
+
95
+ ```python
96
+ import os, vimol
97
+
98
+ scene = vimol.Scene(vimol.load("c60.xyz"), 640, 380) # render it off-screen
99
+ scene.style.transparent = True # let the terminal through
100
+ os.write(1, b"\x1b[6;19H" + scene.to_kitty()) # paint at row 6, col 19
101
+ ```
102
+
103
+ `scene.render()` hands you the pixels as a numpy array instead and
104
+ `scene.to_png()` writes a file. To let the reader turn the molecule,
105
+ `MoleculeWidget` takes the input events you hand it and leaves the loop to you;
106
+ `examples/embed_demo.py` is a complete host application built that way.
107
+
108
+ ## Reference
109
+
110
+ | Key | Does |
111
+ |---|---|
112
+ | Drag / arrows / `hjkl` | rotate |
113
+ | Wheel, `+` `-` | zoom |
114
+ | Right or middle drag | pan |
115
+ | `[` `]` | roll |
116
+ | `1` `2` `3` `4` | ball-and-stick, space-filling, licorice, wireframe |
117
+ | `5` `6` | ribbon, lettered residues (proteins) |
118
+ | `f` `z` | re-fit, reset the view |
119
+ | `m` | measure — click 2, 3 or 4 atoms for distance, angle, dihedral |
120
+ | `a` `x` `c` `u` `s` | append, delete, cleanup clashes, undo, save |
121
+ | `r` `R` | align an overlay, or align on picked atoms |
122
+ | `Shift+S` | ready-made selections: backbone, heavy atoms, ring system |
123
+ | `A` `n` `p` | add a file, next and previous structure |
124
+ | `Tab` | focus the structure list |
125
+ | `d` `g` `t` `ctrl-t` | depth cue, hi-quality, transparent background, theme |
126
+ | `?` `q` | help, quit |
127
+
128
+ ```bash
129
+ vimol traj.xyz --spin --style spacefill # spin a trajectory, space-filling
130
+ vimol protein.pdb --style glyph # lettered residues on a ribbon
131
+ vimol a.xyz b.pdb --style ribbon # overlay two proteins
132
+ ```
133
+
134
+ Several files always open in ball-and-stick, so pass `--style ribbon` for
135
+ proteins. Also `--backend cpu|gl|auto`, `--theme dark|light|auto`,
136
+ `--rotate YAW PITCH`, `--frame N`, `--background`,
137
+ `--transparent`/`--opaque`, `--atom-scale`, `--bond-radius`,
138
+ `--no-depth-cue`, `--no-bonds`, `--bond-tolerance`, `--list-formats`.
139
+ `pip install vimol[align]` adds scipy, which speeds up subset alignment.
140
+
141
+ The protein, alignment and editing animations are recorded by
142
+ `scripts/record_demos.py`.
vimol-0.1.4/README.md ADDED
@@ -0,0 +1,106 @@
1
+ # vimol
2
+
3
+ A molecular viewer and editor that runs **in your terminal**. Open an `.xyz`,
4
+ `.pdb`, `.mol` or `.sdf` file and get a shaded, rotatable, editable 3D
5
+ structure right where you are already working — over SSH, in tmux, beside your
6
+ editor.
7
+
8
+ ```bash
9
+ pip install vimol
10
+ vimol molecule.xyz
11
+ ```
12
+
13
+ ![C60 spinning in the terminal, rendered by vimol](https://raw.githubusercontent.com/hanimustafa/vimol/main/docs/media/spin.gif)
14
+
15
+ That is the C60 bundled with vimol, which `vimol` opens with no arguments.
16
+ Drag to rotate, scroll to zoom, option-drag empty space to pan, hover an atom
17
+ to identify it, `?` for every binding.
18
+
19
+ You need Python 3.8 or newer and a terminal that speaks the
20
+ [Kitty graphics protocol](https://sw.kovidgoyal.net/kitty/graphics-protocol/) —
21
+ **kitty, Ghostty or WezTerm**. Rendering is pure software, with an OpenGL path
22
+ used automatically where a GPU is available. MIT licensed.
23
+
24
+ ## Proteins out of bare coordinates
25
+
26
+ ![vimol opening a bare xyz protein and switching to the lettered residue view](https://raw.githubusercontent.com/hanimustafa/vimol/main/docs/media/protein.gif)
27
+
28
+ An `.xyz` file has no residue names, no atom names and no chains. vimol finds
29
+ the backbone anyway, opens the file as a ribbon, and on `6` letters every
30
+ residue onto it. The trp-cage above is PDB 1RIJ stripped to bare coordinates,
31
+ which vimol reads back as `ALQELLGQWLKDGGPSSGRPPPS` — character for character
32
+ the sequence in that entry.
33
+
34
+ ## Overlays and RMSD
35
+
36
+ ![vimol overlaying 72 CREST conformers on a reference structure and reporting each RMSD](https://raw.githubusercontent.com/hanimustafa/vimol/main/docs/media/align.gif)
37
+
38
+ Open several files, or a trajectory, and every structure lands in one session,
39
+ overlaid and colour-coded down the left. `r` aligns the whole overlay onto the
40
+ active structure and reports each RMSD in a column beside the list — above, a
41
+ chignolin crystal structure and 72 CREST conformers of it. `R` runs the same
42
+ fit on only the atoms you pick.
43
+
44
+ ## Editing
45
+
46
+ ![vimol growing a methyl group onto threonine's side-chain hydroxyl](https://raw.githubusercontent.com/hanimustafa/vimol/main/docs/media/methyl.gif)
47
+
48
+ Editing is on by default. Click a hydrogen to grow a fragment in its place, a
49
+ heavy atom to swap the element, empty space to start something new — one click
50
+ turns threonine into O-methylthreonine. Bonds, deletion, clash cleanup, undo
51
+ and save are a keystroke each.
52
+
53
+ ## As a library
54
+
55
+ ![a C60 painted into the middle of a terminal by three lines of vimol](https://raw.githubusercontent.com/hanimustafa/vimol/main/docs/media/library.png)
56
+
57
+ Three lines put a molecule anywhere on the screen:
58
+
59
+ ```python
60
+ import os, vimol
61
+
62
+ scene = vimol.Scene(vimol.load("c60.xyz"), 640, 380) # render it off-screen
63
+ scene.style.transparent = True # let the terminal through
64
+ os.write(1, b"\x1b[6;19H" + scene.to_kitty()) # paint at row 6, col 19
65
+ ```
66
+
67
+ `scene.render()` hands you the pixels as a numpy array instead and
68
+ `scene.to_png()` writes a file. To let the reader turn the molecule,
69
+ `MoleculeWidget` takes the input events you hand it and leaves the loop to you;
70
+ `examples/embed_demo.py` is a complete host application built that way.
71
+
72
+ ## Reference
73
+
74
+ | Key | Does |
75
+ |---|---|
76
+ | Drag / arrows / `hjkl` | rotate |
77
+ | Wheel, `+` `-` | zoom |
78
+ | Right or middle drag | pan |
79
+ | `[` `]` | roll |
80
+ | `1` `2` `3` `4` | ball-and-stick, space-filling, licorice, wireframe |
81
+ | `5` `6` | ribbon, lettered residues (proteins) |
82
+ | `f` `z` | re-fit, reset the view |
83
+ | `m` | measure — click 2, 3 or 4 atoms for distance, angle, dihedral |
84
+ | `a` `x` `c` `u` `s` | append, delete, cleanup clashes, undo, save |
85
+ | `r` `R` | align an overlay, or align on picked atoms |
86
+ | `Shift+S` | ready-made selections: backbone, heavy atoms, ring system |
87
+ | `A` `n` `p` | add a file, next and previous structure |
88
+ | `Tab` | focus the structure list |
89
+ | `d` `g` `t` `ctrl-t` | depth cue, hi-quality, transparent background, theme |
90
+ | `?` `q` | help, quit |
91
+
92
+ ```bash
93
+ vimol traj.xyz --spin --style spacefill # spin a trajectory, space-filling
94
+ vimol protein.pdb --style glyph # lettered residues on a ribbon
95
+ vimol a.xyz b.pdb --style ribbon # overlay two proteins
96
+ ```
97
+
98
+ Several files always open in ball-and-stick, so pass `--style ribbon` for
99
+ proteins. Also `--backend cpu|gl|auto`, `--theme dark|light|auto`,
100
+ `--rotate YAW PITCH`, `--frame N`, `--background`,
101
+ `--transparent`/`--opaque`, `--atom-scale`, `--bond-radius`,
102
+ `--no-depth-cue`, `--no-bonds`, `--bond-tolerance`, `--list-formats`.
103
+ `pip install vimol[align]` adds scipy, which speeds up subset alignment.
104
+
105
+ The protein, alignment and editing animations are recorded by
106
+ `scripts/record_demos.py`.
@@ -45,6 +45,7 @@ dependencies = ["numpy>=1.20", "moderngl>=5.6", "numba>=0.59"]
45
45
 
46
46
  [project.optional-dependencies]
47
47
  test = ["pytest>=7"]
48
+ align = ["scipy>=1.4"]
48
49
 
49
50
  [project.scripts]
50
51
  vimol = "vimol.app:main"
@@ -56,4 +57,4 @@ version = { attr = "vimol.__version__" }
56
57
  where = ["src"]
57
58
 
58
59
  [tool.setuptools.package-data]
59
- vimol = ["py.typed"]
60
+ vimol = ["py.typed", "data/c60.xyz"]
@@ -32,14 +32,19 @@ from . import kitty
32
32
  from . import elements
33
33
  from . import templates
34
34
  from . import editor
35
+ from . import select
36
+ from .structures import StructureSet, Structure, Transform, AlignmentResult
37
+ from .align import kabsch, superpose, permutation_search, subset_search
35
38
 
36
- __version__ = "0.1.2"
39
+ __version__ = "0.1.4"
37
40
 
38
41
  __all__ = [
39
42
  "Molecule", "VectorField", "Camera", "Renderer", "Style", "Scene", "MoleculeWidget",
40
43
  "InputDecoder", "MouseEvent", "KeyEvent", "enable_mouse", "disable_mouse",
41
44
  "load", "load_all", "loads", "save", "SUPPORTED_EXTENSIONS", "SAVE_EXTENSIONS",
42
- "perceive_bonds", "ensure_bonds", "kitty", "elements", "templates", "editor",
45
+ "perceive_bonds", "ensure_bonds", "kitty", "elements", "templates", "editor", "select",
46
+ "StructureSet", "Structure", "Transform", "AlignmentResult", "kabsch",
47
+ "superpose", "permutation_search", "subset_search",
43
48
  "view", "__version__",
44
49
  ]
45
50