rdkit.Chem.Draw.rdMolDraw2D module¶
Module containing a C++ implementation of 2D molecule drawing
- class rdkit.Chem.Draw.rdMolDraw2D.ContourParams(self)¶
Bases:
objectParameters for drawing contours
- property colourMap¶
the color map to use when filling the grid
- property contourColour¶
the color to use for drawing the contours
- property contourWidth¶
line width of the contours
- property coordScaleForQuantization¶
scaling factor used to convert coordinates to ints when forming the continuous lines
- property dashNegative¶
use a dashed line for negative contours
- property drawAsLines¶
draw the contours as continuous lines isntead of line segments
- property extraGridPadding¶
extra space (in molecule coords) around the grid
- property fillGrid¶
colors the grid in addition to drawing contours
- property fillThreshold¶
magnitude threshold to determine if a grid point is filled
- property fillThresholdIsFraction¶
if true, fillThreshold is a fraction of the range of the data
- property gridResolution¶
set the resolution of the grid
- property isovalScaleForQuantization¶
scaling factor used to convert isovalues to ints when forming the continuous lines
- property setScale¶
set the scale of the drawing object (useful if you draw the grid/contours first)
- property useFillThreshold¶
use a magnitude threshold to determine if a grid point is filled
- class rdkit.Chem.Draw.rdMolDraw2D.DrawElement(*values)¶
Bases:
IntEnum- ALL = 2147483647¶
- ANNOTATIONS = 16¶
- ATOMLABELS = 4¶
- BONDS = 2¶
- HIGHLIGHTS = 8¶
- NONE = 0¶
- POSTSHAPES = 64¶
- PRESHAPES = 1¶
- RADICALS = 32¶
- class rdkit.Chem.Draw.rdMolDraw2D.IntStringMap¶
Bases:
object
- class rdkit.Chem.Draw.rdMolDraw2D.LegendPosition(*values)¶
Bases:
Enum- Bottom = 0¶
- Left = 2¶
- Right = 3¶
- Top = 1¶
- class rdkit.Chem.Draw.rdMolDraw2D.MolDraw2D¶
Bases:
objectDrawer abstract base class
- DrawArc(self, center: rdkit.Geometry.rdGeometry.Point2D, radius: float, angle1: float, angle2: float, rawCoords: bool = False) None¶
draws an arc with the current drawing style. The coordinates are in the molecule frame unless rawCoords is true, in which case the coordinates are in pixels. The angles are in degrees; angle2 should be > angle1.
- DrawArrow(self, cds1: rdkit.Geometry.rdGeometry.Point2D, cds2: rdkit.Geometry.rdGeometry.Point2D, asPolygon: bool = False, frac: float = 0.05, angle: float = 0.5235987755982988, color: object | None = None, rawCoords: bool = False) None¶
draws an arrow with the current drawing style. The coordinates are in the molecule frame unless rawCoords is true, in which case the coordinates are in pixels. If asPolygon is true the head of the arrow will be drawn as a triangle, otherwise two lines are used. The fraction of the arrow length to use for the head is given by frac. The angle of the arrowhead (the angle between the main line and each arrowhead line) is given by angle. The color is a tuple of 3 floats (0-1) in red, green, blue (RGB) order.
- DrawAttachmentLine(self, cds1: rdkit.Geometry.rdGeometry.Point2D, cds2: rdkit.Geometry.rdGeometry.Point2D, color: tuple, len: float = 1.0, nSegments: int = 16, rawCoords: bool = False) None¶
draw a line indicating the presence of an attachment point (normally a squiggle line perpendicular to a bond). The coordinates are in the molecule frame unless rawCoords is true, in which case the coordinates are in pixels.
- DrawEllipse(self, cds1: rdkit.Geometry.rdGeometry.Point2D, cds2: rdkit.Geometry.rdGeometry.Point2D, rawCoords: bool = False) None¶
draws a triangle with the current drawing style in the rectangle defined by the two points. The coordinates are in the molecule frame unless rawCoords is true, in which case the coordinates are in pixels.
- DrawLine(self, cds1: rdkit.Geometry.rdGeometry.Point2D, cds2: rdkit.Geometry.rdGeometry.Point2D, rawCoords: bool = False) None¶
draws a line with the current drawing style. The coordinates are in the molecule frame unless rawCoords is true, in which case the coordinates are in pixels.
- DrawMolecule(self, mol: rdkit.Chem.rdchem.Mol, highlightAtoms: object | None = None, highlightAtomColors: object | None = None, highlightAtomRadii: dict | None = None, confId: int = -1, legend: str = '') None¶
- DrawMolecule(self, mol: rdkit.Chem.rdchem.Mol, highlightAtoms: object, highlightBonds: object, highlightAtomColors: object | None = None, highlightBondColors: object | None = None, highlightAtomRadii: dict | None = None, confId: int = -1, legend: str = '') None
renders a molecule
- DrawMoleculeWithHighlights(self, mol: rdkit.Chem.rdchem.Mol, legend: str, highlight_atom_map: object, highlight_bond_map: object, highlight_radii: dict | None, highlight_linewidth_multipliers: object, confId: int = -1) None¶
renders a molecule with multiple highlight colours
- DrawMolecules(self, mols: object, highlightAtoms: object | None = None, highlightBonds: object | None = None, highlightAtomColors: object | None = None, highlightBondColors: object | None = None, highlightAtomRadii: object | None = None, confIds: object | None = None, legends: object | None = None) None¶
renders multiple molecules
- DrawPolygon(self, cds: object, rawCoords: bool = False) None¶
draws a polygon with the current drawing style. The coordinates are in the molecule frame unless rawCoords is true, in which case the coordinates are in pixels.
- DrawReaction(self, rxn: rdkit.Chem.rdChemReactions.ChemicalReaction, highlightByReactant: bool = False, highlightColorsReactants: object | None = None, confIds: object | None = None) None¶
renders a reaction
- DrawRect(self, cds1: rdkit.Geometry.rdGeometry.Point2D, cds2: rdkit.Geometry.rdGeometry.Point2D, rawCoords: bool = False) None¶
draws a rectangle with the current drawing style in the rectangle defined by the two points. The coordinates are in the molecule frame unless rawCoords is true, in which case the coordinates are in pixels.
- DrawString(self, string: str, pos: rdkit.Geometry.rdGeometry.Point2D, rawCoords: bool = False) None¶
- DrawString(self, string: str, pos: rdkit.Geometry.rdGeometry.Point2D, align: int, rawCoords: bool = False) None
Overloaded function.
DrawString(self, string: str, pos: rdkit.Geometry.rdGeometry.Point2D, rawCoords: bool = False) -> None
add text to the canvas. The coordinates are in the molecule frame unless rawCoords is true, in which case the coordinates are in pixels.
DrawString(self, string: str, pos: rdkit.Geometry.rdGeometry.Point2D, align: int, rawCoords: bool = False) -> None
add aligned text to the canvas. The align argument can be 0 (=MIDDLE), 1 (=START), or 2 (=END). The coordinates are in the molecule frame unless rawCoords is true, in which case the coordinates are in pixels.
- DrawTriangle(self, cds1: rdkit.Geometry.rdGeometry.Point2D, cds2: rdkit.Geometry.rdGeometry.Point2D, cds3: rdkit.Geometry.rdGeometry.Point2D, rawCoords: bool = False) None¶
draws a triangle with the current drawing style. The coordinates are in the molecule frame unless rawCoords is true, in which case the coordinates are in pixels.
- DrawWavyLine(self, cds1: rdkit.Geometry.rdGeometry.Point2D, cds2: rdkit.Geometry.rdGeometry.Point2D, color1: tuple, color2: tuple, nSegments: int = 16, vertOffset: float = 0.05, rawCoords: bool = False) None¶
draw a line indicating the presence of an attachment point (normally a squiggle line perpendicular to a bond). The coordinates are in the molecule frame unless rawCoords is true, in which case the coordinates are in pixels.
- FillPolys(self) bool¶
returns whether or not polygons are being filled
- FlexiMode(self) bool¶
returns whether or not FlexiMode is being used
- FontSize(self) float¶
get the default font size. The units are, roughly, pixels.
- GetDrawCoords(self, point: rdkit.Geometry.rdGeometry.Point2D) rdkit.Geometry.rdGeometry.Point2D¶
- GetDrawCoords(self, atomIndex: int) rdkit.Geometry.rdGeometry.Point2D
Overloaded function.
GetDrawCoords(self, point: rdkit.Geometry.rdGeometry.Point2D) -> rdkit.Geometry.rdGeometry.Point2D
get the coordinates in drawing space for a particular point in molecule space
GetDrawCoords(self, atomIndex: int) -> rdkit.Geometry.rdGeometry.Point2D
get the coordinates in drawing space for a particular atom
- GetMolSize(self, mol: rdkit.Chem.rdchem.Mol, highlightAtoms: object | None = None, highlightBonds: object | None = None, highlightAtomColors: object | None = None, highlightBondColors: object | None = None, highlightAtomRadii: dict | None = None, confId: int = -1, legend: str = '') tuple¶
returns the width and height required to draw a molecule at the current size
- Height(self) int¶
get the height of the drawing canvas
- LineWidth(self) float¶
returns the line width being used
- Offset(self) rdkit.Geometry.rdGeometry.Point2D¶
returns the offset (in drawing coordinates) for the drawing
- SetDrawOptions(self, opts: rdkit.Chem.Draw.rdMolDraw2D.MolDrawOptions) None¶
Copies the drawing options passed in over our drawing options
- SetFlexiMode(self, mode: bool) None¶
when FlexiMode is set, molecules will always been drawn with the default values for bond length, font size, etc.
- SetFontSize(self, new_size: float) None¶
change the default font size. The units are, roughly, pixels.
- SetScale(self, width: int, height: int, minv: rdkit.Geometry.rdGeometry.Point2D, maxv: rdkit.Geometry.rdGeometry.Point2D, mol: object | None = None) None¶
uses the values provided to set the drawing scaling
- Width(self) int¶
get the width of the drawing canvas
- drawOptions(self) rdkit.Chem.Draw.rdMolDraw2D.MolDrawOptions¶
Returns a modifiable version of the current drawing options
- class rdkit.Chem.Draw.rdMolDraw2D.MolDraw2DCairo(self, width: int, height: int, panelWidth: int = -1, panelHeight: int = -1, noFreetype: bool = False)¶
Bases:
MolDraw2DCairo molecule drawer
- GetDrawingText(self) bytes¶
return the PNG data as a string
- class rdkit.Chem.Draw.rdMolDraw2D.MolDraw2DSVG(self, width: int, height: int, panelWidth: int = -1, panelHeight: int = -1, noFreetype: bool = False)¶
Bases:
MolDraw2DSVG molecule drawer
- AddMoleculeMetadata(self, mol: rdkit.Chem.rdchem.Mol, confId: int = -1) None¶
add RDKit-specific information to the bottom of the drawing
- GetDrawingText(self) str¶
return the SVG
- TagAtoms(self, mol: rdkit.Chem.rdchem.Mol, radius: float = 0.2, events: object | None = None) None¶
allow atom selection in the SVG
- class rdkit.Chem.Draw.rdMolDraw2D.MolDrawOptions(self)¶
Bases:
objectDrawing options
- property addAtomIndices¶
adds atom indices to drawings. Default False.
- property addBondIndices¶
adds bond indices to drawings. Default False.
- property addStereoAnnotation¶
adds R/S and E/Z to drawings. Default False.
- property addStereoGroupAnnotation¶
Whether to add the enhanced stereo labels. Default is True.
- property additionalAtomLabelPadding¶
additional padding to leave around atom labels. Expressed as a fraction of the font size.
- property annotationColour¶
the annotation colour as an (R,G,B,A) tuple, values should be between 0 and 1
- property annotationFontScale¶
Scale of font for atom and bond annotation relative to atom label font. Default=0.75.
- property atomHighlightsAreCircles¶
forces atom highlights always to be circles. Default (false) is to put ellipses round longer labels.
- property atomLabelDeuteriumTritium¶
labels deuterium as D and tritium as T
- property atomLabels¶
maps indices to atom labels
- property atomNoteColour¶
the atom note colour as an (R,G,B,A) tuple, values should be between 0 and 1
- property atomRegions¶
regions to outline
- property backgroundColour¶
the background colour as an (R,G,B,A) tuple, values should be between 0 and 1
- property baseFontSize¶
relative size of font. Defaults to 0.6. -1 means use default.
- property bondLineWidth¶
if positive, this overrides the default line width for bonds
- property bondNoteColour¶
the bond note colour as an (R,G,B,A) tuple, values should be between 0 and 1
- property bracketsAroundAtomLists¶
Whether to put brackets round atom lists in query atoms. Default is true.
- property centreMoleculesBeforeDrawing¶
Moves the centre of the drawn molecule to (0,0). Default False.
- property circleAtoms¶
(self) -> bool
- property clearBackground¶
clear the background before drawing a molecule
- property comicMode¶
simulate hand-drawn lines for bonds. When combined with a font like Comic-Sans or Comic-Neue, this gives xkcd-like drawings. Default is false.
- property continuousHighlight¶
(self) -> bool
- property drawMolsSameScale¶
when drawing multiple molecules with DrawMolecules, forces them to use the same scale. Default is true.
- property drawingExtentsInclude¶
Drawing extents are computed taking into account only selected DrawElement items. Default=DrawElement.ALL
- property dummiesAreAttachments¶
(self) -> bool
- property dummyIsotopeLabels¶
adds isotope labels on dummy atoms. Default True.
- property explicitMethyl¶
Draw terminal methyls explictly. Default is false.
- property fillHighlights¶
(self) -> bool
- property fixedBondLength¶
If > 0.0, fixes bond length to this number of pixels unless that would make it too big. Default -1.0 means no fix. If both set, fixedScale takes precedence.
- property fixedFontSize¶
font size in pixels. default=-1 means not fixed. If set, always used irrespective of scale, minFontSize and maxFontSize.
- property fixedScale¶
If > 0.0, fixes scale to that fraction of width of draw window unless that would make it too big. Default -1.0 means adjust scale to fit.
- property flagCloseContactsDist¶
(self) -> int
- property fontFile¶
Font file for use with FreeType text drawer. Can also be BuiltinTelexRegular (the default) or BuiltinRobotoRegular.
- getAnnotationColour(self) tuple¶
method returning the annotation colour
- getAtomNoteColour(self) tuple¶
method returning the atom note colour
- getAtomPalette(self) dict¶
returns the current atom palette as a dictionary mapping ints to 4-tuples
- getBackgroundColour(self) tuple¶
method returning the background colour
- getBondNoteColour(self) tuple¶
method returning the bond note colour
- getHighlightColour(self) tuple¶
method returning the highlight colour
- getLegendColour(self) tuple¶
method returning the legend colour
- getQueryColour(self) tuple¶
method returning the query colour
- getSymbolColour(self) tuple¶
method returning the symbol colour
- getVariableAttachmentColour(self) tuple¶
method for getting the colour of variable attachment points
- property highlightBondWidthMultiplier¶
What to multiply default bond width by for highlighting bonds. Default-8.
- property highlightColour¶
the highlight colour as an (R,G,B,A) tuple, values should be between 0 and 1
- property highlightRadius¶
Default radius for highlight circles.
- property includeAtomTags¶
include atom tags in output
- property includeChiralFlagLabel¶
add a molecule annotation with “ABS” if the chiral flag is set. Default is false.
- property includeMetadata¶
When possible, include metadata about molecules and reactions to allow them to be reconstructed. Default is true.
- property includeRadicals¶
include radicals in the drawing (it can be useful to turn this off for reactions and queries). Default is true.
- property isotopeLabels¶
adds isotope labels on non-dummy atoms. Default True.
- property legendColour¶
the legend colour as an (R,G,B,A) tuple, values should be between 0 and 1
- property legendFontSize¶
font size in pixels of the legend (if drawn)
- property legendFraction¶
fraction of the draw panel to be used for the legend if present
- property legendPosition¶
legend position enum. Default=Bottom. Values: LegendPosition.Bottom, LegendPosition.Top, LegendPosition.Left, LegendPosition.Right.
- property legendVerticalText¶
when legend is Left or Right, draw text vertically (one char per line)
- property maxFontSize¶
maximum font size in pixels. default=40, -1 means no maximum.
- property minFontSize¶
minimum font size in pixels. default=6, -1 means no minimum.
- property multiColourHighlightStyle¶
Either ‘CircleAndLine’ or ‘Lasso’, to control style of multi-coloured highlighting in DrawMoleculeWithHighlights. Default is CircleAndLine.
- property multipleBondOffset¶
offset for the extra lines in a multiple bond as a fraction of mean bond length
- property noAtomLabels¶
disables inclusion of atom labels in the rendering
- property padding¶
Fraction of empty space to leave around molecule. Default=0.05.
- property prepareMolsBeforeDrawing¶
call prepareMolForDrawing() on each molecule passed to DrawMolecules()
- property queryColour¶
the query colour as an (R,G,B,A) tuple, values should be between 0 and 1
- property reagentPadding¶
Fraction of empty space to leave around each component of a reaction drawing. Default=0.0.
- property rotate¶
Rotates molecule about centre by this number of degrees,
- property scaleBondWidth¶
Scales the width of drawn bonds using image scaling.
- property scaleHighlightBondWidth¶
Scales the width of drawn highlighted bonds using image scaling.
- property scalingFactor¶
scaling factor for pixels->angstrom when auto scaling being used. Default is 20.
- setAtomPalette(self, cmap: object) None¶
sets the palette for atoms and bonds from a dictionary mapping ints to 3-tuples
- setVariableAttachmentColour(self, tpl: tuple) None¶
method for setting the colour of variable attachment points
- property showAllCIPCodes¶
show all defined CIP codes (no hiding!). Default False.
- property simplifiedStereoGroupLabel¶
if all specified stereocenters are in a single StereoGroup, show a molecule-level annotation instead of the individual labels. Default is false.
- property singleColourBonds¶
if true all bonds are drawn using symbolColour rather than inheriting their colour from the atoms. Default is false.
- property singleColourWedgeBonds¶
if true wedged and dashed bonds are drawn using symbolColour rather than inheriting their colour from the atoms. Default is false.
- property splitBonds¶
(self) -> bool
- property standardColoursForHighlightedAtoms¶
If true, highlighted hetero atoms are drawn in standard colours rather than black. Default=False
- property stereoGroupAbsLabel¶
String to use for enhanced stereo ‘ABS’ groups. Default=’abs’.
- property stereoGroupAndLabel¶
String to use for enhanced stereo ‘AND’ groups. Default=’and’.
- property stereoGroupOrLabel¶
String to use for enhanced stereo ‘OR’ groups. Default=’or’.
- property symbolColour¶
the symbol colour as an (R,G,B,A) tuple, values should be between 0 and 1
- property unspecifiedStereoIsUnknown¶
if true, double bonds with unspecified stereo are drawn crossed, potential stereocenters with unspecified stereo are drawn with a wavy bond. Default is false.
- updateAtomPalette(self, cmap: object) None¶
updates the palette for atoms and bonds from a dictionary mapping ints to 3-tuples
- property useComplexQueryAtomSymbols¶
replace any atom, any hetero, any halo queries with complex query symbols A, Q, X, M, optionally followed by H if hydrogen is included (except for AH, which stays *). Default is true
- property useMolBlockWedging¶
If the molecule came from a MolBlock, prefer the wedging information that provides. If false, use RDKit rules. Default false
- property variableAtomRadius¶
radius value to use for atoms involved in variable attachment points.
- property variableAttachmentColour¶
the variable attachment colour as an (R,G,B,A) tuple, values should be between 0 and 1
- property variableBondWidthMultiplier¶
what to multiply standard bond width by for variable attachment points.