moleditpy 1.3.0__tar.gz → 1.3.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.3.0 → moleditpy-1.3.2}/PKG-INFO +1 -1
- {moleditpy-1.3.0 → moleditpy-1.3.2}/pyproject.toml +1 -1
- {moleditpy-1.3.0 → moleditpy-1.3.2}/src/moleditpy/main.py +74 -18
- {moleditpy-1.3.0 → moleditpy-1.3.2}/src/moleditpy.egg-info/PKG-INFO +1 -1
- {moleditpy-1.3.0 → moleditpy-1.3.2}/README.md +0 -0
- {moleditpy-1.3.0 → moleditpy-1.3.2}/setup.cfg +0 -0
- {moleditpy-1.3.0 → moleditpy-1.3.2}/src/moleditpy/__init__.py +0 -0
- {moleditpy-1.3.0 → moleditpy-1.3.2}/src/moleditpy/assets/icon.ico +0 -0
- {moleditpy-1.3.0 → moleditpy-1.3.2}/src/moleditpy/assets/icon.png +0 -0
- {moleditpy-1.3.0 → moleditpy-1.3.2}/src/moleditpy.egg-info/SOURCES.txt +0 -0
- {moleditpy-1.3.0 → moleditpy-1.3.2}/src/moleditpy.egg-info/dependency_links.txt +0 -0
- {moleditpy-1.3.0 → moleditpy-1.3.2}/src/moleditpy.egg-info/entry_points.txt +0 -0
- {moleditpy-1.3.0 → moleditpy-1.3.2}/src/moleditpy.egg-info/requires.txt +0 -0
- {moleditpy-1.3.0 → moleditpy-1.3.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.3.
|
|
3
|
+
Version: 1.3.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
|
|
@@ -11,7 +11,7 @@ DOI 10.5281/zenodo.17268532
|
|
|
11
11
|
"""
|
|
12
12
|
|
|
13
13
|
#Version
|
|
14
|
-
VERSION = '1.3.
|
|
14
|
+
VERSION = '1.3.2'
|
|
15
15
|
|
|
16
16
|
print("-----------------------------------------------------")
|
|
17
17
|
print("MoleditPy — A Python-based molecular editing software")
|
|
@@ -1522,32 +1522,78 @@ class MoleculeScene(QGraphicsScene):
|
|
|
1522
1522
|
target_bonds = [it for it in self.selectedItems() if isinstance(it, BondItem)]
|
|
1523
1523
|
|
|
1524
1524
|
if target_bonds:
|
|
1525
|
-
|
|
1525
|
+
any_bond_changed = False
|
|
1526
1526
|
for bond in target_bonds:
|
|
1527
|
+
# 1. 結合の向きを考慮して、データ辞書内の現在のキーを正しく特定する
|
|
1527
1528
|
id1, id2 = bond.atom1.atom_id, bond.atom2.atom_id
|
|
1528
|
-
|
|
1529
|
+
current_key = None
|
|
1530
|
+
if (id1, id2) in self.data.bonds:
|
|
1531
|
+
current_key = (id1, id2)
|
|
1532
|
+
elif (id2, id1) in self.data.bonds:
|
|
1533
|
+
current_key = (id2, id1)
|
|
1534
|
+
|
|
1535
|
+
if not current_key: continue
|
|
1536
|
+
|
|
1537
|
+
# 2. 変更前の状態を保存
|
|
1538
|
+
old_order, old_stereo = bond.order, bond.stereo
|
|
1539
|
+
|
|
1540
|
+
# 3. キー入力に応じてBondItemのプロパティを変更
|
|
1541
|
+
if key == Qt.Key.Key_W:
|
|
1542
|
+
if bond.stereo == 1:
|
|
1543
|
+
bond_data = self.data.bonds.pop(current_key)
|
|
1544
|
+
new_key = (current_key[1], current_key[0])
|
|
1545
|
+
self.data.bonds[new_key] = bond_data
|
|
1546
|
+
bond.atom1, bond.atom2 = bond.atom2, bond.atom1
|
|
1547
|
+
bond.update_position()
|
|
1548
|
+
was_reversed = True
|
|
1549
|
+
else:
|
|
1550
|
+
bond.order = 1; bond.stereo = 1
|
|
1551
|
+
|
|
1552
|
+
elif key == Qt.Key.Key_D:
|
|
1553
|
+
if bond.stereo == 2:
|
|
1554
|
+
bond_data = self.data.bonds.pop(current_key)
|
|
1555
|
+
new_key = (current_key[1], current_key[0])
|
|
1556
|
+
self.data.bonds[new_key] = bond_data
|
|
1557
|
+
bond.atom1, bond.atom2 = bond.atom2, bond.atom1
|
|
1558
|
+
bond.update_position()
|
|
1559
|
+
was_reversed = True
|
|
1560
|
+
else:
|
|
1561
|
+
bond.order = 1; bond.stereo = 2
|
|
1529
1562
|
|
|
1530
|
-
|
|
1531
|
-
bond.order = 1; bond.stereo = 0
|
|
1563
|
+
elif key == Qt.Key.Key_1 and (bond.order != 1 or bond.stereo != 0):
|
|
1564
|
+
bond.order = 1; bond.stereo = 0
|
|
1532
1565
|
elif key == Qt.Key.Key_2 and bond.order != 2:
|
|
1533
1566
|
bond.order = 2; bond.stereo = 0; needs_update = True
|
|
1534
1567
|
elif key == Qt.Key.Key_3 and bond.order != 3:
|
|
1535
1568
|
bond.order = 3; bond.stereo = 0; needs_update = True
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
self.data.bonds
|
|
1543
|
-
|
|
1569
|
+
|
|
1570
|
+
# 4. 実際に変更があった場合のみデータモデルを更新
|
|
1571
|
+
if old_order != bond.order or old_stereo != bond.stereo:
|
|
1572
|
+
any_bond_changed = True
|
|
1573
|
+
|
|
1574
|
+
# 5. 古いキーでデータを辞書から一度削除
|
|
1575
|
+
bond_data = self.data.bonds.pop(current_key)
|
|
1576
|
+
bond_data['order'] = bond.order
|
|
1577
|
+
bond_data['stereo'] = bond.stereo
|
|
1578
|
+
|
|
1579
|
+
# 6. 変更後の種類に応じて新しいキーを決定し、再登録する
|
|
1580
|
+
new_key_id1, new_key_id2 = bond.atom1.atom_id, bond.atom2.atom_id
|
|
1581
|
+
if bond.stereo == 0:
|
|
1582
|
+
if new_key_id1 > new_key_id2:
|
|
1583
|
+
new_key_id1, new_key_id2 = new_key_id2, new_key_id1
|
|
1584
|
+
|
|
1585
|
+
new_key = (new_key_id1, new_key_id2)
|
|
1586
|
+
self.data.bonds[new_key] = bond_data
|
|
1587
|
+
|
|
1544
1588
|
bond.update()
|
|
1545
1589
|
|
|
1546
|
-
if
|
|
1590
|
+
if any_bond_changed:
|
|
1547
1591
|
self.window.push_undo_state()
|
|
1592
|
+
|
|
1593
|
+
if key in [Qt.Key.Key_1, Qt.Key.Key_2, Qt.Key.Key_3, Qt.Key.Key_W, Qt.Key.Key_D]:
|
|
1548
1594
|
event.accept()
|
|
1549
1595
|
return
|
|
1550
|
-
|
|
1596
|
+
|
|
1551
1597
|
# --- 3. Atomに対する操作 (原子の追加 - マージされた機能) ---
|
|
1552
1598
|
if key == Qt.Key.Key_1:
|
|
1553
1599
|
start_atom = None
|
|
@@ -3013,6 +3059,11 @@ class MainWindow(QMainWindow):
|
|
|
3013
3059
|
|
|
3014
3060
|
mol_block = Chem.MolToMolBlock(mol, includeStereo=True)
|
|
3015
3061
|
self.convert_button.setEnabled(False)
|
|
3062
|
+
self.cleanup_button.setEnabled(False)
|
|
3063
|
+
self.optimize_3d_button.setEnabled(False)
|
|
3064
|
+
self.export_button.setEnabled(False)
|
|
3065
|
+
self.analysis_action.setEnabled(False)
|
|
3066
|
+
self.edit_3d_action.setEnabled(False)
|
|
3016
3067
|
self.statusBar().showMessage("Calculating 3D structure...")
|
|
3017
3068
|
self.plotter.clear()
|
|
3018
3069
|
text_actor = self.plotter.add_text(
|
|
@@ -3074,6 +3125,7 @@ class MainWindow(QMainWindow):
|
|
|
3074
3125
|
self.analysis_action.setEnabled(True)
|
|
3075
3126
|
self.push_undo_state()
|
|
3076
3127
|
self.view_2d.setFocus()
|
|
3128
|
+
self.cleanup_button.setEnabled(True)
|
|
3077
3129
|
self.optimize_3d_button.setEnabled(True)
|
|
3078
3130
|
self.export_button.setEnabled(True)
|
|
3079
3131
|
self.edit_3d_action.setEnabled(True)
|
|
@@ -3083,6 +3135,7 @@ class MainWindow(QMainWindow):
|
|
|
3083
3135
|
self.plotter.clear()
|
|
3084
3136
|
self.dragged_atom_info = None
|
|
3085
3137
|
self.statusBar().showMessage(f"Error: {error_message}")
|
|
3138
|
+
self.cleanup_button.setEnabled(True)
|
|
3086
3139
|
self.convert_button.setEnabled(True)
|
|
3087
3140
|
self.analysis_action.setEnabled(False)
|
|
3088
3141
|
self.edit_3d_action.setEnabled(False)
|
|
@@ -3498,9 +3551,12 @@ class MainWindow(QMainWindow):
|
|
|
3498
3551
|
except Exception as e:
|
|
3499
3552
|
self.statusBar().showMessage(f"Error loading from InChI: {e}")
|
|
3500
3553
|
|
|
3501
|
-
def load_mol_file(self):
|
|
3502
|
-
|
|
3503
|
-
|
|
3554
|
+
def load_mol_file(self, file_path=None):
|
|
3555
|
+
if not file_path:
|
|
3556
|
+
options = QFileDialog.Option.DontUseNativeDialog
|
|
3557
|
+
file_path, _ = QFileDialog.getOpenFileName(self, "Import MOL File", "", "Chemical Files (*.mol *.sdf);;All Files (*)", options=options)
|
|
3558
|
+
if not file_path: return
|
|
3559
|
+
|
|
3504
3560
|
if not file_path: return
|
|
3505
3561
|
try:
|
|
3506
3562
|
self.dragged_atom_info = None
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: moleditpy
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.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
|
|
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
|