Depicting Molecule with Various Styles
Problem
You want to depict a molecule with various styles.
|
|
|
|
|
|
|
|
|
|
|
|
The examples below generate interactive .svg images
These svg images should be included into an HTML page with the SVG MIME type.
<object data="<imagename>.svg" type="image/svg+xml"></object>
|
|
|
|
Ingredients
|
Difficulty Level
🌶️
Solution
Default
"""Code snippet for customizing style of molecule depiction."""
from openeye import oechem, oedepict
mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, r"C/C=C\C1CCc2cc[nH]c2[C@@H]1C(=O)O molecule")
oedepict.OEPrepareDepiction(mol)
width, height, scale = 300, 200, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
disp = oedepict.OE2DMolDisplay(mol, opts)
Download code |
|
See also
OE2DMolDisplayOptions class
OE2DMolDisplay class
OERenderMolecule function
Aromaticity Style
from openeye import oechem, oedepict
mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, r"C/C=C\C1CCc2cc[nH]c2[C@@H]1C(=O)O molecule")
oedepict.OEPrepareDepiction(mol)
width, height, scale = 300, 200, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
opts.SetAromaticStyle(oedepict.OEAromaticStyle_Circle)
disp = oedepict.OE2DMolDisplay(mol, opts)
Download code |
|
See also
OEAromaticStyle namespace
Atom Color Style
from openeye import oechem, oedepict
mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, r"C/C=C\C1CCc2cc[nH]c2[C@@H]1C(=O)O molecule")
oedepict.OEPrepareDepiction(mol)
width, height, scale = 300, 200, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
opts.SetAtomColorStyle(oedepict.OEAtomColorStyle_BlackCPK)
disp = oedepict.OE2DMolDisplay(mol, opts)
Download code |
|
See also
OEAtomColorStyle namespace
Super Atom Style
from openeye import oechem, oedepict
mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, r"C/C=C\C1CCc2cc[nH]c2[C@@H]1C(=O)O molecule")
oedepict.OEPrepareDepiction(mol)
width, height, scale = 300, 200, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
opts.SetSuperAtomStyle(oedepict.OESuperAtomStyle_All)
disp = oedepict.OE2DMolDisplay(mol, opts)
Download code |
|
See also
OESuperAtomStyle namespace
Atom Stereo Style
from openeye import oechem, oedepict
mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, r"C/C=C\C1CCc2cc[nH]c2[C@@H]1C(=O)O molecule")
oedepict.OEPrepareDepiction(mol)
width, height, scale = 300, 200, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
stereo_style = oedepict.OEAtomStereoStyle_Display_All
stereo_style |= oedepict.OEAtomStereoStyle_HashWedgeStyle_Standard
opts.SetAtomStereoStyle(stereo_style)
disp = oedepict.OE2DMolDisplay(mol, opts)
Download code |
|
See also
OEAtomStereoStyle namespace
Bond Stereo Style
from openeye import oechem, oedepict
mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, r"C/C=C\C1CCc2cc[nH]c2[C@@H]1C(=O)O molecule")
oedepict.OEPrepareDepiction(mol)
width, height, scale = 300, 200, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
opts.SetBondStereoStyle(oedepict.OEBondStereoStyle_Display_All)
disp = oedepict.OE2DMolDisplay(mol, opts)
Download code |
|
See also
OEBondStereoStyle namespace
Title Style
from openeye import oechem, oedepict
mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, r"C/C=C\C1CCc2cc[nH]c2[C@@H]1C(=O)O molecule")
oedepict.OEPrepareDepiction(mol)
width, height, scale = 300, 200, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
opts.SetTitleLocation(oedepict.OETitleLocation_Bottom)
font_type = oedepict.OEFontFamily_Default
font_style = oedepict.OEFontStyle_Bold | oedepict.OEFontStyle_Italic
font_align = oedepict.OEAlignment_Center
font_size = 10
font = oedepict.OEFont(font_type, font_style, font_size, font_align, oechem.OERoyalBlue)
opts.SetTitleFont(font)
disp = oedepict.OE2DMolDisplay(mol, opts)
Download code |
|
See also
OETitleLocation namespace
OEFont class
Border Style
from openeye import oechem, oedepict
mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, r"C/C=C\C1CCc2cc[nH]c2[C@@H]1C(=O)O molecule")
oedepict.OEPrepareDepiction(mol)
width, height, scale = 300, 200, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
disp = oedepict.OE2DMolDisplay(mol, opts)
layer = disp.GetLayer(oedepict.OELayerPosition_Below)
lightred = oechem.OEColor(255, 235, 235) # R, G, B
mediumred = oechem.OEColor(225, 55, 55) # R, G, B
linewidth = 6.0
pen = oedepict.OEPen(lightred, mediumred, oedepict.OEFill_On, linewidth)
cornersize = 30
oedepict.OEDrawCurvedBorder(layer, pen, cornersize)
Download code |
|
See also
OE2DMolDisplay.GetLayer method
OELayerPosition namespace
OEPen class
OEDrawCurvedBorder method
Display Atom Index
from openeye import oechem, oedepict
mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, r"C/C=C\C1CCc2cc[nH]c2[C@@H]1C(=O)O molecule")
oedepict.OEPrepareDepiction(mol)
width, height, scale = 300, 200, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
opts.SetAtomPropertyFunctor(oedepict.OEDisplayAtomIdx())
disp = oedepict.OE2DMolDisplay(mol, opts)
Download code |
|
See also
OEDisplayAtomIdx class
OEDisplayAtomPropBase base class
Display Bond Index
from openeye import oechem, oedepict
mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, r"C/C=C\C1CCc2cc[nH]c2[C@@H]1C(=O)O molecule")
oedepict.OEPrepareDepiction(mol)
width, height, scale = 300, 200, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
opts.SetBondPropertyFunctor(oedepict.OEDisplayBondIdx())
disp = oedepict.OE2DMolDisplay(mol, opts)
Download code |
|
See also
OEDisplayBondIdx class
OEDisplayBondPropBase base class
Display Atom Property
from openeye import oechem, oedepict
class LabelAtomTopology(oedepict.OEDisplayAtomPropBase):
"""Functor to assign labels to displayed atoms."""
def __init__(self) -> None:
"""Initialize functor."""
oedepict.OEDisplayAtomPropBase.__init__(self)
def __call__(self, atom: oechem.OEAtomBase) -> str:
"""Assign label."""
if atom.IsInRing():
return "R"
return "C"
def CreateCopy(self): # noqa: ANN201, N802
"""Copy constructor."""
copy = LabelAtomTopology()
return copy.__disown__()
mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, r"C/C=C\C1CCc2cc[nH]c2[C@@H]1C(=O)O molecule")
oedepict.OEPrepareDepiction(mol)
width, height, scale = 300, 200, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
opts.SetAtomPropertyFunctor(LabelAtomTopology())
font_type = oedepict.OEFontFamily_Default
font_style = oedepict.OEFontStyle_Bold
font_align = oedepict.OEAlignment_Center
Download code |
|
See also
OEDisplayAtomPropBase base class
OEFont class
Display Bond Property
from openeye import oechem, oedepict
class LabelBondTopology(oedepict.OEDisplayBondPropBase):
"""Functor to assign labels to displayed bonds."""
def __init__(self) -> None:
"""Initialize functor."""
oedepict.OEDisplayBondPropBase.__init__(self)
def __call__(self, bond: oechem.OEBondBase) -> str:
"""Assign label."""
if bond.IsAromatic():
return "a"
return ""
def CreateCopy(self): # noqa: ANN201, N802
"""Copy constructor."""
copy = LabelBondTopology()
return copy.__disown__()
mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, r"C/C=C\C1CCc2cc[nH]c2[C@@H]1C(=O)O molecule")
oedepict.OEPrepareDepiction(mol)
width, height, scale = 300, 200, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
opts.SetBondPropertyFunctor(LabelBondTopology())
font_type = oedepict.OEFontFamily_Default
font_style = oedepict.OEFontStyle_Bold
font_align = oedepict.OEAlignment_Center
Download code |
|
See also
OEDisplayBondPropBase base class
OEFont class
Hover Atom Property
See also
OEFont class
OEDrawSVGHoverText function
Hover Bond Property
See also
OEFont class
OEDrawSVGHoverText function
Toggle Atom Property
See also
OEFont class
OEDrawSVGToggleText function
Toggle Bond Property
See also
OEFont class
OEDrawSVGToggleText function
See also in OEChem TK manual
API
OESmilesToMol function
See also in OEDepict TK manual
Theory
Molecule Depiction chapter
API
OE2DMolDisplay class
OE2DMolDisplayOptions class
OEPrepareDepiction function
OERenderMolecule function