环境

  • Python 3.9
  • RDKit 2023.09.1
from rdkit import Chem
from rdkit.Chem import rdDepictor
from rdkit.Chem import Draw
from rdkit.Chem.Draw import IPythonConsole

IPythonConsole.ipython_useSVG=True
%matplotlib inline
import rdkit
print(rdkit.__version__)
mol = Chem.MolFromSmiles("NC(CCC1CCC2C(C1)C1CCN2NN1)CC(=O)CCC1=CCCC2CCCCC2CCCCC2CCCC(CCCCCCC1)C2")
mol_with_templates = Chem.Mol(mol)

# use rdkit native coordinate generation
rdDepictor.SetPreferCoordGen(False)
rdDepictor.Compute2DCoords(mol)

# the first time you call this, 
rdDepictor.Compute2DCoords(mol_with_templates, useRingTemplates=True)

Draw.MolsToGridImage([mol, mol_with_templates], subImgSize=(400,400))
11-02 16:54