# Depicting Molecular Graph Symmetry¶

## Problem¶

You want to easily identify whether there is a graph symmetry in a molecule. See examples in in Table 1.

## Ingredients¶

 OEChem TK - cheminformatics toolkit OEDepict TK - molecule depiction toolkit

## Solution¶

In DepictSymmetry function, the OEPerceiveSymmetry function is called to assign symmetry class for each atom of a given molecule. The symmetry class of each atom then can be retrieved using the OEAtomBase.GetSymmetryClass method.

After perceiving the molecule symmetry, atoms that belong to the same symmetry class are collected in a dictionary (lines 5-11). If a symmetry class only contains one atom, than it is considered unique and removed from the dictionary (lines 13-19). The atoms of the remaining symmetry classes are then highlighted with different colors (lines 24-26).

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 def DepictSymmetry(image, mol, opts): oechem.OEPerceiveSymmetry(mol) symdict = dict() for atom in mol.GetAtoms(): sym = atom.GetSymmetryClass() if sym not in symdict: symdict[sym] = oechem.OEAtomBondSet() symdict[sym].AddAtom(atom) uniquesym = [] for sym, atomset in symdict.items(): if atomset.NumAtoms() == 1: uniquesym.append(sym) for sym in uniquesym: del symdict[sym] oedepict.OEPrepareDepiction(mol) disp = oedepict.OE2DMolDisplay(mol, opts) colors = [c for c in oechem.OEGetContrastColors()] for (sym, atomset), color in zip(symdict.items(), colors): oedepict.OEAddHighlighting(disp, color, oedepict.OEHighlightStyle_BallAndStick, atomset) oedepict.OERenderMolecule(image, disp) 

symmetry2img.py

Usage:

prompt > python3 symmetry2img.py


## Discussion¶

Perceiving graph symmetry plays an important role in cheminformatics. The classification provided by the OEPerceiveSymmetry function can be used to:

API

Theory

API