Skip to content
HiroYokoyama edited this page Dec 6, 2025 · 34 revisions

MoleditPy — A Python-based molecular editing software

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.

Author: HiroYokoyama
License: GPL-3.0
Repository: https://github.com/HiroYokoyama/python_molecular_editor

Overview

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.

Key Features

1. 2D Drawing and Editing

  • 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.
  • 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.
  • Charge/Radical Operations: Easily set formal charges and radicals by clicking on an atom or using keyboard shortcuts (+/-/.).
  • Selection from Periodic Table: Select any element from a periodic table dialog.
  • Enhanced Selection Tools:
    • Supports Cut (Ctrl+X), Copy (Ctrl+C), and Paste (Ctrl+V) for clipboard operations on molecular fragments.
    • Space: Toggles select mode / Selects all in select mode.

2. Keyboard Shortcuts

Key Action Notes
1/2/3 Change bond order Single/Double/Triple bond
W/D Change to stereochemical bond Wedge / Dash bond
Delete / Backspace Delete item(s) Deletes selected or hovered items
. Toggle radical 0 → 1 → 2 → 0
+/- Increase/Decrease charge Change formal charge
C, N, O, etc. Change atom symbol Applies to atom under cursor or selection
4 Place benzene ring One-shot placement on atom/bond under cursor
Ctrl+J Perform 2D optimization
Ctrl+K Perform 3D conversion
Ctrl+L Perform 3D optimization

3. 2D Structure Optimization

  • Performs automatic layout using RDKit's Compute2DCoords (Optimize 2D).
  • Implements logic to detect and automatically separate and resolve overlapping groups of atoms (such as non-bonded fragments).

4. High-Quality 3D Visualization and Analysis

  • 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.
  • Interactive Display: Provides interactive 3D visualization (Ball & Stick / CPK styles) powered by PyVista / pyvistaqt.
  • 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.
  • Chiral Label Display: After 3D conversion, automatically assigns R/S labels to chiral centers and displays them in the 3D view.
  • Molecule Analysis Window: A dedicated window that lists key molecular properties based on RDKit, such as molecular formula, molecular weight, SMILES, LogP, and TPSA.

5. File I/O

  • Project File (.pmeprj): Allows you to completely save and load the editing state, including 2D drawing data, 3D structure, charges, radicals, and chiral label states.
  • Save 2D structures in MOL format.
  • Save 3D structures in MOL / XYZ formats. These formats are widely supported as inputs for many DFT calculation software packages.
  • Supports importing from MOL/SDF files.
  • Supports importing from a SMILES/InChI string.
  • Supports exporting 2D and 3D displays as PNG images.
  • Supports exporting to STL/OBJ files for 3D printing.

Wiki Pages

Clone this wiki locally