moleditpy 1.2.0__tar.gz → 1.2.2__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.
- {moleditpy-1.2.0 → moleditpy-1.2.2}/PKG-INFO +292 -31
- moleditpy-1.2.2/README.md +522 -0
- {moleditpy-1.2.0 → moleditpy-1.2.2}/pyproject.toml +1 -1
- {moleditpy-1.2.0 → moleditpy-1.2.2}/src/moleditpy/main.py +253 -39
- {moleditpy-1.2.0 → moleditpy-1.2.2}/src/moleditpy.egg-info/PKG-INFO +292 -31
- moleditpy-1.2.0/README.md +0 -261
- {moleditpy-1.2.0 → moleditpy-1.2.2}/setup.cfg +0 -0
- {moleditpy-1.2.0 → moleditpy-1.2.2}/src/moleditpy/__init__.py +0 -0
- {moleditpy-1.2.0 → moleditpy-1.2.2}/src/moleditpy/assets/icon.ico +0 -0
- {moleditpy-1.2.0 → moleditpy-1.2.2}/src/moleditpy/assets/icon.png +0 -0
- {moleditpy-1.2.0 → moleditpy-1.2.2}/src/moleditpy.egg-info/SOURCES.txt +0 -0
- {moleditpy-1.2.0 → moleditpy-1.2.2}/src/moleditpy.egg-info/dependency_links.txt +0 -0
- {moleditpy-1.2.0 → moleditpy-1.2.2}/src/moleditpy.egg-info/entry_points.txt +0 -0
- {moleditpy-1.2.0 → moleditpy-1.2.2}/src/moleditpy.egg-info/requires.txt +0 -0
- {moleditpy-1.2.0 → moleditpy-1.2.2}/src/moleditpy.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: moleditpy
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.2
|
|
4
4
|
Summary: A cross-platform, simple, and intuitive molecular structure editor built in Python. It allows 2D molecular drawing and 3D structure visualization. It supports exporting structure files for input to DFT calculation software.
|
|
5
5
|
Author-email: HiroYokoyama <titech.yoko.hiro@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/HiroYokoyama/python_molecular_editor
|
|
@@ -28,36 +28,76 @@ Requires-Dist: openbabel-wheel
|
|
|
28
28
|
[](https://doi.org/10.5281/zenodo.17268532)
|
|
29
29
|
[](https://www.rdkit.org/)
|
|
30
30
|
|
|
31
|
-
Python
|
|
31
|
+
A cross-platform, simple, and intuitive molecular structure editor built in Python. It allows 2D molecular drawing and 3D structure visualization. It supports exporting structure files, and its interactive 3D editing capabilities allow for the intuitive creation of desired conformations, making it **ideal for preparing inputs for DFT calculation software**.
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
**Author**: HiroYokoyama
|
|
34
|
+
**License**: Apache-2.0
|
|
35
|
+
**Repository**: [https://github.com/HiroYokoyama/python\_molecular\_editor](https://github.com/HiroYokoyama/python_molecular_editor)
|
|
34
36
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
-----
|
|
38
|
+
|
|
39
|
+
Pythonで構築された、クロスプラットフォームかつシンプルで直感的な分子構造エディターです。2Dでの分子描画と3D構造可視化ができます。構造ファイルのエクスポートをサポートし、さらにインタラクティブな3D編集機能で目的の配座を直感的に作成できるため、**DFT計算のインプット作成に最適です**。
|
|
40
|
+
|
|
41
|
+
**作者**: HiroYokoyama
|
|
42
|
+
**ライセンス**: Apache-2.0
|
|
43
|
+
**リポジトリ**: [https://github.com/HiroYokoyama/python\_molecular\_editor](https://github.com/HiroYokoyama/python_molecular_editor)
|
|
38
44
|
|
|
45
|
+
-----
|
|
39
46
|

|
|
47
|
+
-----
|
|
48
|
+
|
|
49
|
+
## Overview
|
|
50
|
+
|
|
51
|
+
This application is a tool for easily drawing molecular structures and visually inspecting their three-dimensional shapes. It combines a modern GUI by **PyQt6**, powerful chemical calculations by **RDKit**, and high-performance 3D rendering by **PyVista**.
|
|
40
52
|
|
|
41
53
|
-----
|
|
42
54
|
|
|
43
|
-
|
|
55
|
+
### 概要
|
|
44
56
|
|
|
45
57
|
このアプリケーションは、分子構造を容易に描き、その3次元的な形状を視覚的に確認するためのツールです。**PyQt6**によるモダンなGUI、**RDKit**による強力な化学計算、**PyVista**による高性能な3Dレンダリングを組み合わせています。
|
|
46
58
|
|
|
47
59
|
-----
|
|
48
60
|
|
|
49
|
-
##
|
|
61
|
+
## Key Features
|
|
62
|
+
|
|
63
|
+
### 1\. 2D Drawing and Editing
|
|
64
|
+
|
|
65
|
+
* **Intuitive Operations:** Easily add, edit, or delete atoms and bonds with intuitive mouse controls. Add/edit with click-and-drag, and **delete items with a right-click** or by using the `Delete` / `Backspace` keys.
|
|
66
|
+
* **Improved Template Placement:** Place templates for benzene or 3- to 9-membered rings with a live preview. Features **advanced logic to automatically adjust the double-bond configuration of benzene rings** when fused to existing bonds.
|
|
67
|
+
* **Charge/Radical Operations:** Easily set formal charges and radicals by clicking on an atom or using keyboard shortcuts (`+`/`-`/`.`).
|
|
68
|
+
* **Selection from Periodic Table:** Select any element from a periodic table dialog.
|
|
69
|
+
* **Enhanced Selection Tools:**
|
|
70
|
+
* Supports `Cut` (`Ctrl+X`), `Copy` (`Ctrl+C`), and `Paste` (`Ctrl+V`) for clipboard operations on molecular fragments.
|
|
71
|
+
* `Space`: Toggles select mode / Selects all in select mode.
|
|
50
72
|
|
|
51
|
-
### 1\. 2D 描画と編集
|
|
52
73
|
|
|
53
|
-
|
|
74
|
+
### 1\. 2D描画と編集
|
|
75
|
+
|
|
76
|
+
* **直感的な操作:** 直感的なマウス操作で原子や結合の追加・編集・削除が簡単に行えます。クリック&ドラッグで追加・編集し、**右クリックでアイテムを削除**できます。また`Delete` / `Backspace`キーでも削除可能です。
|
|
54
77
|
* **テンプレート配置の改良:** ベンゼン環や3〜9員環のテンプレートをプレビューして配置可能。既存の結合にフューズする際、**ベンゼン環の二重結合配置を自動調整する高度なロジック**を搭載しました。
|
|
55
78
|
* **電荷・ラジカル操作:** 原子をクリックするか、キーボードショートカット (`+`/`-`/`.`) で、形式電荷やラジカルを簡単に設定できます。
|
|
56
79
|
* **周期表からの選択:** 周期表ダイアログから任意の元素を選択可能です。
|
|
57
80
|
* **選択操作の充実:**
|
|
58
81
|
* `Cut` (`Ctrl+X`), `Copy` (`Ctrl+C`), `Paste` (`Ctrl+V`) に対応し、分子フラグメントのクリップボード操作が可能です。
|
|
59
82
|
* `Space`: 選択モード切替 / 選択モードで全選択。
|
|
60
|
-
|
|
83
|
+
|
|
84
|
+
-----
|
|
85
|
+
|
|
86
|
+
### 2\. Keyboard Shortcuts
|
|
87
|
+
|
|
88
|
+
| Key | Action | Notes |
|
|
89
|
+
| :--- | :--- | :--- |
|
|
90
|
+
| `1`/`2`/`3` | Change bond order | Single/Double/Triple bond |
|
|
91
|
+
| `W`/`D` | Change to stereochemical bond | Wedge / Dash bond |
|
|
92
|
+
| `Delete` / `Backspace` | Delete item(s) | Deletes selected or hovered items |
|
|
93
|
+
| `.` | Toggle radical | 0 → 1 → 2 → 0 |
|
|
94
|
+
| `+`/`-` | Increase/Decrease charge | Change formal charge |
|
|
95
|
+
| `C`, `N`, `O`, etc. | Change atom symbol | Applies to atom under cursor or selection |
|
|
96
|
+
| `4` | Place benzene ring | One-shot placement on atom/bond under cursor |
|
|
97
|
+
| `Ctrl+J` | Perform 2D optimization | |
|
|
98
|
+
| `Ctrl+K` | Perform 3D conversion | |
|
|
99
|
+
| `Ctrl+L` | Perform 3D optimization | |
|
|
100
|
+
|
|
61
101
|
|
|
62
102
|
### 2\. キーボードショートカット
|
|
63
103
|
|
|
@@ -65,6 +105,7 @@ A cross-platform, simple, and intuitive molecular structure editor built in Pyth
|
|
|
65
105
|
| :--- | :--- | :--- |
|
|
66
106
|
| `1`/`2`/`3` | 結合次数を変更 | 単結合/二重結合/三重結合 |
|
|
67
107
|
| `W`/`D` | 立体化学結合に変更 | Wedge / Dash 結合 |
|
|
108
|
+
| `Delete` / `Backspace` | アイテムの削除 | 選択またはカーソル下のアイテムを削除 |
|
|
68
109
|
| `.` | ラジカルをトグル | 0 → 1 → 2 → 0 |
|
|
69
110
|
| `+`/`-` | 電荷を増減 | 形式電荷の変更 |
|
|
70
111
|
| `C`, `N`, `O` など | 原子記号を変更 | カーソル下または選択中の原子に適用 |
|
|
@@ -73,28 +114,83 @@ A cross-platform, simple, and intuitive molecular structure editor built in Pyth
|
|
|
73
114
|
| `Ctrl+K` | 3D変換を実行 | |
|
|
74
115
|
| `Ctrl+L` | 3D最適化を実行 | |
|
|
75
116
|
|
|
117
|
+
-----
|
|
118
|
+
|
|
119
|
+
### 3\. 2D Structure Optimization
|
|
120
|
+
|
|
121
|
+
* Performs automatic layout using RDKit's `Compute2DCoords` (**Optimize 2D**).
|
|
122
|
+
* Implements logic to detect and **automatically separate and resolve overlapping groups of atoms** (such as non-bonded fragments).
|
|
123
|
+
|
|
124
|
+
|
|
76
125
|
### 3\. 2D構造の最適化
|
|
77
126
|
|
|
78
127
|
* RDKit の `Compute2DCoords` を使った自動レイアウト(**Optimize 2D**)を実行します。
|
|
79
128
|
* 完全に重なった原子グループ(結合していないフラグメント同士など)を検出し、**自動で分離・解消するロジック**を実装しました。
|
|
80
129
|
|
|
130
|
+
-----
|
|
131
|
+
|
|
132
|
+
### 4\. High-Quality 3D Visualization and Analysis
|
|
133
|
+
|
|
134
|
+
* **3D Conversion:** Generates 3D coordinates with RDKit and optimizes them using an MMFF94-based force field (**Convert to 3D**). If RDKit fails, it executes a **fallback to Open Babel** to enhance robustness.
|
|
135
|
+
* **Interactive Display:** Provides interactive 3D visualization (Ball & Stick / CPK styles) powered by PyVista / pyvistaqt.
|
|
136
|
+
* **Interactive 3D Editing:** When 3D edit mode is enabled, you can **directly drag atoms in the 3D view with the mouse** to fine-tune their positions. This allows for the intuitive creation of specific conformations you wish to investigate in theoretical calculations.
|
|
137
|
+
* **Chiral Label Display:** After 3D conversion, automatically assigns R/S labels to chiral centers and displays them in the **3D view**.
|
|
138
|
+
* **Molecule Analysis Window:** A dedicated window that **lists key molecular properties** based on RDKit, such as molecular formula, molecular weight, SMILES, LogP, and TPSA.
|
|
139
|
+
|
|
140
|
+
|
|
81
141
|
### 4\. 高品質な3D可視化と分析
|
|
82
142
|
|
|
83
143
|
* **3D変換:** RDKit で 3D 座標を生成し MMFF94 ベースで最適化(**Convert to 3D**)します。RDKitでの生成に失敗した場合、**Open Babelによるフォールバック**を実行し、堅牢性を高めています。
|
|
84
144
|
* **インタラクティブ表示:** PyVista / pyvistaqt によるインタラクティブな3D表示(Ball & Stick / CPK スタイル)を提供します。
|
|
85
|
-
* **インタラクティブ3D編集:** 3D編集モードを有効にすると、3D
|
|
145
|
+
* **インタラクティブ3D編集:** 3D編集モードを有効にすると、3Dビュー内の原子を**マウスで直接ドラッグして位置を微調整**できます。これにより、理論計算で検討したい特定の配座(コンフォメーション)を直感的に作り出すことができます。
|
|
86
146
|
* **キラルラベル表示:** 3D変換後、キラル中心に R/S ラベルを自動で付与し、**3Dビュー**に表示します。
|
|
87
147
|
* **分子分析ウィンドウ:** 分子式、分子量、SMILES、LogP、TPSAなど、RDKitベースの**主要な分子特性を一覧表示**する専用ウィンドウがあります。
|
|
88
148
|
|
|
149
|
+
-----
|
|
150
|
+
|
|
151
|
+
### 5\. File I/O
|
|
152
|
+
|
|
153
|
+
* **Project File (.pmeraw):** Allows you to completely save and load the editing state, including 2D drawing data, 3D structure, charges, radicals, and chiral label states.
|
|
154
|
+
* Save 2D structures in MOL format.
|
|
155
|
+
* Save 3D structures in MOL / XYZ formats. These formats are widely supported as inputs for many DFT calculation software packages.
|
|
156
|
+
* Supports importing from MOL/SDF files.
|
|
157
|
+
* Supports importing from a SMILES string.
|
|
158
|
+
|
|
159
|
+
|
|
89
160
|
### 5\. ファイル入出力
|
|
90
161
|
|
|
91
162
|
* **プロジェクトファイル (.pmeraw):** 2D描画データと3D構造、電荷、ラジカル、キラルラベルの状態など、編集状態を完全に保存/読み込みできます。
|
|
92
163
|
* 2D を MOL 形式で保存。
|
|
93
|
-
* 3D を MOL / XYZ
|
|
164
|
+
* 3D を MOL / XYZ 形式で保存。これらの形式は多くのDFT計算ソフトウェアでインプットとして利用できます。
|
|
94
165
|
* MOL/SDF の読み込みに対応しています。
|
|
166
|
+
* SMILES文字列からのインポートに対応しています。
|
|
95
167
|
|
|
96
168
|
-----
|
|
97
169
|
|
|
170
|
+
## Execution and Installation
|
|
171
|
+
|
|
172
|
+
#### Requirements
|
|
173
|
+
|
|
174
|
+
`PyQt6`, `RDKit`, `NumPy`, `PyVista`, `pyvistaqt`, `openbabel`
|
|
175
|
+
|
|
176
|
+
#### Installation Example
|
|
177
|
+
|
|
178
|
+
**Using pip:**
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
pip install moleditpy
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
> **Note**
|
|
185
|
+
> It is recommended to install RDKit and Open Babel using `conda`, a scientific computing distribution. Open Babel is required for the 3D structure conversion fallback feature.
|
|
186
|
+
|
|
187
|
+
#### Running the App
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
moleditpy
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
|
|
98
194
|
## 実行とインストール
|
|
99
195
|
|
|
100
196
|
#### 必要ライブラリ
|
|
@@ -118,7 +214,26 @@ pip install moleditpy
|
|
|
118
214
|
moleditpy
|
|
119
215
|
```
|
|
120
216
|
|
|
121
|
-
|
|
217
|
+
-----
|
|
218
|
+
|
|
219
|
+
## Development Environment
|
|
220
|
+
|
|
221
|
+
The recommended development and execution environment for MoleditPy is as follows.
|
|
222
|
+
|
|
223
|
+
| Component | Version |
|
|
224
|
+
| :--- | :--- |
|
|
225
|
+
| **Python** | `3.13.7` |
|
|
226
|
+
| **numpy** | `2.3.3` |
|
|
227
|
+
| **openbabel-wheel** | `3.1.1.22` |
|
|
228
|
+
| **PyQt6** | `6.9.1` |
|
|
229
|
+
| **QtPy** | `2.4.3` |
|
|
230
|
+
| **rdkit** | `2025.3.6` |
|
|
231
|
+
| **vtk** | `9.5.2` |
|
|
232
|
+
| **pyvista** | `0.46.3` |
|
|
233
|
+
| **pyvistaqt** | `0.11.3` |
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
### 開発環境
|
|
122
237
|
|
|
123
238
|
MoleditPyの動作確認および推奨される開発・実行環境は以下の通りです。
|
|
124
239
|
|
|
@@ -136,11 +251,61 @@ MoleditPyの動作確認および推奨される開発・実行環境は以下
|
|
|
136
251
|
|
|
137
252
|
-----
|
|
138
253
|
|
|
139
|
-
## Windows:
|
|
254
|
+
## Windows: Shortcut and File Association Guide
|
|
255
|
+
|
|
256
|
+
This guide provides detailed steps for setting up the application in a Windows environment, allowing you to open project files (`.pmeraw`) by double-clicking and launch the application from a shortcut with a custom icon.
|
|
257
|
+
|
|
258
|
+
### 1\. Paths for Executable and Icon
|
|
259
|
+
|
|
260
|
+
| Item | Details |
|
|
261
|
+
| :--- | :--- |
|
|
262
|
+
| **Target Application** | `C:\Users\%USERNAME%\AppData\Local\Programs\Python\PythonXX\Scripts\moleditpy.exe` |
|
|
263
|
+
| **File Extension** | `.pmeraw` |
|
|
264
|
+
| **Icon File Path** | `C:\Users\%USERNAME%\AppData\Local\Programs\Python\PythonXX\Lib\site-packages\moleditpy\assets\icon.ico` |
|
|
265
|
+
|
|
266
|
+
> **Note:** Replace `%USERNAME%` with your actual username and `PythonXX` with the directory name of your installed Python version (e.g., `Python311`).
|
|
267
|
+
|
|
268
|
+
### 2\. File Association Steps (to open .pmeraw files on double-click)
|
|
269
|
+
|
|
270
|
+
Follow these steps to associate `.pmeraw` files with `moleditpy.exe`.
|
|
271
|
+
|
|
272
|
+
1. **Find a `.pmeraw` file:** In File Explorer, **right-click** on a file you want to associate (e.g., `sample.pmeraw`).
|
|
273
|
+
2. **Change association:** From the context menu, select **"Properties"**, and in the "General" tab, click the **"Change..."** button next to "Opens with:".
|
|
274
|
+
3. **Select the program:** In the "How do you want to open this file?" window, choose "More apps" → **"Look for another app on this PC"**.
|
|
275
|
+
4. **Specify the executable:** Navigate to the path of **`moleditpy.exe`** (with placeholders replaced) mentioned above and click "Open" to complete the process.
|
|
276
|
+
|
|
277
|
+
> **Tip:** Applying a custom icon to a file association system-wide typically requires editing the registry. This is an advanced operation and should be done with caution.
|
|
278
|
+
|
|
279
|
+
### 3\. Desktop Shortcut Creation Steps
|
|
280
|
+
|
|
281
|
+
Create a shortcut with a custom icon to launch the application.
|
|
282
|
+
|
|
283
|
+
1. **Create a new shortcut:** Right-click on your desktop or any desired location, then select "New" → **"Shortcut"**.
|
|
284
|
+
2. **Enter the executable path:** In the "Type the location of the item" field, enter the full path to the executable and click "Next".
|
|
285
|
+
3. **Name the shortcut:** Give the shortcut a name (e.g., `MoleditPy`) and click "Finish".
|
|
286
|
+
4. **Change the icon:**
|
|
287
|
+
* Right-click the newly created shortcut and select **"Properties"**.
|
|
288
|
+
* In the "Shortcut" tab, click the **"Change Icon..."** button.
|
|
289
|
+
* Browse to the icon file path mentioned above and select `icon.ico`.
|
|
290
|
+
* Click "OK" → "Apply" → "OK" to finish.
|
|
291
|
+
|
|
292
|
+
### 4\. How to Pin the Shortcut to the Start Menu
|
|
293
|
+
|
|
294
|
+
To make the shortcut appear in the Windows Start Menu program list, place it in the following folder:
|
|
295
|
+
|
|
296
|
+
1. **Locate the Start Menu folder:** Open File Explorer and enter one of the following paths in the address bar:
|
|
297
|
+
* **For the current user only (Recommended):** `%APPDATA%\Microsoft\Windows\Start Menu\Programs`
|
|
298
|
+
* **For all users (Requires administrator privileges):** `%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs`
|
|
299
|
+
2. **Copy or move the shortcut:** **Copy or move** the shortcut you created (e.g., the `MoleditPy` shortcut from your desktop) into this folder. (Holding `Ctrl` while dragging will copy it.)
|
|
300
|
+
3. **Confirm:** Click the Start button and check that the shortcut name now appears in the program list.
|
|
301
|
+
|
|
302
|
+
-----
|
|
303
|
+
|
|
304
|
+
### Windows: ショートカットとファイル関連付けガイド
|
|
140
305
|
|
|
141
306
|
Windows環境でプロジェクトファイル(`.pmeraw`)をダブルクリックで開いたり、アイコン付きのショートカットからアプリケーションを起動したりするための詳細な設定手順です。
|
|
142
307
|
|
|
143
|
-
|
|
308
|
+
#### 1\. 実行ファイルとアイコンのパス
|
|
144
309
|
|
|
145
310
|
| 項目 | 詳細 |
|
|
146
311
|
| :--- | :--- |
|
|
@@ -150,7 +315,7 @@ Windows環境でプロジェクトファイル(`.pmeraw`)をダブルクリ
|
|
|
150
315
|
|
|
151
316
|
> **注意:** `%USERNAME%` はお使いのユーザー名、`PythonXX` はインストールされているPythonのバージョンディレクトリ名(例: `Python311`)に置き換えてください。
|
|
152
317
|
|
|
153
|
-
|
|
318
|
+
#### 2\. ファイルの関連付け手順 (.pmeraw をダブルクリックで開く)
|
|
154
319
|
|
|
155
320
|
`.pmeraw` ファイルを `moleditpy.exe` で開けるようにする手順です。
|
|
156
321
|
|
|
@@ -161,7 +326,7 @@ Windows環境でプロジェクトファイル(`.pmeraw`)をダブルクリ
|
|
|
161
326
|
|
|
162
327
|
> **補足:** カスタムアイコンをシステム全体のファイル関連付けに適用するには、通常、レジストリを編集する必要があります。レジストリ操作は上級者向けであり、慎重に行ってください。
|
|
163
328
|
|
|
164
|
-
|
|
329
|
+
#### 3\. デスクトップショートカットの作成手順
|
|
165
330
|
|
|
166
331
|
アプリケーションを起動するためのアイコン付きショートカットを作成します。
|
|
167
332
|
|
|
@@ -174,7 +339,7 @@ Windows環境でプロジェクトファイル(`.pmeraw`)をダブルクリ
|
|
|
174
339
|
* 上記のアイコンファイルのパスを参照して `icon.ico` を選択します。
|
|
175
340
|
* 「OK」→「適用」→「OK」をクリックして完了です。
|
|
176
341
|
|
|
177
|
-
|
|
342
|
+
#### 4\. ショートカットをスタートメニューに配置する方法
|
|
178
343
|
|
|
179
344
|
作成したショートカットをWindowsのスタートメニューのプログラム一覧に表示するには、以下の手順でフォルダに配置します。
|
|
180
345
|
|
|
@@ -186,11 +351,90 @@ Windows環境でプロジェクトファイル(`.pmeraw`)をダブルクリ
|
|
|
186
351
|
|
|
187
352
|
-----
|
|
188
353
|
|
|
189
|
-
## macOS: Python CLI
|
|
354
|
+
## macOS: How to create a .app from a Python CLI app via Automator
|
|
355
|
+
|
|
356
|
+
This guide explains how to turn a Python app installed with `pip install moleditpy` into a native **.app** application on macOS, complete with a custom icon.
|
|
357
|
+
|
|
358
|
+
### 1\. Locate the Binary
|
|
359
|
+
|
|
360
|
+
The executable binary will be generated at a path similar to this:
|
|
361
|
+
|
|
362
|
+
```
|
|
363
|
+
/Users/<username>/Library/Python/<python_version>/bin/moleditpy
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
### 2\. Create a New Application in Automator
|
|
367
|
+
|
|
368
|
+
1. Open **Automator**.
|
|
369
|
+
2. Select **"New Document"** → **"Application"**.
|
|
370
|
+
3. From the left pane, find "Utilities" → and add **"Run Shell Script"**.
|
|
371
|
+
|
|
372
|
+
### 3\. Configure the Script
|
|
373
|
+
|
|
374
|
+
Enter the following into the script area. The `"$@"` part is to pass any files dropped onto the app as arguments.
|
|
375
|
+
|
|
376
|
+
```bash
|
|
377
|
+
#!/bin/bash
|
|
378
|
+
/Users/<username>/Library/Python/<python_version>/bin/moleditpy "$@"
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
### 4\. Save as an Application
|
|
382
|
+
|
|
383
|
+
1. From the menu, select **"File"** → **"Save"**.
|
|
384
|
+
2. Name it **`MoleditPy.app`**.
|
|
385
|
+
3. You can save it to your Desktop temporarily.
|
|
386
|
+
|
|
387
|
+
### 5\. Move to the Applications Folder
|
|
388
|
+
|
|
389
|
+
After saving, copy the created app to the system's standard Applications folder.
|
|
390
|
+
|
|
391
|
+
**Copying via Finder:**
|
|
392
|
+
|
|
393
|
+
1. Select `MoleditPy.app` in Finder and copy it with `⌘ + C`.
|
|
394
|
+
2. Open the **"Applications"** folder from the Finder's "Go" menu.
|
|
395
|
+
3. Paste it with `⌘ + V`.
|
|
396
|
+
|
|
397
|
+
**Copying via Terminal:**
|
|
398
|
+
|
|
399
|
+
```bash
|
|
400
|
+
sudo cp -R ~/Desktop/MoleditPy.app /Applications/
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
### 6\. Set the Icon
|
|
404
|
+
|
|
405
|
+
Location of the icon image:
|
|
406
|
+
|
|
407
|
+
```
|
|
408
|
+
/Users/<username>/Library/Python/<python_version>/lib/python<python_version>/site-packages/moleditpy/assets/icon.png
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
**Icon Setting Steps (Copy-Paste Method):**
|
|
412
|
+
|
|
413
|
+
1. Open the `icon.png` from the path above in Finder.
|
|
414
|
+
2. With the image open in "Preview," press `⌘ + A` to **select all**, then `⌘ + C` to **copy**.
|
|
415
|
+
3. In Finder, select `MoleditPy.app` in the `/Applications` folder and press `⌘ + I` (Get Info).
|
|
416
|
+
4. Click the small icon in the top-left corner (a border will appear) → press `⌘ + V` to **paste**.
|
|
417
|
+
The app's icon will now be updated.
|
|
418
|
+
|
|
419
|
+
### 7\. Check Execution Permissions (if necessary)
|
|
420
|
+
|
|
421
|
+
If the app fails to launch, run the following command:
|
|
422
|
+
|
|
423
|
+
```bash
|
|
424
|
+
chmod +x /Users/<username>/Library/Python/<python_version>/bin/moleditpy
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
### 8\. Done\!
|
|
428
|
+
|
|
429
|
+
Now you can run the Python app just by double-clicking **`MoleditPy.app`** installed in `/Applications`.
|
|
430
|
+
|
|
431
|
+
-----
|
|
432
|
+
|
|
433
|
+
### macOS: Python CLIアプリをAutomator経由で.app化する方法
|
|
190
434
|
|
|
191
435
|
この手順では、`pip install moleditpy` でインストールしたPythonアプリをmacOS上で\*\*.appアプリケーション\*\*として使えるようにし、独自アイコンを設定します。
|
|
192
436
|
|
|
193
|
-
|
|
437
|
+
#### 1\. バイナリの場所を確認
|
|
194
438
|
|
|
195
439
|
以下のようなパスに実行ファイル(バイナリ)が生成されます:
|
|
196
440
|
|
|
@@ -198,13 +442,13 @@ Windows環境でプロジェクトファイル(`.pmeraw`)をダブルクリ
|
|
|
198
442
|
/Users/<username>/Library/Python/<python_version>/bin/moleditpy
|
|
199
443
|
```
|
|
200
444
|
|
|
201
|
-
|
|
445
|
+
#### 2\. Automatorで新規アプリケーションを作成
|
|
202
446
|
|
|
203
447
|
1. **Automator** を開きます。
|
|
204
448
|
2. **「新規書類」** → **「アプリケーション」** を選択します。
|
|
205
449
|
3. 左の一覧から「ユーティリティ」→\*\*「シェルスクリプトを実行」\*\* を追加します。
|
|
206
450
|
|
|
207
|
-
|
|
451
|
+
#### 3\. スクリプトを設定
|
|
208
452
|
|
|
209
453
|
スクリプト欄に以下を入力します。`"$@"` は、ドラッグ&ドロップされたファイルを引数として渡すためのものです。
|
|
210
454
|
|
|
@@ -213,13 +457,13 @@ Windows環境でプロジェクトファイル(`.pmeraw`)をダブルクリ
|
|
|
213
457
|
/Users/<username>/Library/Python/<python_version>/bin/moleditpy "$@"
|
|
214
458
|
```
|
|
215
459
|
|
|
216
|
-
|
|
460
|
+
#### 4\. アプリとして保存
|
|
217
461
|
|
|
218
462
|
1. メニューから\*\*「ファイル」\*\* → **「保存」** を選択します。
|
|
219
463
|
2. 名前を **`MoleditPy.app`** にします。
|
|
220
464
|
3. 保存場所は一時的にデスクトップなど任意で構いません。
|
|
221
465
|
|
|
222
|
-
|
|
466
|
+
#### 5\. アプリケーションフォルダーへ移動
|
|
223
467
|
|
|
224
468
|
保存後、作成したアプリをシステム標準のアプリケーションフォルダーへコピーします。
|
|
225
469
|
|
|
@@ -235,7 +479,7 @@ Windows環境でプロジェクトファイル(`.pmeraw`)をダブルクリ
|
|
|
235
479
|
sudo cp -R ~/Desktop/MoleditPy.app /Applications/
|
|
236
480
|
```
|
|
237
481
|
|
|
238
|
-
|
|
482
|
+
#### 6\. アイコンを設定
|
|
239
483
|
|
|
240
484
|
アイコン画像の場所:
|
|
241
485
|
|
|
@@ -251,7 +495,7 @@ sudo cp -R ~/Desktop/MoleditPy.app /Applications/
|
|
|
251
495
|
4. 左上の小さいアイコンをクリック(枠が出る) → `⌘ + V` で**貼り付け**ます。
|
|
252
496
|
これでアプリのアイコンが変更されます。
|
|
253
497
|
|
|
254
|
-
|
|
498
|
+
#### 7\. 実行権限を確認(必要な場合)
|
|
255
499
|
|
|
256
500
|
起動できない場合は、以下を実行してください。
|
|
257
501
|
|
|
@@ -259,13 +503,26 @@ sudo cp -R ~/Desktop/MoleditPy.app /Applications/
|
|
|
259
503
|
chmod +x /Users/<username>/Library/Python/<python_version>/bin/moleditpy
|
|
260
504
|
```
|
|
261
505
|
|
|
262
|
-
|
|
506
|
+
#### 8\. 完了
|
|
263
507
|
|
|
264
508
|
これで `/Applications` にインストールされた **`MoleditPy.app`** をダブルクリックするだけでPythonアプリが実行できます。
|
|
265
509
|
|
|
266
510
|
-----
|
|
267
511
|
|
|
268
|
-
##
|
|
512
|
+
## Technical Details
|
|
513
|
+
|
|
514
|
+
* **GUI and 2D Drawing (PyQt6):**
|
|
515
|
+
* Interactively manipulates custom `AtomItem` and `BondItem` objects on a `QGraphicsScene`.
|
|
516
|
+
* The Undo/Redo feature is implemented by serializing the entire application state with `pickle` and storing it on a stack.
|
|
517
|
+
* **Chemical Calculations (RDKit / Open Babel):**
|
|
518
|
+
* Generates RDKit molecule objects from 2D data to perform 3D coordinate generation (`AllChem.EmbedMolecule`) and calculate molecular properties.
|
|
519
|
+
* When 3D coordinate generation with RDKit fails, it falls back to **Open Babel** to attempt the calculation.
|
|
520
|
+
* Calculations are performed on a separate thread (`QThread`) to maintain GUI responsiveness.
|
|
521
|
+
* **3D Visualization (PyVista / pyvistaqt):**
|
|
522
|
+
* Generates and renders PyVista meshes (spheres and cylinders) from RDKit conformer coordinates.
|
|
523
|
+
* Implements a custom `vtkInteractorStyle` to enable direct drag-and-drop editing of atoms within the 3D view.
|
|
524
|
+
|
|
525
|
+
### 技術的な仕組み
|
|
269
526
|
|
|
270
527
|
* **GUI と 2D 描画 (PyQt6):**
|
|
271
528
|
* `QGraphicsScene` 上にカスタムの `AtomItem`(原子)と `BondItem`(結合)を配置し、対話的に操作します。
|
|
@@ -280,7 +537,11 @@ chmod +x /Users/<username>/Library/Python/<python_version>/bin/moleditpy
|
|
|
280
537
|
|
|
281
538
|
-----
|
|
282
539
|
|
|
283
|
-
##
|
|
540
|
+
## License
|
|
541
|
+
|
|
542
|
+
This project is licensed under the **Apache-2.0 License**. See the `LICENSE` file for details.
|
|
284
543
|
|
|
285
|
-
このプロジェクトは **Apache-2.0 License** のもとで公開されています。詳細は `LICENSE` ファイルを参照してください。
|
|
286
544
|
|
|
545
|
+
### ライセンス
|
|
546
|
+
|
|
547
|
+
このプロジェクトは **Apache-2.0 License** のもとで公開されています。詳細は `LICENSE` ファイルを参照してください。
|