rdkit.Chem.Draw package¶
Submodules¶
- rdkit.Chem.Draw.IPythonConsole module
- rdkit.Chem.Draw.MolDrawing module
DrawingOptionsDrawingOptions.atomLabelDeuteriumTritiumDrawingOptions.atomLabelFontFaceDrawingOptions.atomLabelFontSizeDrawingOptions.atomLabelMinFontSizeDrawingOptions.atomNumberOffsetDrawingOptions.bgColorDrawingOptions.bondLineWidthDrawingOptions.colorBondsDrawingOptions.coordScaleDrawingOptions.dashDrawingOptions.dblBondLengthFracDrawingOptions.dblBondOffsetDrawingOptions.defaultColorDrawingOptions.dotsPerAngstromDrawingOptions.elemDictDrawingOptions.includeAtomNumbersDrawingOptions.noCarbonSymbolsDrawingOptions.radicalSymbolDrawingOptions.selectColorDrawingOptions.showUnknownDoubleBondsDrawingOptions.useFractionDrawingOptions.wedgeDashedBonds
FontMolDrawingcmp()
- rdkit.Chem.Draw.SimilarityMaps module
GetAPFingerprint()GetAtomicWeightsForFingerprint()GetAtomicWeightsForFingerprintGenerator()GetAtomicWeightsForModel()GetMorganFingerprint()GetRDKFingerprint()GetSimilarityMapForFingerprint()GetSimilarityMapForFingerprintGenerator()GetSimilarityMapForModel()GetSimilarityMapFromWeights()GetStandardizedWeights()GetTTFingerprint()
- rdkit.Chem.Draw.rdMolDraw2D module
ContourAndDrawGaussians()ContourAndDrawGrid()ContourParamsContourParams.colourMapContourParams.contourColourContourParams.contourWidthContourParams.coordScaleForQuantizationContourParams.dashNegativeContourParams.drawAsLinesContourParams.extraGridPaddingContourParams.fillGridContourParams.fillThresholdContourParams.fillThresholdIsFractionContourParams.gridResolutionContourParams.isovalScaleForQuantizationContourParams.setColourMap()ContourParams.setContourColour()ContourParams.setScaleContourParams.useFillThreshold
DrawElementDrawMoleculeACS1996()IntStringMapMeanBondLength()MolDraw2DMolDraw2D.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()
MolDraw2DCairoMolDraw2DSVGMolDrawOptionsMolDrawOptions.addAtomIndicesMolDrawOptions.addBondIndicesMolDrawOptions.addStereoAnnotationMolDrawOptions.additionalAtomLabelPaddingMolDrawOptions.annotationColourMolDrawOptions.annotationFontScaleMolDrawOptions.atomHighlightsAreCirclesMolDrawOptions.atomLabelDeuteriumTritiumMolDrawOptions.atomLabelsMolDrawOptions.atomNoteColourMolDrawOptions.atomRegionsMolDrawOptions.backgroundColourMolDrawOptions.baseFontSizeMolDrawOptions.bondLineWidthMolDrawOptions.bondNoteColourMolDrawOptions.bracketsAroundAtomListsMolDrawOptions.centreMoleculesBeforeDrawingMolDrawOptions.circleAtomsMolDrawOptions.clearBackgroundMolDrawOptions.comicModeMolDrawOptions.continuousHighlightMolDrawOptions.drawMolsSameScaleMolDrawOptions.drawingExtentsIncludeMolDrawOptions.dummiesAreAttachmentsMolDrawOptions.dummyIsotopeLabelsMolDrawOptions.explicitMethylMolDrawOptions.fillHighlightsMolDrawOptions.fixedBondLengthMolDrawOptions.fixedFontSizeMolDrawOptions.fixedScaleMolDrawOptions.flagCloseContactsDistMolDrawOptions.fontFileMolDrawOptions.getAnnotationColour()MolDrawOptions.getAtomNoteColour()MolDrawOptions.getAtomPalette()MolDrawOptions.getBackgroundColour()MolDrawOptions.getBondNoteColour()MolDrawOptions.getHighlightColour()MolDrawOptions.getLegendColour()MolDrawOptions.getQueryColour()MolDrawOptions.getSymbolColour()MolDrawOptions.getVariableAttachmentColour()MolDrawOptions.highlightBondWidthMultiplierMolDrawOptions.highlightColourMolDrawOptions.highlightRadiusMolDrawOptions.includeAtomTagsMolDrawOptions.includeChiralFlagLabelMolDrawOptions.includeMetadataMolDrawOptions.includeRadicalsMolDrawOptions.isotopeLabelsMolDrawOptions.legendColourMolDrawOptions.legendFontSizeMolDrawOptions.legendFractionMolDrawOptions.maxFontSizeMolDrawOptions.minFontSizeMolDrawOptions.multiColourHighlightStyleMolDrawOptions.multipleBondOffsetMolDrawOptions.noAtomLabelsMolDrawOptions.paddingMolDrawOptions.prepareMolsBeforeDrawingMolDrawOptions.queryColourMolDrawOptions.reagentPaddingMolDrawOptions.rotateMolDrawOptions.scaleBondWidthMolDrawOptions.scaleHighlightBondWidthMolDrawOptions.scalingFactorMolDrawOptions.setAnnotationColour()MolDrawOptions.setAtomNoteColour()MolDrawOptions.setAtomPalette()MolDrawOptions.setBackgroundColour()MolDrawOptions.setBondNoteColour()MolDrawOptions.setHighlightColour()MolDrawOptions.setLegendColour()MolDrawOptions.setQueryColour()MolDrawOptions.setSymbolColour()MolDrawOptions.setVariableAttachmentColour()MolDrawOptions.showAllCIPCodesMolDrawOptions.simplifiedStereoGroupLabelMolDrawOptions.singleColourWedgeBondsMolDrawOptions.splitBondsMolDrawOptions.standardColoursForHighlightedAtomsMolDrawOptions.symbolColourMolDrawOptions.unspecifiedStereoIsUnknownMolDrawOptions.updateAtomPalette()MolDrawOptions.useAvalonAtomPalette()MolDrawOptions.useBWAtomPalette()MolDrawOptions.useCDKAtomPalette()MolDrawOptions.useComplexQueryAtomSymbolsMolDrawOptions.useDefaultAtomPalette()MolDrawOptions.useMolBlockWedgingMolDrawOptions.variableAtomRadiusMolDrawOptions.variableAttachmentColourMolDrawOptions.variableBondWidthMultiplier
MolToACS1996SVG()MolToSVG()MultiColourHighlightStylePrepareAndDrawMolecule()PrepareMolForDrawing()SetACS1996Mode()SetDarkMode()SetMonochromeMode()UpdateDrawerParamsFromJSON()UpdateMolDrawOptionsFromJSON()map_indexing_suite_IntStringMap_entry
- 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.DrawMolWithMatches(mol, matches, molSize=(350, 300), qry=None, label='', options=<rdkit.Chem.Draw.rdMolDraw2D.MolDrawOptions object>, colors=None, doPNG=True, kekulize=True, confId=-1)¶
Draws a molecule with a set of substructure matches highlighted
- Parameters:
mol (-) – The molecule to draw
matches (-) – A list/tuple of lists/tuples of atom indices, each inner tuple representing a substructure match
molSize (-) – The size of the image to produce (default (350, 300))
qry (-) – The query molecule used to generate the matches (default None) If supplied, bonds between matched atoms will also be highlighted
label (-) – A string to place under the molecule (default ‘’)
options (-) – A MolDrawOptions object to control the drawing style (default MolDrawOptions())
colors (-) – A list/tuple of colors to use for highlighting the different matches (default None, in which case the default highlight color is used for all matches)
doPNG (-) – Whether to return PNG (if true) or SVG (if false) (default true)
kekulize (-) – Whether to kekulize the molecule before drawing (default true)
confId (-) – The conformer ID to use when drawing (default -1, the default conformer)
- Returns:
A string containing the image in the requested format (PNG or SVG)
- 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:
tupleCreate 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)¶