rdkit.Chem.Draw package

Module contents

rdkit.Chem.Draw.MolToFile(mol, fileName, size=(300, 300), kekulize=True, wedgeBonds=True, imageType=None, fitImage=False, options=None, **kwargs)

Generates a drawing of a molecule and writes it to a file

rdkit.Chem.Draw.MolToImage(mol, size=(300, 300), kekulize=True, wedgeBonds=True, fitImage=False, options=None, canvas=None, **kwargs)

Returns a PIL image containing a drawing of the molecule

ARGUMENTS:

  • kekulize: run kekulization routine on input mol (default True)
  • size: final image size, in pixel (default (300,300))
  • wedgeBonds: draw wedge (stereo) bonds (default True)
  • highlightAtoms: list of atoms to highlight (default [])
  • highlightMap: dictionary of (atom, color) pairs (default None)
  • highlightBonds: list of bonds to highlight (default [])
  • highlightColor: RGB color as tuple (default [1, 0, 0])

NOTE:

use ‘matplotlib.colors.to_rgb()’ to convert string and HTML color codes into the RGB tuple representation, eg.

from matplotlib.colors import ColorConverter img = Draw.MolToImage(m, highlightAtoms=[1,2], highlightColor=ColorConverter().to_rgb(‘aqua’)) img.save(“molecule.png”)

RETURNS:

a PIL Image object
rdkit.Chem.Draw.MolToImageFile(mol, filename, size=(300, 300), kekulize=True, wedgeBonds=True, **kwargs)

DEPRECATED: please use MolToFile instead

rdkit.Chem.Draw.MolToMPL(mol, size=(300, 300), kekulize=True, wedgeBonds=True, imageType=None, fitImage=False, options=None, **kwargs)

Generates a drawing of a molecule on a matplotlib canvas

rdkit.Chem.Draw.MolToQPixmap(mol, size=(300, 300), kekulize=True, wedgeBonds=True, fitImage=False, options=None, **kwargs)

Generates a drawing of a molecule on a Qt QPixmap

rdkit.Chem.Draw.MolsToGridImage(mols, molsPerRow=3, subImgSize=(200, 200), legends=None, highlightAtomLists=None, useSVG=False, **kwargs)
rdkit.Chem.Draw.MolsToImage(mols, subImgSize=(200, 200), legends=None, **kwargs)
rdkit.Chem.Draw.ReactionToImage(rxn, subImgSize=(200, 200), **kwargs)
rdkit.Chem.Draw.ShowMol(mol, size=(300, 300), kekulize=True, wedgeBonds=True, title='RDKit Molecule', **kwargs)

Generates a picture of a molecule and displays it in a Tkinter window

rdkit.Chem.Draw.calcAtomGaussians(mol, a=0.03, step=0.02, weights=None)

useful things to do with these: fig.axes[0].imshow(z,cmap=cm.gray,interpolation=’bilinear’,origin=’lower’,extent=(0,1,0,1)) fig.axes[0].contour(x,y,z,20,colors=’k’)

fig=Draw.MolToMPL(m); contribs=Crippen.rdMolDescriptors._CalcCrippenContribs(m) logps,mrs=zip(*contribs) x,y,z=Draw.calcAtomGaussians(m,0.03,step=0.01,weights=logps) fig.axes[0].imshow(z,cmap=cm.jet,interpolation=’bilinear’,origin=’lower’,extent=(0,1,0,1)) fig.axes[0].contour(x,y,z,20,colors=’k’,alpha=0.5) fig.savefig(‘coumlogps.colored.png’,bbox_inches=’tight’)