Skip to content

Start

Tutorials · 简体中文

Reconstruct the Fe–Pd–Fe complex 338-S from XYZ coordinates with Python and draw its coordination bonds with rdkit-dof.

1. Prepare the input

Download 338-S.xyz to your working directory. Open a terminal there and install MolGR and rdkit-dof.

pip install molgr rdkit-dof

If your platform requires a source build, follow the build guide.

2. Run the reconstruction

Save the code below as reconstruct.py in the same directory. The XYZ comment gives a total charge of 0 and a spin multiplicity of 1. The coordinates are in ångströms.

from pathlib import Path

from rdkit import Chem
from rdkit_dof import MolToDofImage
from molgr.interface import xyz_to_rdmol

xyz = Path("338-S.xyz").read_text(encoding="utf-8")
mol = xyz_to_rdmol(xyz, total_charge=0, spin_multiplicity=1)
dative = sum(b.GetBondType() == Chem.BondType.DATIVE for b in mol.GetBonds())
print(mol.GetNumAtoms(), mol.GetNumBonds(), dative, Chem.GetFormalCharge(mol))
for atom in mol.GetAtoms():
    if atom.GetSymbol() in {"Fe", "Pd"}:
        print(atom.GetSymbol(), atom.GetFormalCharge(), atom.GetDegree())

svg = MolToDofImage(mol, size=(720, 480), return_image=False)
Path("338-S.svg").write_text(svg, encoding="utf-8")

Run the script from the terminal.

python reconstruct.py

Expected output

67 89 24 0
Fe 2 10
Pd 2 4
Fe 2 10

3. View the coordination bonds

Open the generated 338-S.svg in a browser. rdkit-dof draws the reconstructed molecule using its 3D coordinates, including the explicit hydrogen atoms.

rdkit-dof rendering of the reconstructed 338-S complex with two Fe centers and one Pd center.

Look for the four bonds around Pd. Each Fe contacts ten carbon atoms across two five-membered rings. These contacts account for the 24 dative bonds counted above.

Continue with batch processing, or look up API parameters. The reconstruction model explains charge, multiplicity, and chemical representations.