moleditpy 1.8.2__tar.gz → 1.8.3__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.8.2 → moleditpy-1.8.3}/PKG-INFO +1 -1
- {moleditpy-1.8.2 → moleditpy-1.8.3}/pyproject.toml +1 -1
- {moleditpy-1.8.2 → moleditpy-1.8.3}/src/moleditpy/main.py +84 -8
- {moleditpy-1.8.2 → moleditpy-1.8.3}/src/moleditpy.egg-info/PKG-INFO +1 -1
- {moleditpy-1.8.2 → moleditpy-1.8.3}/README.md +0 -0
- {moleditpy-1.8.2 → moleditpy-1.8.3}/setup.cfg +0 -0
- {moleditpy-1.8.2 → moleditpy-1.8.3}/src/moleditpy/__init__.py +0 -0
- {moleditpy-1.8.2 → moleditpy-1.8.3}/src/moleditpy/assets/icon.ico +0 -0
- {moleditpy-1.8.2 → moleditpy-1.8.3}/src/moleditpy/assets/icon.png +0 -0
- {moleditpy-1.8.2 → moleditpy-1.8.3}/src/moleditpy.egg-info/SOURCES.txt +0 -0
- {moleditpy-1.8.2 → moleditpy-1.8.3}/src/moleditpy.egg-info/dependency_links.txt +0 -0
- {moleditpy-1.8.2 → moleditpy-1.8.3}/src/moleditpy.egg-info/entry_points.txt +0 -0
- {moleditpy-1.8.2 → moleditpy-1.8.3}/src/moleditpy.egg-info/requires.txt +0 -0
- {moleditpy-1.8.2 → moleditpy-1.8.3}/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.8.
|
|
3
|
+
Version: 1.8.3
|
|
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
|
|
@@ -11,7 +11,7 @@ DOI 10.5281/zenodo.17268532
|
|
|
11
11
|
"""
|
|
12
12
|
|
|
13
13
|
#Version
|
|
14
|
-
VERSION = '1.8.
|
|
14
|
+
VERSION = '1.8.3'
|
|
15
15
|
|
|
16
16
|
print("-----------------------------------------------------")
|
|
17
17
|
print("MoleditPy — A Python-based molecular editing software")
|
|
@@ -3315,7 +3315,6 @@ class MoleculeScene(QGraphicsScene):
|
|
|
3315
3315
|
return needs_update
|
|
3316
3316
|
|
|
3317
3317
|
def mousePressEvent(self, event):
|
|
3318
|
-
self.clear_all_problem_flags()
|
|
3319
3318
|
self.press_pos = event.scenePos()
|
|
3320
3319
|
self.mouse_moved_since_press = False
|
|
3321
3320
|
self.data_changed_in_event = False
|
|
@@ -7131,9 +7130,8 @@ class MainWindow(QMainWindow):
|
|
|
7131
7130
|
self.mode_actions['select'].setChecked(True)
|
|
7132
7131
|
|
|
7133
7132
|
def trigger_conversion(self):
|
|
7134
|
-
|
|
7135
|
-
if not
|
|
7136
|
-
# 3Dビューと関連データをクリア
|
|
7133
|
+
# 2Dエディタに原子が存在しない場合は3Dビューをクリア
|
|
7134
|
+
if not self.data.atoms:
|
|
7137
7135
|
self.plotter.clear()
|
|
7138
7136
|
self.current_mol = None
|
|
7139
7137
|
self.analysis_action.setEnabled(False)
|
|
@@ -7141,8 +7139,13 @@ class MainWindow(QMainWindow):
|
|
|
7141
7139
|
self.view_2d.setFocus()
|
|
7142
7140
|
return
|
|
7143
7141
|
|
|
7144
|
-
|
|
7145
|
-
|
|
7142
|
+
mol = self.data.to_rdkit_mol(use_2d_stereo=False)
|
|
7143
|
+
|
|
7144
|
+
# 分子オブジェクトが作成できない場合でも化学的問題をチェック
|
|
7145
|
+
if not mol or mol.GetNumAtoms() == 0:
|
|
7146
|
+
# RDKitでの変換に失敗した場合は、独自の化学的問題チェックを実行
|
|
7147
|
+
self.check_chemistry_problems_fallback()
|
|
7148
|
+
return
|
|
7146
7149
|
|
|
7147
7150
|
# 原子プロパティを保存(ワーカープロセスで失われるため)
|
|
7148
7151
|
self.original_atom_properties = {}
|
|
@@ -7156,6 +7159,8 @@ class MainWindow(QMainWindow):
|
|
|
7156
7159
|
|
|
7157
7160
|
problems = Chem.DetectChemistryProblems(mol)
|
|
7158
7161
|
if problems:
|
|
7162
|
+
# 化学的問題が見つかった場合は既存のフラグをクリアしてから新しい問題を表示
|
|
7163
|
+
self.scene.clear_all_problem_flags()
|
|
7159
7164
|
self.statusBar().showMessage(f"Error: {len(problems)} chemistry problem(s) found.")
|
|
7160
7165
|
# 既存の選択状態をクリア
|
|
7161
7166
|
self.scene.clearSelection()
|
|
@@ -7175,6 +7180,9 @@ class MainWindow(QMainWindow):
|
|
|
7175
7180
|
self.view_2d.setFocus()
|
|
7176
7181
|
return
|
|
7177
7182
|
|
|
7183
|
+
# 化学的問題がない場合のみフラグをクリアして3D変換を実行
|
|
7184
|
+
self.scene.clear_all_problem_flags()
|
|
7185
|
+
|
|
7178
7186
|
try:
|
|
7179
7187
|
Chem.SanitizeMol(mol)
|
|
7180
7188
|
except Exception:
|
|
@@ -7251,6 +7259,63 @@ class MainWindow(QMainWindow):
|
|
|
7251
7259
|
|
|
7252
7260
|
self.view_2d.setFocus()
|
|
7253
7261
|
|
|
7262
|
+
def check_chemistry_problems_fallback(self):
|
|
7263
|
+
"""RDKit変換が失敗した場合の化学的問題チェック(独自実装)"""
|
|
7264
|
+
try:
|
|
7265
|
+
# 既存のフラグをクリア
|
|
7266
|
+
self.scene.clear_all_problem_flags()
|
|
7267
|
+
|
|
7268
|
+
# 簡易的な化学的問題チェック
|
|
7269
|
+
problem_atoms = []
|
|
7270
|
+
|
|
7271
|
+
for atom_id, atom_data in self.data.atoms.items():
|
|
7272
|
+
atom_item = atom_data.get('item')
|
|
7273
|
+
if not atom_item:
|
|
7274
|
+
continue
|
|
7275
|
+
|
|
7276
|
+
symbol = atom_data['symbol']
|
|
7277
|
+
charge = atom_data.get('charge', 0)
|
|
7278
|
+
|
|
7279
|
+
# 結合数を計算
|
|
7280
|
+
bond_count = 0
|
|
7281
|
+
for (id1, id2), bond_data in self.data.bonds.items():
|
|
7282
|
+
if id1 == atom_id or id2 == atom_id:
|
|
7283
|
+
bond_count += bond_data.get('order', 1)
|
|
7284
|
+
|
|
7285
|
+
# 基本的な価数チェック
|
|
7286
|
+
is_problematic = False
|
|
7287
|
+
if symbol == 'C' and bond_count > 4:
|
|
7288
|
+
is_problematic = True
|
|
7289
|
+
elif symbol == 'N' and bond_count > 3 and charge == 0:
|
|
7290
|
+
is_problematic = True
|
|
7291
|
+
elif symbol == 'O' and bond_count > 2 and charge == 0:
|
|
7292
|
+
is_problematic = True
|
|
7293
|
+
elif symbol == 'H' and bond_count > 1:
|
|
7294
|
+
is_problematic = True
|
|
7295
|
+
elif symbol in ['F', 'Cl', 'Br', 'I'] and bond_count > 1 and charge == 0:
|
|
7296
|
+
is_problematic = True
|
|
7297
|
+
|
|
7298
|
+
if is_problematic:
|
|
7299
|
+
problem_atoms.append(atom_item)
|
|
7300
|
+
|
|
7301
|
+
if problem_atoms:
|
|
7302
|
+
# 問題のある原子に赤枠を設定
|
|
7303
|
+
for atom_item in problem_atoms:
|
|
7304
|
+
atom_item.has_problem = True
|
|
7305
|
+
atom_item.update()
|
|
7306
|
+
|
|
7307
|
+
self.statusBar().showMessage(f"Error: {len(problem_atoms)} chemistry problem(s) found (valence issues).")
|
|
7308
|
+
else:
|
|
7309
|
+
self.statusBar().showMessage("Error: Invalid chemical structure (RDKit conversion failed).")
|
|
7310
|
+
|
|
7311
|
+
self.scene.clearSelection()
|
|
7312
|
+
self.view_2d.setFocus()
|
|
7313
|
+
|
|
7314
|
+
except Exception as e:
|
|
7315
|
+
print(f"Error in fallback chemistry check: {e}")
|
|
7316
|
+
self.statusBar().showMessage("Error: Invalid chemical structure.")
|
|
7317
|
+
self.view_2d.setFocus()
|
|
7318
|
+
|
|
7254
7319
|
def optimize_3d_structure(self):
|
|
7255
7320
|
"""現在の3D分子構造を力場で最適化する"""
|
|
7256
7321
|
if not self.current_mol:
|
|
@@ -9100,9 +9165,20 @@ class MainWindow(QMainWindow):
|
|
|
9100
9165
|
|
|
9101
9166
|
def clean_up_2d_structure(self):
|
|
9102
9167
|
self.statusBar().showMessage("Optimizing 2D structure...")
|
|
9168
|
+
|
|
9169
|
+
# 最初に既存の化学的問題フラグをクリア
|
|
9170
|
+
self.scene.clear_all_problem_flags()
|
|
9171
|
+
|
|
9172
|
+
# 2Dエディタに原子が存在しない場合
|
|
9173
|
+
if not self.data.atoms:
|
|
9174
|
+
self.statusBar().showMessage("Error: No atoms to optimize.")
|
|
9175
|
+
return
|
|
9176
|
+
|
|
9103
9177
|
mol = self.data.to_rdkit_mol()
|
|
9104
9178
|
if mol is None or mol.GetNumAtoms() == 0:
|
|
9105
|
-
|
|
9179
|
+
# RDKit変換が失敗した場合は化学的問題をチェック
|
|
9180
|
+
self.check_chemistry_problems_fallback()
|
|
9181
|
+
return
|
|
9106
9182
|
|
|
9107
9183
|
try:
|
|
9108
9184
|
# 安定版:原子IDとRDKit座標の確実なマッピング
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: moleditpy
|
|
3
|
-
Version: 1.8.
|
|
3
|
+
Version: 1.8.3
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|