rdkit.Chem.Draw package — The RDKit 2025.03.3 documentation (original) (raw)
Submodules¶
- rdkit.Chem.Draw.IPythonConsole module
- rdkit.Chem.Draw.MolDrawing module
- DrawingOptions
* DrawingOptions.atomLabelDeuteriumTritium
* DrawingOptions.atomLabelFontFace
* DrawingOptions.atomLabelFontSize
* DrawingOptions.atomLabelMinFontSize
* DrawingOptions.atomNumberOffset
* DrawingOptions.bgColor
* DrawingOptions.bondLineWidth
* DrawingOptions.colorBonds
* DrawingOptions.coordScale
* DrawingOptions.dash
* DrawingOptions.dblBondLengthFrac
* DrawingOptions.dblBondOffset
* DrawingOptions.defaultColor
* DrawingOptions.dotsPerAngstrom
* DrawingOptions.elemDict
* DrawingOptions.includeAtomNumbers
* DrawingOptions.noCarbonSymbols
* DrawingOptions.radicalSymbol
* DrawingOptions.selectColor
* DrawingOptions.showUnknownDoubleBonds
* DrawingOptions.useFraction
* DrawingOptions.wedgeDashedBonds - Font
- MolDrawing
* MolDrawing.AddMol()
* MolDrawing.scaleAndCenter()
* MolDrawing.transformPoint() - cmp()
- DrawingOptions
- rdkit.Chem.Draw.SimilarityMaps module
- rdkit.Chem.Draw.rdMolDraw2D module
- ContourAndDrawGaussians()
- ContourAndDrawGrid()
- ContourParams
* ContourParams.contourWidth
* ContourParams.coordScaleForQuantization
* ContourParams.dashNegative
* ContourParams.drawAsLines
* ContourParams.extraGridPadding
* ContourParams.fillGrid
* ContourParams.fillThreshold
* ContourParams.fillThresholdIsFraction
* ContourParams.gridResolution
* ContourParams.isovalScaleForQuantization
* ContourParams.setColourMap()
* ContourParams.setContourColour()
* ContourParams.setScale
* ContourParams.useFillThreshold - DrawMoleculeACS1996()
- IntStringMap
- MeanBondLength()
- MolDraw2D
* MolDraw2D.ClearDrawing()
* MolDraw2D.DrawArc()
* MolDraw2D.DrawArrow()
* MolDraw2D.DrawAttachmentLine()
* MolDraw2D.DrawEllipse()
* MolDraw2D.DrawLine()
* MolDraw2D.DrawMolecule()
* MolDraw2D.DrawMoleculeWithHighlights()
* MolDraw2D.DrawMolecules()
* MolDraw2D.DrawPolygon()
* MolDraw2D.DrawReaction()
* MolDraw2D.DrawRect()
* MolDraw2D.DrawString()
* MolDraw2D.DrawTriangle()
* MolDraw2D.DrawWavyLine()
* MolDraw2D.FillPolys()
* MolDraw2D.FlexiMode()
* MolDraw2D.FontSize()
* MolDraw2D.GetDrawCoords()
* MolDraw2D.GetMolSize()
* MolDraw2D.Height()
* MolDraw2D.LineWidth()
* MolDraw2D.Offset()
* MolDraw2D.SetColour()
* MolDraw2D.SetDrawOptions()
* MolDraw2D.SetFillPolys()
* MolDraw2D.SetFlexiMode()
* MolDraw2D.SetFontSize()
* MolDraw2D.SetLineWidth()
* MolDraw2D.SetOffset()
* MolDraw2D.SetScale()
* MolDraw2D.Width()
* MolDraw2D.drawOptions() - MolDraw2DCairo
* MolDraw2DCairo.FinishDrawing()
* MolDraw2DCairo.GetDrawingText()
* MolDraw2DCairo.WriteDrawingText() - MolDraw2DSVG
* MolDraw2DSVG.AddMoleculeMetadata()
* MolDraw2DSVG.FinishDrawing()
* MolDraw2DSVG.GetDrawingText()
* MolDraw2DSVG.TagAtoms() - MolDrawOptions
* MolDrawOptions.addAtomIndices
* MolDrawOptions.addBondIndices
* MolDrawOptions.addStereoAnnotation
* MolDrawOptions.additionalAtomLabelPadding
* MolDrawOptions.annotationFontScale
* MolDrawOptions.atomHighlightsAreCircles
* MolDrawOptions.atomLabelDeuteriumTritium
* MolDrawOptions.atomLabels
* MolDrawOptions.atomRegions
* MolDrawOptions.baseFontSize
* MolDrawOptions.bondLineWidth
* MolDrawOptions.bracketsAroundAtomLists
* MolDrawOptions.centreMoleculesBeforeDrawing
* MolDrawOptions.circleAtoms
* MolDrawOptions.clearBackground
* MolDrawOptions.comicMode
* MolDrawOptions.continuousHighlight
* MolDrawOptions.drawMolsSameScale
* MolDrawOptions.dummiesAreAttachments
* MolDrawOptions.dummyIsotopeLabels
* MolDrawOptions.explicitMethyl
* MolDrawOptions.fillHighlights
* MolDrawOptions.fixedBondLength
* MolDrawOptions.fixedFontSize
* MolDrawOptions.fixedScale
* MolDrawOptions.flagCloseContactsDist
* MolDrawOptions.fontFile
* MolDrawOptions.getAnnotationColour()
* MolDrawOptions.getAtomNoteColour()
* MolDrawOptions.getBackgroundColour()
* MolDrawOptions.getBondNoteColour()
* MolDrawOptions.getHighlightColour()
* MolDrawOptions.getLegendColour()
* MolDrawOptions.getQueryColour()
* MolDrawOptions.getSymbolColour()
* MolDrawOptions.getVariableAttachmentColour()
* MolDrawOptions.highlightBondWidthMultiplier
* MolDrawOptions.highlightRadius
* MolDrawOptions.includeAtomTags
* MolDrawOptions.includeChiralFlagLabel
* MolDrawOptions.includeMetadata
* MolDrawOptions.includeRadicals
* MolDrawOptions.isotopeLabels
* MolDrawOptions.legendFontSize
* MolDrawOptions.legendFraction
* MolDrawOptions.maxFontSize
* MolDrawOptions.minFontSize
* MolDrawOptions.multiColourHighlightStyle
* MolDrawOptions.multipleBondOffset
* MolDrawOptions.noAtomLabels
* MolDrawOptions.padding
* MolDrawOptions.prepareMolsBeforeDrawing
* MolDrawOptions.reagentPadding
* MolDrawOptions.rotate
* MolDrawOptions.scaleBondWidth
* MolDrawOptions.scaleHighlightBondWidth
* MolDrawOptions.scalingFactor
* MolDrawOptions.setAnnotationColour()
* MolDrawOptions.setAtomNoteColour()
* MolDrawOptions.setAtomPalette()
* MolDrawOptions.setBackgroundColour()
* MolDrawOptions.setBondNoteColour()
* MolDrawOptions.setHighlightColour()
* MolDrawOptions.setLegendColour()
* MolDrawOptions.setQueryColour()
* MolDrawOptions.setSymbolColour()
* MolDrawOptions.setVariableAttachmentColour()
* MolDrawOptions.simplifiedStereoGroupLabel
* MolDrawOptions.singleColourWedgeBonds
* MolDrawOptions.splitBonds
* MolDrawOptions.standardColoursForHighlightedAtoms
* MolDrawOptions.unspecifiedStereoIsUnknown
* MolDrawOptions.updateAtomPalette()
* MolDrawOptions.useAvalonAtomPalette()
* MolDrawOptions.useBWAtomPalette()
* MolDrawOptions.useCDKAtomPalette()
* MolDrawOptions.useComplexQueryAtomSymbols
* MolDrawOptions.useDefaultAtomPalette()
* MolDrawOptions.useMolBlockWedging
* MolDrawOptions.variableAtomRadius
* MolDrawOptions.variableBondWidthMultiplier - MolToACS1996SVG()
- MolToSVG()
- MultiColourHighlightStyle
* MultiColourHighlightStyle.CircleAndLine
* MultiColourHighlightStyle.Lasso
* MultiColourHighlightStyle.names
* MultiColourHighlightStyle.values - PrepareAndDrawMolecule()
- PrepareMolForDrawing()
- SetACS1996Mode()
- SetDarkMode()
- SetMonochromeMode()
- UpdateDrawerParamsFromJSON()
- UpdateMolDrawOptionsFromJSON()
- map_indexing_suite_IntStringMap_entry
* map_indexing_suite_IntStringMap_entry.data()
* map_indexing_suite_IntStringMap_entry.key()
- rdkit.Chem.Draw.rdMolDraw2DQt module
Module contents¶
rdkit.Chem.Draw.DebugDraw(mol, size=(350, 350), drawer=None, asSVG=True, useBW=True, includeHLabels=True, addAtomIndices=True, addBondIndices=False)¶
rdkit.Chem.Draw.DrawMorganBit(mol, bitId, bitInfo, whichExample=0, **kwargs)¶
rdkit.Chem.Draw.DrawMorganBits(tpls, **kwargs)¶
rdkit.Chem.Draw.DrawMorganEnv(mol, atomId, radius, molSize=(150, 150), baseRad=0.3, useSVG=True, aromaticColor=(0.9, 0.9, 0.2), ringColor=(0.8, 0.8, 0.8), centerColor=(0.6, 0.6, 0.9), extraColor=(0.9, 0.9, 0.9), drawOptions=None, **kwargs)¶
rdkit.Chem.Draw.DrawMorganEnvs(envs, molsPerRow=3, subImgSize=(150, 150), baseRad=0.3, useSVG=True, aromaticColor=(0.9, 0.9, 0.2), ringColor=(0.8, 0.8, 0.8), centerColor=(0.6, 0.6, 0.9), extraColor=(0.9, 0.9, 0.9), legends=None, drawOptions=None, **kwargs)¶
rdkit.Chem.Draw.DrawRDKitBit(mol, bitId, bitInfo, whichExample=0, **kwargs)¶
rdkit.Chem.Draw.DrawRDKitBits(tpls, **kwargs)¶
rdkit.Chem.Draw.DrawRDKitEnv(mol, bondPath, molSize=(150, 150), baseRad=0.3, useSVG=True, aromaticColor=(0.9, 0.9, 0.2), extraColor=(0.9, 0.9, 0.9), nonAromaticColor=None, drawOptions=None, **kwargs)¶
rdkit.Chem.Draw.DrawRDKitEnvs(envs, molsPerRow=3, subImgSize=(150, 150), baseRad=0.3, useSVG=True, aromaticColor=(0.9, 0.9, 0.2), extraColor=(0.9, 0.9, 0.9), nonAromaticColor=None, legends=None, drawOptions=None, **kwargs)¶
class rdkit.Chem.Draw.FingerprintEnv(submol, highlightAtoms, atomColors, highlightBonds, bondColors, highlightRadii)¶
Bases: tuple
Create new instance of FingerprintEnv(submol, highlightAtoms, atomColors, highlightBonds, bondColors, highlightRadii)
atomColors¶
Alias for field number 2
bondColors¶
Alias for field number 4
highlightAtoms¶
Alias for field number 1
highlightBonds¶
Alias for field number 3
highlightRadii¶
Alias for field number 5
submol¶
Alias for field number 0
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, **kwargs)¶
Returns a PIL image containing a drawing of the molecule
Parameters:
- 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 [])
- 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.MolsMatrixToGridImage(molsMatrix, subImgSize=(200, 200), legendsMatrix=None, highlightAtomListsMatrix=None, highlightBondListsMatrix=None, useSVG=False, returnPNG=False, **kwargs)¶
Creates a mol grid image from a nested data structure (where each data substructure represents a row), padding rows as needed so all rows are the length of the longest row
ARGUMENTS:
- molsMatrix: A two-deep nested data structure of RDKit molecules to draw, iterable of iterables (for example list of lists) of RDKit molecules
- subImgSize: The size of a cell in the drawing; passed through to MolsToGridImage (default (200, 200))
- legendsMatrix: A two-deep nested data structure of strings to label molecules with, iterable of iterables (for example list of lists) of strings (default None)
- highlightAtomListsMatrix: A three-deep nested data structure of integers of atoms to highlight, iterable of iterables (for example list of lists) of integers (default None)
- highlightBondListsMatrix: A three-deep nested data structure of integers of bonds to highlight, iterable of iterables (for example list of lists) of integers (default None)
- useSVG: Whether to return an SVG (if true) or PNG (if false); passed through to MolsToGridImage (default false)
- returnPNG: Whether to return PNG data (if true) or a PIL object for a PNG image file (if false); has no effect if useSVG is true; passed through to MolsToGridImage (default false)
- kwargs: Any other keyword arguments are passed to MolsToGridImage
NOTES:
To include a blank cell in the middle of a row, supply None for that entry in molsMatrix. You do not need to do that for empty cells at the end of a row; this function will automatically pad rows so that all rows are the same length.
This function is useful when each row has some meaning, for example the generation in a mass spectrometry fragmentation tree–refer to example at https://en.wikipedia.org/wiki/Fragmentation_(mass_spectrometry). If you want to display a set molecules where each row does not have any specific meaning, use MolsToGridImage instead.
This function nests data structures one additional level beyond the analogous function MolsToGridImage (in which the molecules and legends are non-nested lists, and the highlight parameters are two-deep nested lists)
RETURNS:
A grid of molecular images in one of these formats:
- useSVG=False and returnPNG=False (default): A PIL object for a PNG image file
- useSVG=False and returnPNG=True: PNG data
- useSVG=True: An SVG string
EXAMPLES:
from rdkit import Chem from rdkit.Chem.Draw import MolsMatrixToGridImage, rdMolDraw2D FCl = Chem.MolFromSmiles(“FCl”) molsMatrix = [[FCl, FCl], [FCl, None, FCl]]
# Minimal example: Only molsMatrix is supplied, # result will be a drawing containing (where each row contains molecules): # F-Cl F-Cl # F-Cl F-Cl img = MolsMatrixToGridImage(molsMatrix) img.save(“MolsMatrixToGridImageMinimal.png”) # img is a PIL object for a PNG image file like: # <PIL.PngImagePlugin.PngImageFile image mode=RGB size=600x200 at 0x1648CC390> # Drawing will be saved as PNG file MolsMatrixToGridImageMinimal.png
# Exhaustive example: All parameters are supplied, # result will be a drawing containing (where each row of molecules is followed by a row of legends): # 1 F-Cl 0 1 F-Cl 0 # no highlighting bond highlighted # 1 F-Cl 0 1 F-Cl 0 # sodium highlighted chloride and bond highlighted legendsMatrix = [[“no highlighting”, “bond highlighted”], [“F highlighted”, “”, “Cl and bond highlighted”]] highlightAtomListsMatrix = [[[],[]], [[0], None, [1]]] highlightBondListsMatrix = [[[],[0]], [[], None, [0]]]
dopts = rdMolDraw2D.MolDrawOptions() dopts.addAtomIndices = True
img_binary = MolsMatrixToGridImage(molsMatrix=molsMatrix, subImgSize=(300, 400), legendsMatrix=legendsMatrix, highlightAtomListsMatrix=highlightAtomListsMatrix, highlightBondListsMatrix=highlightBondListsMatrix, useSVG=False, returnPNG=True, drawOptions=dopts) print(img_binary[:20]) # Prints a binary string: b’x89PNGrnx1anx00x00x00rIHDRx00x00x03x84’
rdkit.Chem.Draw.MolsToGridImage(mols, molsPerRow=3, subImgSize=(200, 200), legends=None, highlightAtomLists=None, highlightBondLists=None, useSVG=False, returnPNG=False, **kwargs)¶
rdkit.Chem.Draw.MolsToImage(mols, subImgSize=(200, 200), legends=None, **kwargs)¶
rdkit.Chem.Draw.ReactionToImage(rxn, subImgSize=(200, 200), useSVG=False, drawOptions=None, returnPNG=False, **kwargs)¶
rdkit.Chem.Draw.SetComicMode(opts)¶
rdkit.Chem.Draw.ShowMol(mol, size=(300, 300), kekulize=True, wedgeBonds=True, title='RDKit Molecule', stayInFront=True, **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)¶
rdkit.Chem.Draw.shouldKekulize(mol, kekulize)¶