Appendix: Selected Examples in Python

These are full listings of programming examples that are excerpted or offered for download, elsewhere in this chapter.

#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

###############################################################
# USED TO GENERATE CODE SNIPPETS FOR THE OEDEPICT DOCUMENTATION
###############################################################

mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "c1cc(N)cc(S(=O)(=O)O)c1")
oedepict.OEPrepareDepiction(mol)

width, height = 300, 200

opts = oedepict.OE2DMolDisplayOptions(width, height, oedepict.OEScale_AutoScale)
disp = oedepict.OE2DMolDisplay(mol, opts)

pred = oechem.OEHasAtomicNum(oechem.OEElemNo_O)
for atom in mol.GetAtoms(pred):
    adisp = disp.GetAtomDisplay(atom)
    if adisp is not None and adisp.IsVisible():
        # do something
        pass

for adisp in disp.GetAtomDisplays(oechem.OEHasAtomicNum(oechem.OEElemNo_O)):
    if adisp.IsVisible():
        # do something
        pass
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

###############################################################
# USED TO GENERATE CODE SNIPPETS FOR THE OEDEPICT DOCUMENTATION
###############################################################

mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "c1cc(N)cc(S(=O)(=O)O)c1")
oedepict.OEPrepareDepiction(mol)

width, height = 300, 200

opts = oedepict.OE2DMolDisplayOptions(width, height, oedepict.OEScale_AutoScale)
disp = oedepict.OE2DMolDisplay(mol, opts)

pred = oechem.OEIsAromaticBond()
for bond in mol.GetBonds(pred):
    bdisp = disp.GetBondDisplay(bond)
    if bdisp is not None and bdisp.IsVisible():
        # do something
        pass

for bdisp in disp.GetBondDisplays(oechem.OEIsAromaticBond()):
    if bdisp.IsVisible():
        # do something
        pass
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

width, height = 400, 200
image = oedepict.OEImage(width, height)

mol = oechem.OEGraphMol()
smiles = "Cc1cccnc1/C=C/[C@H](C(=O)O)O"
oechem.OESmilesToMol(mol, smiles)
oedepict.OEPrepareDepiction(mol)

opts = oedepict.OE2DMolDisplayOptions(width, height, oedepict.OEScale_AutoScale)
opts.SetMargins(10)
disp = oedepict.OE2DMolDisplay(mol, opts)

for adisp in disp.GetAtomDisplays():
    atom = adisp.GetAtom()
    message = "atom idx=%s" % atom.GetIdx()
    oedepict.OEAddSVGClickEvent(disp, adisp, message)

oedepict.OERenderMolecule("AddAtomClickEvent.svg", disp)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

width, height = 400, 200
image = oedepict.OEImage(width, height)

mol = oechem.OEGraphMol()
smiles = "Cc1cccnc1/C=C/[C@H](C(=O)O)O"
oechem.OESmilesToMol(mol, smiles)
oedepict.OEPrepareDepiction(mol)

opts = oedepict.OE2DMolDisplayOptions(width, height, oedepict.OEScale_AutoScale)
opts.SetMargins(10)
disp = oedepict.OE2DMolDisplay(mol, opts)

for bdisp in disp.GetBondDisplays():
    bond = bdisp.GetBond()
    message = "bond idx=%s" % bond.GetIdx()
    oedepict.OEAddSVGClickEvent(disp, bdisp, message)

oedepict.OERenderMolecule("AddBondClickEvent.svg", disp)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oedepict

width, height = 200, 100
image = oedepict.OEImage(width, height)

group_rectangle = image.NewSVGGroup("rectangle")

message = "clicked on rectangle"
oedepict.OEAddSVGClickEvent(group_rectangle, message)

image.PushGroup(group_rectangle)
image.DrawRectangle(oedepict.OE2DPoint(30, 30), oedepict.OE2DPoint(70, 70), oedepict.OERedBoxPen)
image.PopGroup(group_rectangle)

group_circle = image.NewSVGGroup("circle")

message = "clicked on circle"
oedepict.OEAddSVGClickEvent(group_circle, message)

image.PushGroup(group_circle)
image.DrawCircle(oedepict.OE2DPoint(150, 50), 30, oedepict.OEBlueBoxPen)
image.PopGroup(group_circle)

oedepict.OEWriteImage("AddSVGClickEvent.svg", image)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oedepict

width, height = 200, 100
image = oedepict.OEImage(width, height)

hover_area = image.NewSVGGroup("hover_area")
target_area = image.NewSVGGroup("hover_target_area")

oedepict.OEAddSVGHover(hover_area, target_area)

image.PushGroup(hover_area)
image.DrawRectangle(oedepict.OE2DPoint(30, 30),
                    oedepict.OE2DPoint(70, 70), oedepict.OERedBoxPen)
image.PopGroup(hover_area)

image.PushGroup(target_area)
image.DrawCircle(oedepict.OE2DPoint(150, 50), 30, oedepict.OEBlueBoxPen)
image.PopGroup(target_area)

oedepict.OEAddInteractiveIcon(image)

oedepict.OEWriteImage("AddSVGHover.svg", image)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oedepict

width, height = 200, 100
image = oedepict.OEImage(width, height)

toggle_area = image.NewSVGGroup("toggle_area")
target_area = image.NewSVGGroup("toggle_target_area")

oedepict.OEAddSVGToggle(toggle_area, target_area)

image.PushGroup(toggle_area)
image.DrawRectangle(oedepict.OE2DPoint(30, 30),
                    oedepict.OE2DPoint(70, 70), oedepict.OERedBoxPen)
image.PopGroup(toggle_area)

image.PushGroup(target_area)
image.DrawCircle(oedepict.OE2DPoint(150, 50), 30, oedepict.OEBlueBoxPen)
image.PopGroup(target_area)

oedepict.OEAddInteractiveIcon(image)

oedepict.OEWriteImage("AddSVGToggle.svg", image)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "c1cc(N)cc(S(=O)(=O)O)c1")
oedepict.OEPrepareDepiction(mol)

width, height = 300, 200

opts = oedepict.OE2DMolDisplayOptions(width, height, oedepict.OEScale_AutoScale)
disp = oedepict.OE2DMolDisplay(mol, opts)

for adisp in disp.GetAtomDisplays(oechem.OEHasAtomicNum(oechem.OEElemNo_C)):
    if adisp.IsVisible():
        adisp.SetLabel("C")

oedepict.OERenderMolecule("AtomDisplayLabel.png", disp)
oedepict.OERenderMolecule("AtomDisplayLabel.pdf", disp)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "c1cc(N)cc(S(=O)(=O)O)c1")
oedepict.OEPrepareDepiction(mol)

width, height = 300, 200

opts = oedepict.OE2DMolDisplayOptions(width, height, oedepict.OEScale_AutoScale)
opts.SetAtomPropertyFunctor(oedepict.OEDisplayAtomIdx())
opts.SetAtomPropLabelFont(oedepict.OEFont(oechem.OEDarkGreen))

disp = oedepict.OE2DMolDisplay(mol, opts)
oedepict.OERenderMolecule("AtomPropIndex.png", disp)
oedepict.OERenderMolecule("AtomPropIndex.pdf", disp)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict


class LabelAromaticAtoms(oedepict.OEDisplayAtomPropBase):
    def __init__(self):
        oedepict.OEDisplayAtomPropBase.__init__(self)

    def __call__(self, atom):
        if atom.IsAromatic():
            return "(A)"
        return ""

    def CreateCopy(self):
        # __disown__ is required to allow C++ to take
        # ownership of this object and its memory
        copy = LabelAromaticAtoms()
        return copy.__disown__()


mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "c1cc(N)cc(S(=O)(=O)O)c1")
oedepict.OEPrepareDepiction(mol)

width, height = 300, 200

opts = oedepict.OE2DMolDisplayOptions(width, height, oedepict.OEScale_AutoScale)

atomlabel = LabelAromaticAtoms()
opts.SetAtomPropertyFunctor(atomlabel)

disp = oedepict.OE2DMolDisplay(mol, opts)
oedepict.OERenderMolecule("AtomPropUser.png", disp)
oedepict.OERenderMolecule("AtomPropUser.pdf", disp)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict
import sys


class OEAtomVisibilityShowRxnRole(oechem.OEUnaryAtomPred):
    def __init__(self, role):
        self.rxnrole = role
        oechem.OEUnaryAtomPred.__init__(self)

    def __call__(self, atom):
        # return True if the atom should be visible, otherwise return False
        if self.rxnrole == oechem.OERxnRole_None:
            return True
        return (self.rxnrole == atom.GetRxnRole())

    def CreateCopy(self):
        # __disown__ is required to allow C++ to take
        # ownership of this object and its memory
        return OEAtomVisibilityShowRxnRole(self.rxnrole).__disown__()


if len(sys.argv) != 3:
    oechem.OEThrow.Usage("%s <rxnfile> <imagefile>" % sys.argv[0])

ifs = oechem.oemolistream(sys.argv[1])

mol = oechem.OEGraphMol()
if not oechem.OEReadRxnFile(ifs, mol):
    oechem.OEThrow.Fatal("%s error reading reaction file" % sys.argv[0])

oedepict.OEPrepareDepiction(mol)

image = oedepict.OEImage(900, 100)

rows, cols = 1, 3
grid = oedepict.OEImageGrid(image, rows, cols)

opts = oedepict.OE2DMolDisplayOptions(grid.GetCellWidth(), grid.GetCellHeight(),
                                      oedepict.OEScale_AutoScale)

cell = grid.GetCell(1, 1)
mol.SetTitle("Reaction display")
opts.SetAtomVisibilityFunctor(oechem.OEIsTrueAtom())  # explicitly set the default
disp = oedepict.OE2DMolDisplay(mol, opts)
rxnscale = disp.GetScale()
oedepict.OERenderMolecule(cell, disp)

cell = grid.GetCell(1, 2)
mol.SetTitle("Reactant display")
opts.SetAtomVisibilityFunctor(OEAtomVisibilityShowRxnRole(oechem.OERxnRole_Reactant))
opts.SetScale(rxnscale)
disp = oedepict.OE2DMolDisplay(mol, opts)
oedepict.OERenderMolecule(cell, disp)

cell = grid.GetCell(1, 3)
mol.SetTitle("Product display")
opts.SetAtomVisibilityFunctor(OEAtomVisibilityShowRxnRole(oechem.OERxnRole_Product))
opts.SetScale(rxnscale)
disp = oedepict.OE2DMolDisplay(mol, opts)
oedepict.OERenderMolecule(cell, disp)

oedepict.OEWriteImage(sys.argv[2], image)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "c1cc(N)cc(S(=O)(=O)O)c1")
oedepict.OEPrepareDepiction(mol)

width, height = 300, 200

opts = oedepict.OE2DMolDisplayOptions(width, height, oedepict.OEScale_AutoScale)
opts.SetBondPropertyFunctor(oedepict.OEDisplayBondIdx())
opts.SetBondPropLabelFont(oedepict.OEFont(oechem.OEDarkBlue))

disp = oedepict.OE2DMolDisplay(mol, opts)
oedepict.OERenderMolecule("BondPropIndex.png", disp)
oedepict.OERenderMolecule("BondPropIndex.pdf", disp)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict


class LabelRingChainBonds(oedepict.OEDisplayBondPropBase):
    def __init__(self):
        oedepict.OEDisplayBondPropBase.__init__(self)

    def __call__(self, bond):
        if bond.IsInRing():
            return "R"
        return "C"

    def CreateCopy(self):
        # __disown__ is required to allow C++ to take
        # ownership of this object and its memory
        copy = LabelRingChainBonds()
        return copy.__disown__()


mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "c1cc(N)cc(S(=O)(=O)O)c1")
oedepict.OEPrepareDepiction(mol)

width, height = 300, 200

opts = oedepict.OE2DMolDisplayOptions(width, height, oedepict.OEScale_AutoScale)

bondlabel = LabelRingChainBonds()
opts.SetBondPropertyFunctor(bondlabel)

disp = oedepict.OE2DMolDisplay(mol, opts)
oedepict.OERenderMolecule("BondPropUser.png", disp)
oedepict.OERenderMolecule("BondPropUser.pdf", disp)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oedepict

width, height = 100, 100
image = oedepict.OEImage(width, height)

svg_group_circ = image.NewSVGGroup("circle")
svg_group_rect = image.NewSVGGroup("rectangle")
svg_class_objs = image.NewSVGClass("object")

svg_group_circ.AddSVGClass(svg_class_objs)
svg_group_rect.AddSVGClass(svg_class_objs)

image.PushGroup(svg_group_circ)
image.DrawCircle(oedepict.OEGetCenter(image), 30, oedepict.OERedBoxPen)
image.PopGroup(svg_group_circ)

image.PushGroup(svg_group_rect)
image.DrawRectangle(oedepict.OE2DPoint(10, 10), oedepict.OE2DPoint(90, 90), oedepict.OELightGreyPen)
image.PopGroup(svg_group_rect)

oedepict.OEWriteImage("CreateSVGClass.svg", image)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oedepict

width, height = 100, 100
image = oedepict.OEImage(width, height)

svg_group_circ = image.NewSVGGroup("circle")

image.PushGroup(svg_group_circ)
image.DrawCircle(oedepict.OEGetCenter(image), 30, oedepict.OERedBoxPen)
image.PopGroup(svg_group_circ)

oedepict.OEWriteImage("CreateSVGGroup.svg", image)

for g in image.GetSVGGroups():
    print(g.GetId())
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict
import sys

if len(sys.argv) != 3:
    oechem.OEThrow.Usage("%s <mdlquery> <imagefile>" % sys.argv[0])

ifs = oechem.oemolistream(sys.argv[1])
qmol = oechem.OEGraphMol()
oechem.OEReadMDLQueryFile(ifs, qmol)
oedepict.OEPrepareDepiction(qmol)
oedepict.OERenderMolecule(sys.argv[2], qmol)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict
import sys

if len(sys.argv) != 3:
    oechem.OEThrow.Usage("%s <mdlreaction> <imagefile>" % sys.argv[0])

ifs = oechem.oemolistream(sys.argv[1])
qmol = oechem.OEGraphMol()
oechem.OEReadMDLReactionQueryFile(ifs, qmol)
oedepict.OEPrepareDepiction(qmol)
oedepict.OERenderMolecule(sys.argv[2], qmol)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict
import sys

if len(sys.argv) != 3:
    oechem.OEThrow.Usage("%s <mdlreaction> <imagefile>" % sys.argv[0])

ifile = sys.argv[1]
ofile = sys.argv[2]

ifs = oechem.oemolistream(ifile)
qmol = oechem.OEGraphMol()
oechem.OEReadMDLReactionQueryFile(ifs, qmol)
oedepict.OEPrepareDepiction(qmol)

opts = oedepict.OE2DMolDisplayOptions()
opts.SetAtomPropertyFunctor(oedepict.OEDisplayAtomMapIdx())
disp = oedepict.OE2DMolDisplay(qmol, opts)

oedepict.OERenderMolecule(ofile, disp)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict
import sys


def main(argv=[__name__]):
    # import configuration file
    itf = oechem.OEInterface()
    oechem.OEConfigure(itf, InterfaceData)
    # add configuration for image size and display options
    oedepict.OEConfigureImageOptions(itf)
    oedepict.OEConfigure2DMolDisplayOptions(itf)

    if not oechem.OEParseCommandLine(itf, argv):
        oechem.OEThrow.Fatal("Unable to interpret command line!")

    ifname = itf.GetString("-in")
    ofname = itf.GetString("-out")

    ifs = oechem.oemolistream(ifname)
    mol = oechem.OEGraphMol()
    oechem.OEReadMolecule(ifs, mol)
    oedepict.OEPrepareDepiction(mol)

    width, height = oedepict.OEGetImageWidth(itf), oedepict.OEGetImageHeight(itf)
    opts = oedepict.OE2DMolDisplayOptions(width, height, oedepict.OEScale_AutoScale)
    # set up display options from command line parameters
    oedepict.OESetup2DMolDisplayOptions(opts, itf)

    disp = oedepict.OE2DMolDisplay(mol, opts)
    oedepict.OERenderMolecule(ofname, disp)


InterfaceData = """
!CATEGORY "input/output options :"

  !PARAMETER -in
    !ALIAS -i
    !TYPE string
    !REQUIRED true
    !BRIEF Input filename
  !END

  !PARAMETER -out
    !ALIAS -o
    !TYPE string
    !REQUIRED true
    !BRIEF Output filename
  !END

!END
"""

if __name__ == "__main__":
    sys.exit(main(sys.argv))
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "c1cc(N)cc(S(=O)(=O)O)c1")
oedepict.OEPrepareDepiction(mol)

width, height = 200, 200
opts = oedepict.OE2DMolDisplayOptions(width, height, oedepict.OEScale_AutoScale)

opts.SetAtomColorStyle(oedepict.OEAtomColorStyle_WhiteMonochrome)
opts.SetTitleLocation(oedepict.OETitleLocation_Hidden)
opts.SetAtomColor(oechem.OEElemNo_C, oechem.OEDarkGreen)
pen = oedepict.OEPen(oechem.OEBlack, oechem.OEBlack, oedepict.OEFill_On, 3.0)
opts.SetDefaultBondPen(pen)

disp = oedepict.OE2DMolDisplay(mol, opts)

for adisp in disp.GetAtomDisplays():
    adisp.SetLabel("")

for bdisp in disp.GetBondDisplays():
    bdisp.SetDisplayType(oedepict.OEBondDisplayType_Single)

oedepict.OERenderMolecule("DepictMolGraph.png", disp)
oedepict.OERenderMolecule("DepictMolGraph.pdf", disp)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

###############################################################
# USED TO GENERATE CODE SNIPPETS FOR THE OEDEPICT DOCUMENTATION
###############################################################

mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "c1ccccc1")
oedepict.OEPrepareDepiction(mol)

width, height, scale = 0.0, 0.0, 50.0
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
disp = oedepict.OE2DMolDisplay(mol, opts)
print("width  %.1f" % disp.GetWidth())
print("height %.1f" % disp.GetHeight())
print("scale  %.1f" % disp.GetScale())
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "c1cc(N)cc(S(=O)(=O)O)c1 3-aminobenzenesulfonic acid")
oedepict.OEPrepareDepiction(mol)
oedepict.OERenderMolecule("DepictMolSimple.png", mol)
oedepict.OERenderMolecule("DepictMolSimple.pdf", mol)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "c1cc(N)cc(S(=O)(=O)O)c1 3-aminobenzenesulfonic acid")
oedepict.OEPrepareDepiction(mol)

width, height = 300, 300
opts = oedepict.OE2DMolDisplayOptions(width, height, oedepict.OEScale_AutoScale)
disp = oedepict.OE2DMolDisplay(mol, opts)
oedepict.OERenderMolecule("DepictMolSize.png", disp)
oedepict.OERenderMolecule("DepictMolSize.pdf", disp)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "c1cc(N)cc(S(=O)(=O)O)c1 3-aminobenzenesulfonic acid")
oedepict.OEPrepareDepiction(mol)

width, height = 200, 200
opts = oedepict.OE2DMolDisplayOptions(width, height, oedepict.OEScale_AutoScale)

opts.SetAromaticStyle(oedepict.OEAromaticStyle_Circle)
opts.SetAtomColorStyle(oedepict.OEAtomColorStyle_BlackCPK)
opts.SetTitleLocation(oedepict.OETitleLocation_Bottom)

disp = oedepict.OE2DMolDisplay(mol, opts)
oedepict.OERenderMolecule("DepictMolStyle.png", disp)
oedepict.OERenderMolecule("DepictMolStyle.pdf", disp)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "c1cc(N)cc(S(=O)(=O)O)c1 3-aminobenzenesulfonic acid")
oedepict.OEPrepareDepiction(mol)

width, height, scale = 200.0, 200.0, oedepict.OEScale_AutoScale
image = oedepict.OEImage(width, height, oechem.OETransparentColor)

opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
disp = oedepict.OE2DMolDisplay(mol, opts)

clearbackground = True
oedepict.OERenderMolecule("DepictMolTransparent.png", disp, not clearbackground)
oedepict.OERenderMolecule("DepictMolTransparent.pdf", disp, not clearbackground)
oedepict.OERenderMolecule("DepictMolTransparent.svg", disp, not clearbackground)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "OC(=O)c1ccccc1")
oedepict.OEPrepareDepiction(mol)

width, height = 150.0, 150.0
image = oedepict.OEImage(width, height)
opts = oedepict.OE2DMolDisplayOptions(width, height, oedepict.OEScale_AutoScale)
opts.SetTitleLocation(oedepict.OETitleLocation_Bottom)

# associate font with URI

font = oedepict.OEFont(oedepict.OEFontFamily_Default, oedepict.OEFontStyle_Default, 10,
                       oedepict.OEAlignment_Center, oechem.OEBlue)
font.SetHyperlink("http://www.eyesopen.com/oedepict-tk")

opts.SetTitleFont(font)
mol.SetTitle("Generated by OEDepict")

disp = oedepict.OE2DMolDisplay(mol, opts)
oedepict.OERenderMolecule(image, disp)

oedepict.OEWriteImage("DepictMolWithHyperlink.pdf", image)
oedepict.OEWriteImage("DepictMolWithHyperlink.svg", image)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oedepict

width, height = 100, 100
# Create image
image = oedepict.OEImage(width, height)

# Draw line with default pen
bgn = oedepict.OE2DPoint(10.0, 10.0)
end = oedepict.OE2DPoint(90.0, 90.0)
image.DrawLine(bgn, end, oedepict.OEBlackPen)

# Write image to SVG file
oedepict.OEWriteImage("DrawLine.svg", image)
oedepict.OEWriteImage("DrawLine.png", image)
oedepict.OEWriteImage("DrawLine.pdf", image)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

###############################################################
# USED TO GENERATE CODE SNIPPETS FOR THE OEDEPICT DOCUMENTATION
###############################################################


def DrawCubicBezier():
    image = oedepict.OEImage(100, 100)

    b = oedepict.OE2DPoint(20, 70)
    e = oedepict.OE2DPoint(60, 70)
    c1 = b + oedepict.OE2DPoint(50, -60)
    c2 = e + oedepict.OE2DPoint(50, -60)

    pen = oedepict.OEPen(oechem.OELightGreen, oechem.OEBlack, oedepict.OEFill_On, 2.0)
    image.DrawCubicBezier(b, c1, c2, e, pen)

    oedepict.OEWriteImage("DrawCubicBezier.png", image)
    oedepict.OEWriteImage("DrawCubicBezier.pdf", image)


def DrawPath():
    image = oedepict.OEImage(100, 100)

    path = oedepict.OE2DPath(oedepict.OE2DPoint(20, 80))
    path.AddLineSegment(oedepict.OE2DPoint(80, 80))
    path.AddLineSegment(oedepict.OE2DPoint(80, 40))
    path.AddCurveSegment(oedepict.OE2DPoint(80, 10), oedepict.OE2DPoint(20, 10),
                         oedepict.OE2DPoint(20, 40))

    pen = oedepict.OEPen(oechem.OELightGreen, oechem.OEBlack, oedepict.OEFill_On, 2.0)
    image.DrawPath(path, pen)

    oedepict.OEWriteImage("DrawPath.png", image)
    oedepict.OEWriteImage("DrawPath.pdf", image)

    for p in path.GetPoints():
        pos = p.GetPoint()
        print(" %.1f %.1f %d" % (pos.GetX(), pos.GetY(), p.GetPointType()))


def DrawPolygon():
    image = oedepict.OEImage(100, 100)

    polygon = []
    polygon.append(oedepict.OE2DPoint(20, 20))
    polygon.append(oedepict.OE2DPoint(40, 40))
    polygon.append(oedepict.OE2DPoint(60, 20))
    polygon.append(oedepict.OE2DPoint(80, 40))
    polygon.append(oedepict.OE2DPoint(80, 80))
    polygon.append(oedepict.OE2DPoint(20, 80))

    pen = oedepict.OEPen(oechem.OELightGreen, oechem.OEBlack, oedepict.OEFill_On, 2.0)
    image.DrawPolygon(polygon, pen)
    oedepict.OEWriteImage("DrawPolygon.png", image)
    oedepict.OEWriteImage("DrawPolygon.pdf", image)


def DrawQuadraticBezier():
    image = oedepict.OEImage(100, 100)

    b = oedepict.OE2DPoint(20, 70)
    e = oedepict.OE2DPoint(80, 70)
    c = b + oedepict.OE2DPoint(30, -80)

    pen = oedepict.OEPen(oechem.OELightGreen, oechem.OEBlack, oedepict.OEFill_On, 2.0)
    image.DrawQuadraticBezier(b, c, e, pen)
    oedepict.OEWriteImage("DrawQuadraticBezier.png", image)
    oedepict.OEWriteImage("DrawQuadraticBezier.pdf", image)


DrawCubicBezier()
DrawPath()
DrawPolygon()
DrawQuadraticBezier()
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oedepict

print("Supported image file formats:")
for fmt in oedepict.OEGetSupportedImageFileExtensions():
    print(fmt)

print("Supported multi-page image file formats:")
for fmt in oedepict.OEGetSupportedMultiPageImageFileExtensions():
    print(fmt)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict
from openeye import oegraphsim

refmol = oechem.OEGraphMol()
oechem.OESmilesToMol(refmol, "C[C@H](C(=O)N1CCC[C@H]1C(=O)O)OC(=O)[C@@H](Cc2ccccc2)S")
oedepict.OEPrepareDepiction(refmol)

fitmol = oechem.OEGraphMol()
oechem.OESmilesToMol(fitmol, "C[C@H](C(=O)N1CCC[C@H]1C(=O)O)NC(=O)[C@@H](Cc2ccccn2)S")
oedepict.OEPrepareDepiction(fitmol)

image = oedepict.OEImage(500, 300)

rows, cols = 1, 2
grid = oedepict.OEImageGrid(image, rows, cols)

overlaps = oegraphsim.OEGetFPOverlap(refmol, fitmol,
                                     oegraphsim.OEGetFPType(oegraphsim.OEFPType_Tree))
oedepict.OEPrepareMultiAlignedDepiction(fitmol, refmol, overlaps)

opts = oedepict.OE2DMolDisplayOptions(grid.GetCellWidth(), grid.GetCellHeight(),
                                      oedepict.OEScale_AutoScale)
opts.SetTitleLocation(oedepict.OETitleLocation_Hidden)

refscale = oedepict.OEGetMoleculeScale(refmol, opts)
fitscale = oedepict.OEGetMoleculeScale(fitmol, opts)
opts.SetScale(min(refscale, fitscale))

refdisp = oedepict.OE2DMolDisplay(refmol, opts)
fitdisp = oedepict.OE2DMolDisplay(fitmol, opts)

refcell = grid.GetCell(1, 1)
oedepict.OERenderMolecule(refcell, refdisp)

fitcell = grid.GetCell(1, 2)
oedepict.OERenderMolecule(fitcell, fitdisp)

oedepict.OEWriteImage("FPAlign.png", image)
oedepict.OEWriteImage("FPAlign.pdf", image)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

refmol = oechem.OEGraphMol()
oechem.OESmilesToMol(refmol, "C[C@H](C(=O)N1CCC[C@H]1C(=O)O)OC(=O)[C@@H](Cc2ccccc2)S")
oedepict.OEPrepareDepiction(refmol)

fitmol = oechem.OEGraphMol()
oechem.OESmilesToMol(fitmol, "C[C@H](C(=O)N1CCC[C@H]1C(=O)O)NC(=O)[C@@H](Cc2ccccn2)S")
oedepict.OEPrepareDepiction(fitmol)

image = oedepict.OEImage(500, 300)

rows, cols = 1, 2
grid = oedepict.OEImageGrid(image, rows, cols)

opts = oedepict.OE2DMolDisplayOptions(grid.GetCellWidth(), grid.GetCellHeight(),
                                      oedepict.OEScale_AutoScale)
opts.SetTitleLocation(oedepict.OETitleLocation_Hidden)

refscale = oedepict.OEGetMoleculeScale(refmol, opts)
fitscale = oedepict.OEGetMoleculeScale(fitmol, opts)
opts.SetScale(min(refscale, fitscale))

refdisp = oedepict.OE2DMolDisplay(refmol, opts)
fitdisp = oedepict.OE2DMolDisplay(fitmol, opts)

refcell = grid.GetCell(1, 1)
oedepict.OERenderMolecule(refcell, refdisp)

fitcell = grid.GetCell(1, 2)
oedepict.OERenderMolecule(fitcell, fitdisp)

oedepict.OEWriteImage("FPNoAlignment.png", image)
oedepict.OEWriteImage("FPNoAlignment.pdf", image)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

###############################################################
# USED TO GENERATE CODE SNIPPETS FOR THE OEDEPICT DOCUMENTATION
###############################################################


def DepictMoleculesWithHighlight(smiles, ss, highlight, basefilename):

    mol = oechem.OEGraphMol()
    oechem.OESmilesToMol(mol, smiles)
    oedepict.OEPrepareDepiction(mol)
    opts = oedepict.OE2DMolDisplayOptions(220, 160, oedepict.OEScale_AutoScale)
    disp = oedepict.OE2DMolDisplay(mol, opts)

    unique = True
    for match in ss.Match(mol, unique):
        oedepict.OEAddHighlighting(disp, highlight, match)

    image = oedepict.OEImage(disp.GetWidth(), disp.GetHeight())
    oedepict.OERenderMolecule(image, disp)

    oedepict.OEWriteImage(basefilename + ".png", image)
    oedepict.OEWriteImage(basefilename + ".pdf", image)


smiles = "c1ccc2c(c1)cc(O)cn2"
ss = oechem.OESubSearch("c1ncc(O)cc1")

highlight = oedepict.OEHighlightByBallAndStick(oechem.OEDarkBlue)
highlight.SetColor(oechem.OEPinkTint)
DepictMoleculesWithHighlight(smiles, ss, highlight, "OEHighlightByBallAndStick_SetColor")

highlight = oedepict.OEHighlightByBallAndStick(oechem.OEPinkTint)
highlight.SetStickWidthScale(5.0)
DepictMoleculesWithHighlight(smiles, ss, highlight, "OEHighlightByBallAndStick_SetStickWidthScale")

highlight = oedepict.OEHighlightByBallAndStick(oechem.OEPinkTint)
highlight.SetBallRadiusScale(4.0)
DepictMoleculesWithHighlight(smiles, ss, highlight, "OEHighlightByBallAndStick_SetBallRadiusScale")

highlight = oedepict.OEHighlightByBallAndStick(oechem.OEPinkTint)
highlight.SetAtomLabelMonochrome(False)
DepictMoleculesWithHighlight(smiles, ss, highlight,
                             "OEHighlightByBallAndStick_SetAtomLabelMonochrome")
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

###############################################################
# USED TO GENERATE CODE SNIPPETS FOR THE OEDEPICT DOCUMENTATION
###############################################################


def DepictMoleculesWithHighlight(smiles, ss, highlight, basefilename):

    mol = oechem.OEGraphMol()
    oechem.OESmilesToMol(mol, smiles)
    oedepict.OEPrepareDepiction(mol)
    opts = oedepict.OE2DMolDisplayOptions(220, 160, oedepict.OEScale_AutoScale)
    disp = oedepict.OE2DMolDisplay(mol, opts)

    unique = True
    for match in ss.Match(mol, unique):
        oedepict.OEAddHighlighting(disp, highlight, match)

    image = oedepict.OEImage(disp.GetWidth(), disp.GetHeight())
    oedepict.OERenderMolecule(image, disp)

    oedepict.OEWriteImage(basefilename + ".png", image)
    oedepict.OEWriteImage(basefilename + ".pdf", image)


smiles = "c1ccc2c(c1)cc(O)cn2"
ss = oechem.OESubSearch("c1ncc(O)cc1")

highlight = oedepict.OEHighlightByCogwheel(oechem.OEDarkBlue)
highlight.SetColor(oechem.OEDarkPurple)
DepictMoleculesWithHighlight(smiles, ss, highlight, "OEHighlightByCogwheel_SetColor")

highlight = oedepict.OEHighlightByCogwheel(oechem.OEDarkPurple)
highlight.SetLineWidthScale(3.0)
DepictMoleculesWithHighlight(smiles, ss, highlight, "OEHighlightByCogwheel_SetLineWidthScale")

highlight = oedepict.OEHighlightByCogwheel(oechem.OEDarkPurple)
highlight.SetStickWidthScale(5.0)
DepictMoleculesWithHighlight(smiles, ss, highlight, "OEHighlightByCogwheel_SetStickWidthScale")

highlight = oedepict.OEHighlightByCogwheel(oechem.OEDarkPurple)
highlight.SetBallRadiusScale(5.0)
DepictMoleculesWithHighlight(smiles, ss, highlight, "OEHighlightByCogwheel_SetBallRadiusScale")

highlight = oedepict.OEHighlightByCogwheel(oechem.OEDarkPurple)
highlight.SetInnerContour(False)
DepictMoleculesWithHighlight(smiles, ss, highlight, "OEHighlightByCogwheel_SetInnerContour")

highlight = oedepict.OEHighlightByCogwheel(oechem.OEDarkPurple)
highlight.SetAtomLabelMonochrome(False)
DepictMoleculesWithHighlight(smiles, ss, highlight, "OEHighlightByCogwheel_SetAtomLabelMonochrome")
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

###############################################################
# USED TO GENERATE CODE SNIPPETS FOR THE OEDEPICT DOCUMENTATION
###############################################################


def DepictMoleculesWithHighlight(smiles, ss, highlight, basefilename):

    mol = oechem.OEGraphMol()
    oechem.OESmilesToMol(mol, smiles)
    oedepict.OEPrepareDepiction(mol)
    opts = oedepict.OE2DMolDisplayOptions(220, 160, oedepict.OEScale_AutoScale)
    disp = oedepict.OE2DMolDisplay(mol, opts)

    unique = True
    for match in ss.Match(mol, unique):
        oedepict.OEAddHighlighting(disp, highlight, match)

    image = oedepict.OEImage(disp.GetWidth(), disp.GetHeight())
    oedepict.OERenderMolecule(image, disp)

    oedepict.OEWriteImage(basefilename + ".png", image)
    oedepict.OEWriteImage(basefilename + ".pdf", image)


smiles = "c1ccc2c(c1)cc(O)cn2"
ss = oechem.OESubSearch("c1ncc(O)cc1")

highlight = oedepict.OEHighlightByColor(oechem.OEDarkBlue)
highlight.SetColor(oechem.OEDarkRed)
DepictMoleculesWithHighlight(smiles, ss, highlight, "OEHighlightByColor_SetColor")

highlight = oedepict.OEHighlightByColor(oechem.OEDarkRed)
highlight.SetLineWidthScale(3.0)
DepictMoleculesWithHighlight(smiles, ss, highlight, "OEHighlightByColor_SetLineWidthScale")

highlight = oedepict.OEHighlightByColor(oechem.OELightOrange)
highlight.SetAtomExternalHighlight(True)
DepictMoleculesWithHighlight(smiles, ss, highlight, "OEHighlightByColor_SetAtomExternalHighlight")
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

###############################################################
# USED TO GENERATE CODE SNIPPETS FOR THE OEDEPICT DOCUMENTATION
###############################################################


def DepictMoleculesWithHighlight(smiles, ss, highlight, basefilename):

    mol = oechem.OEGraphMol()
    oechem.OESmilesToMol(mol, smiles)
    oedepict.OEPrepareDepiction(mol)
    opts = oedepict.OE2DMolDisplayOptions(220, 160, oedepict.OEScale_AutoScale)
    disp = oedepict.OE2DMolDisplay(mol, opts)

    unique = True
    for match in ss.Match(mol, unique):
        oedepict.OEAddHighlighting(disp, highlight, match)

    image = oedepict.OEImage(disp.GetWidth(), disp.GetHeight())
    oedepict.OERenderMolecule(image, disp)

    oedepict.OEWriteImage(basefilename + ".png", image)
    oedepict.OEWriteImage(basefilename + ".pdf", image)


smiles = "c1ccc2c(c1)cc(O)cn2"
ss = oechem.OESubSearch("c1ncc(O)cc1")

highlight = oedepict.OEHighlightByLasso(oechem.OEBlack)

highlight.SetColor(oechem.OEDarkGreen)
DepictMoleculesWithHighlight(smiles, ss, highlight, "OEHighlightByLasso_SetColor")

pen = oedepict.OEPen(oechem.OEGreenTint, oechem.OEDarkGreen,
                     oedepict.OEFill_On, 3.0, oedepict.OEStipple_Dot)
highlight.SetPen(pen)
DepictMoleculesWithHighlight(smiles, ss, highlight, "OEHighlightByLasso_SetPen")

highlight = oedepict.OEHighlightByLasso(oechem.OEDarkGreen)
highlight.SetLassoScale(6.0)
DepictMoleculesWithHighlight(smiles, ss, highlight, "OEHighlightByLasso_SetLassoScale")

highlight = oedepict.OEHighlightByLasso(oechem.OEDarkGreen)
highlight.SetAtomLabelMonochrome(False)
DepictMoleculesWithHighlight(smiles, ss, highlight, "OEHighlightByLasso_SetAtomLabelMonochrome")

highligh = oedepict.OEHighlightByLasso(oechem.OEDarkGreen)
highlight.SetConsiderAtomLabelBoundingBox(True)
DepictMoleculesWithHighlight(smiles, ss, highlight,
                             "OEHighlightByLasso_SetConsiderAtomLabelBoundingBox")

highligh = oedepict.OEHighlightByLasso(oechem.OEDarkGreen)
highlight.SetLineWidthScale(3.0)
DepictMoleculesWithHighlight(smiles, ss, highlight, "OEHighlightByLasso_SetLineWidthScale")
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

###############################################################
# USED TO GENERATE CODE SNIPPETS FOR THE OEDEPICT DOCUMENTATION
###############################################################


def DepictMoleculesWithHighlight(smiles, ss, highlight, basefilename):

    mol = oechem.OEGraphMol()
    oechem.OESmilesToMol(mol, smiles)
    oedepict.OEPrepareDepiction(mol)
    opts = oedepict.OE2DMolDisplayOptions(220, 160, oedepict.OEScale_AutoScale)
    disp = oedepict.OE2DMolDisplay(mol, opts)

    unique = True
    for match in ss.Match(mol, unique):
        oedepict.OEAddHighlighting(disp, highlight, match)

    image = oedepict.OEImage(disp.GetWidth(), disp.GetHeight())
    oedepict.OERenderMolecule(image, disp)

    oedepict.OEWriteImage(basefilename + ".png", image)
    oedepict.OEWriteImage(basefilename + ".pdf", image)


smiles = "c1ccc2c(c1)cc(O)cn2"
ss = oechem.OESubSearch("c1ncc(O)cc1")

highlight = oedepict.OEHighlightByStick(oechem.OEDarkBlue)
highlight.SetColor(oechem.OELightOrange)
DepictMoleculesWithHighlight(smiles, ss, highlight, "OEHighlightByStick_SetColor")

highlight = oedepict.OEHighlightByStick(oechem.OELightOrange)
highlight.SetStickWidthScale(5.0)
DepictMoleculesWithHighlight(smiles, ss, highlight, "OEHighlightByStick_SetStickWidthScale")

highlight = oedepict.OEHighlightByStick(oechem.OELightOrange)
highlight.SetAtomLabelMonochrome(False)
DepictMoleculesWithHighlight(smiles, ss, highlight, "OEHighlightByStick_SetAtomLabelMonochrome")

highlight = oedepict.OEHighlightByStick(oechem.OELightOrange)
highlight.SetAtomExternalHighlightRatio(0.33)
DepictMoleculesWithHighlight(smiles, ss, highlight,
                             "OEHighlightByStick_SetAtomExternalHighlightRatio")
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "c1cncc2c1cc3c(cncc3)c2")
oedepict.OEPrepareDepiction(mol)

subs = oechem.OESubSearch("c1cc[c,n]cc1")

width, height = 350, 250
image = oedepict.OEImage(width, height)

rows, cols = 2, 2
grid = oedepict.OEImageGrid(image, rows, cols)
opts = oedepict.OE2DMolDisplayOptions(grid.GetCellWidth(), grid.GetCellHeight(),
                                      oedepict.OEScale_AutoScale)

unique = True
for match, cell in zip(subs.Match(mol, unique), grid.GetCells()):
    disp = oedepict.OE2DMolDisplay(mol, opts)
    oedepict.OEAddHighlighting(disp, oechem.OEColor(oechem.OEPink),
                               oedepict.OEHighlightStyle_Color, match)
    oedepict.OERenderMolecule(cell, disp)

oedepict.OEWriteImage("HighlightMulti.png", image)
oedepict.OEWriteImage("HighlightMulti.pdf", image)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "c1cncc2c1cc3c(cncc3)c2")
oedepict.OEPrepareDepiction(mol)

subs = oechem.OESubSearch("c1cc[c,n]cc1")

opts = oedepict.OE2DMolDisplayOptions(240.0, 100.0, oedepict.OEScale_AutoScale)
opts.SetMargins(10.0)
disp = oedepict.OE2DMolDisplay(mol, opts)

highlight = oedepict.OEHighlightOverlayByBallAndStick(oechem.OEGetContrastColors())

unique = True
oedepict.OEAddHighlightOverlay(disp, highlight, subs.Match(mol, unique))

oedepict.OERenderMolecule("HighlightOverlay.png", disp)
oedepict.OERenderMolecule("HighlightOverlay.pdf", disp)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

###############################################################
# USED TO GENERATE CODE SNIPPETS FOR THE OEDEPICT DOCUMENTATION
###############################################################


def DepictMoleculesWithHighlight(smiles, ss, highlight, basefilename):

    mol = oechem.OEGraphMol()
    oechem.OESmilesToMol(mol, smiles)
    oedepict.OEPrepareDepiction(mol)

    opts = oedepict.OE2DMolDisplayOptions(250, 160, oedepict.OEScale_AutoScale)
    opts.SetTitleLocation(oedepict.OETitleLocation_Hidden)
    disp = oedepict.OE2DMolDisplay(mol, opts)

    unique = True
    oedepict.OEAddHighlightOverlay(disp, highlight, ss.Match(mol, unique))

    image = oedepict.OEImage(disp.GetWidth(), disp.GetHeight())
    oedepict.OERenderMolecule(image, disp)

    oedepict.OEWriteImage(basefilename + ".png", image)
    oedepict.OEWriteImage(basefilename + ".pdf", image)


smiles = "c1cc(cc2c1ccc(c2)O)O"
ss = oechem.OESubSearch("c1ccc(O)cc1")


highlight = oedepict.OEHighlightOverlayByBallAndStick(oechem.OEGetVividColors())
highlight.SetStickWidthScale(5.0)
DepictMoleculesWithHighlight(smiles, ss, highlight,
                             "OEHighlightOverlayByBallAndStick_SetStickWidthScale")

highlight = oedepict.OEHighlightOverlayByBallAndStick(oechem.OEGetVividColors())
highlight.SetBallRadiusScale(4.0)
DepictMoleculesWithHighlight(smiles, ss, highlight,
                             "OEHighlightOverlayByBallAndStick_SetBallRadiusScale")

highlight = oedepict.OEHighlightOverlayByBallAndStick(oechem.OEGetVividColors())
highlight.SetAtomLabelMonochrome(False)
DepictMoleculesWithHighlight(smiles, ss, highlight,
                             "OEHighlightOverlayByBallAndStick_SetAtomLabelMonochrome")
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "c1cncc2c1cc3c(cncc3)c2")
oedepict.OEPrepareDepiction(mol)

subs = oechem.OESubSearch("c1ncccc1")
disp = oedepict.OE2DMolDisplay(mol)

unique = True
for match in subs.Match(mol, unique):
    oedepict.OEAddHighlighting(disp, oechem.OEColor(oechem.OERed),
                               oedepict.OEHighlightStyle_Stick, match)

oedepict.OERenderMolecule("HighlightSimple.png", disp)
oedepict.OERenderMolecule("HighlightSimple.pdf", disp)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "c1cncc2c1cc3c(cncc3)c2")
oedepict.OEPrepareDepiction(mol)

subs = oechem.OESubSearch("c1ncccc1")

opts = oedepict.OE2DMolDisplayOptions(240.0, 100.0, oedepict.OEScale_AutoScale)
opts.SetMargins(10.0)
disp = oedepict.OE2DMolDisplay(mol, opts)

stickWidthScale = 6.0
monochrome = True
highlight = oedepict.OEHighlightByStick(oechem.OEColor(oechem.OERed),
                                        stickWidthScale, not monochrome)

unique = True
for match in subs.Match(mol, unique):
    oedepict.OEAddHighlighting(disp, highlight, match)

oedepict.OERenderMolecule("HighlightStyle.png", disp)
oedepict.OERenderMolecule("HighlightStyle.pdf", disp)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

width, height = 400, 200
image = oedepict.OEImage(width, height)

mol = oechem.OEGraphMol()
smiles = "Cc1cccnc1/C=C/[C@H](C(=O)O)O"
oechem.OESmilesToMol(mol, smiles)
oedepict.OEPrepareDepiction(mol)

opts = oedepict.OE2DMolDisplayOptions(width, height, oedepict.OEScale_AutoScale)
opts.SetMargins(10)
disp = oedepict.OE2DMolDisplay(mol, opts)

font = oedepict.OEFont(oedepict.OEFontFamily_Default, oedepict.OEFontStyle_Default, 12,
                       oedepict.OEAlignment_Center, oechem.OEDarkRed)

for adisp in disp.GetAtomDisplays():
    atom = adisp.GetAtom()
    hovertext = "atom idx=%s" % atom.GetIdx()
    oedepict.OEDrawSVGHoverText(disp, adisp, hovertext, font)

oedepict.OERenderMolecule("HoverAtomText.svg", disp)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

width, height = 400, 200
image = oedepict.OEImage(width, height)

mol = oechem.OEGraphMol()
smiles = "Cc1cccnc1/C=C/[C@H](C(=O)O)O"
oechem.OESmilesToMol(mol, smiles)
oedepict.OEPrepareDepiction(mol)

opts = oedepict.OE2DMolDisplayOptions(width, height, oedepict.OEScale_AutoScale)
opts.SetMargins(10)
disp = oedepict.OE2DMolDisplay(mol, opts)

font = oedepict.OEFont(oedepict.OEFontFamily_Default, oedepict.OEFontStyle_Default, 12,
                       oedepict.OEAlignment_Center, oechem.OEDarkRed)

for bdisp in disp.GetBondDisplays():
    bond = bdisp.GetBond()
    hovertext = "bond idx=%s" % bond.GetIdx()
    oedepict.OEDrawSVGHoverText(disp, bdisp, hovertext, font)

oedepict.OERenderMolecule("HoverBondText.svg", disp)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict


def DrawMolecule(image, mol, width, height, offset):

    frame = oedepict.OEImageFrame(image, width, height, offset)

    oedepict.OEDrawBorder(frame, oedepict.OELightGreyPen)

    opts = oedepict.OE2DMolDisplayOptions(width, height, oedepict.OEScale_AutoScale)
    disp = oedepict.OE2DMolDisplay(mol, opts)

    clearbackground = True
    oedepict.OERenderMolecule(frame, disp, not clearbackground)


image = oedepict.OEImage(400, 400)

mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "C1CC(O)CNC1")
oedepict.OEPrepareDepiction(mol)

DrawMolecule(image, mol, 60, 60, oedepict.OE2DPoint(50.0, 40.0))
DrawMolecule(image, mol, 180, 180, oedepict.OE2DPoint(180.0, 120.0))
DrawMolecule(image, mol, 80, 80, oedepict.OE2DPoint(300.0, 20.0))
DrawMolecule(image, mol, 50, 50, oedepict.OE2DPoint(150.0, 320.0))
DrawMolecule(image, mol, 20, 20, oedepict.OE2DPoint(360.0, 360.0))

oedepict.OEWriteImage("ImageFrame.png", image)
oedepict.OEWriteImage("ImageFrame.pdf", image)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

smiles = ["c1ccccc1", "c1cccc2c1ccnc2", "c1ccc2c(c1)cc3ccccc3n2"]

image = oedepict.OEImage(400, 200)

rows, cols = 1, 3
grid = oedepict.OEImageGrid(image, rows, cols)

opts = oedepict.OE2DMolDisplayOptions(grid.GetCellWidth(), grid.GetCellHeight(),
                                      oedepict.OEScale_AutoScale)

for smi, cell in zip(smiles, grid.GetCells()):
    mol = oechem.OEGraphMol()
    oechem.OESmilesToMol(mol, smi)
    oedepict.OEPrepareDepiction(mol)

    disp = oedepict.OE2DMolDisplay(mol, opts)
    oedepict.OERenderMolecule(cell, disp)

oedepict.OEWriteImage("ImageGridAutoScale.png", image)
oedepict.OEWriteImage("ImageGridAutoScale.pdf", image)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

smiles = ["c1ccccc1", "c1cccc2c1ccnc2", "c1ccc2c(c1)cc3ccccc3n2"]

molecules = []
for smi in smiles:
    mol = oechem.OEGraphMol()
    oechem.OESmilesToMol(mol, smi)
    oedepict.OEPrepareDepiction(mol)
    molecules.append(oechem.OEGraphMol(mol))

image = oedepict.OEImage(400, 200)

rows, cols = 1, 3
grid = oedepict.OEImageGrid(image, rows, cols)

opts = oedepict.OE2DMolDisplayOptions(grid.GetCellWidth(), grid.GetCellHeight(),
                                      oedepict.OEScale_AutoScale)

minscale = float("inf")
for mol in molecules:
    minscale = min(minscale, oedepict.OEGetMoleculeScale(mol, opts))

opts.SetScale(minscale)
for idx, cell in enumerate(grid.GetCells()):
    disp = oedepict.OE2DMolDisplay(molecules[idx], opts)
    oedepict.OERenderMolecule(cell, disp)

oedepict.OEWriteImage("ImageGridFixedScale.png", image)
oedepict.OEWriteImage("ImageGridFixedScale.pdf", image)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

###############################################################
# USED TO GENERATE CODE SNIPPETS FOR THE OEDEPICT DOCUMENTATION
###############################################################


def CreateGrid(image):

    rows, cols = 3, 3
    grid = oedepict.OEImageGrid(image, rows, cols)
    grid.SetCellGap(5)
    grid.SetMargins(0)

    for cell in grid.GetCells():
        oedepict.OEDrawBorder(cell, oedepict.OERedPen)

    return grid


pen = oedepict.OEPen(oechem.OEColor(225, 200, 200), oechem.OERed, oedepict.OEFill_On, 1.0)

image = oedepict.OEImage(100, 100)
image.Clear(oechem.OELightGrey)
grid = CreateGrid(image)

i = 1
for cell in grid.GetCells():
    pass
    oedepict.OEDrawBorder(cell, pen)
    font = oedepict.OEFont()
    c = oedepict.OE2DPoint(cell.GetWidth(), cell.GetHeight() + font.GetSize())
    cell.DrawText(c / 2.0, "(%d)" % i, font)
    i += 1

oedepict.OEWriteImage("ImageGridIter-all.png", image)
oedepict.OEWriteImage("ImageGridIter-all.pdf", image)


image = oedepict.OEImage(100, 100)
image.Clear(oechem.OELightGrey)
grid = CreateGrid(image)

i = 1
row = 2
for cell in grid.GetCells(row, 0):
    pass
    oedepict.OEDrawBorder(cell, pen)
    font = oedepict.OEFont()
    c = oedepict.OE2DPoint(cell.GetWidth(), cell.GetHeight() + font.GetSize())
    cell.DrawText(c / 2.0, "(%d)" % i, font)
    i += 1

oedepict.OEWriteImage("ImageGridIter-row.png", image)
oedepict.OEWriteImage("ImageGridIter-row.pdf", image)

image = oedepict.OEImage(100, 100)
image.Clear(oechem.OELightGrey)
grid = CreateGrid(image)

i = 1
col = 2
for cell in grid.GetCells(0, col):
    pass
    oedepict.OEDrawBorder(cell, pen)
    font = oedepict.OEFont()
    c = oedepict.OE2DPoint(cell.GetWidth(), cell.GetHeight() + font.GetSize())
    cell.DrawText(c / 2.0, "(%d)" % i, font)
    i += 1

oedepict.OEWriteImage("ImageGridIter-col.png", image)
oedepict.OEWriteImage("ImageGridIter-col.pdf", image)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

smiles = ["C1CC(C)CCC1", "C1CC(O)CCC1", "C1CC(Cl)CCC1"]

image = oedepict.OEImage(200, 200)

rows, cols = 2, 2
grid = oedepict.OEImageGrid(image, rows, cols)

opts = oedepict.OE2DMolDisplayOptions(grid.GetCellWidth(), grid.GetCellHeight(),
                                      oedepict.OEScale_AutoScale)

for smi, cell in zip(smiles, grid.GetCells()):
    mol = oechem.OEGraphMol()
    oechem.OESmilesToMol(mol, smi)
    oedepict.OEPrepareDepiction(mol)
    disp = oedepict.OE2DMolDisplay(mol, opts)
    oedepict.OERenderMolecule(cell, disp)

oedepict.OEWriteImage("ImageGridSimple.png", image)
oedepict.OEWriteImage("ImageGridSimple.pdf", image)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oedepict

image = oedepict.OEImage(100.0, 100.0)

image.DrawCircle(oedepict.OEGetCenter(image), 40.0, oedepict.OEBlackPen)
image.DrawText(oedepict.OEGetCenter(image), "circle", oedepict.OEDefaultFont)
oedepict.OEDrawBorder(image, oedepict.OELightGreyPen)

oedepict.OEWriteImage("image.png", image)

halfimage = oedepict.OEImage(image, 0.5)
oedepict.OEWriteImage("halfimage.png", halfimage)

doubleimage = oedepict.OEImage(image, 2.0)
oedepict.OEWriteImage("doubleimage.png", doubleimage)

oedepict.OEWriteImage("image.pdf", image)
oedepict.OEWriteImage("halfimage.pdf", halfimage)
oedepict.OEWriteImage("doubleimage.pdf", doubleimage)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

smiles = ["c1ccccc1 benzene", "c1cccnc1 pyridine", "c1cncnc1 pyrimidine"]

imagewidth, imageheight = 350, 250
image = oedepict.OEImage(imagewidth, imageheight)

mainrows, maincols = 3, 2
maintableopts = oedepict.OEImageTableOptions(mainrows, maincols, oedepict.OEImageTableStyle_NoStyle)
maintableopts.SetHeader(False)
maintableopts.SetColumnWidths([10, 20])
maintable = oedepict.OEImageTable(image, maintableopts)

datarows, datacols = 4, 2
datatableopts = oedepict.OEImageTableOptions(datarows, datacols,
                                             oedepict.OEImageTableStyle_LightGreen)
datatableopts.SetStubColumn(True)
datatableopts.SetMargins(5.0)
datatableopts.SetColumnWidths([10, 20])

for r in range(min(len(smiles), maintable.NumRows())):
    # depict molecule in first column
    cell = maintable.GetBodyCell(r + 1, 1)

    opts = oedepict.OE2DMolDisplayOptions(cell.GetWidth(), cell.GetHeight(),
                                          oedepict.OEScale_AutoScale)
    opts.SetTitleLocation(oedepict.OETitleLocation_Hidden)

    mol = oechem.OEGraphMol()
    oechem.OESmilesToMol(mol, smiles[r])
    oedepict.OEPrepareDepiction(mol)

    disp = oedepict.OE2DMolDisplay(mol, opts)
    oedepict.OERenderMolecule(cell, disp)

    # depicting data in table
    cell = maintable.GetBodyCell(r + 1, 2)

    table = oedepict.OEImageTable(cell, datatableopts)

    table.DrawText(table.GetHeaderCell(1, False), "Property")
    table.DrawText(table.GetHeaderCell(1), "Value")

    table.DrawText(table.GetStubColumnCell(1), "Name")
    table.DrawText(table.GetBodyCell(1, 1), mol.GetTitle())

    table.DrawText(table.GetStubColumnCell(2), "SMILES")
    table.DrawText(table.GetBodyCell(2, 1), oechem.OEMolToSmiles(mol))

    table.DrawText(table.GetStubColumnCell(3), "MV")
    table.DrawText(table.GetBodyCell(3, 1), "%.3f" % oechem.OECalculateMolecularWeight(mol))

oedepict.OEWriteImage("ImageTable.png", image)
oedepict.OEWriteImage("ImageTable.pdf", image)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

imagewidth, imageheight = 350, 250
image = oedepict.OEImage(imagewidth, imageheight)

mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "c1cccnc1O")
oedepict.OEPrepareDepiction(mol)
oedepict.OERenderMolecule(image, mol)

opts = oedepict.OELegendLayoutOptions(oedepict.OELegendLayoutStyle_VerticalTopRight,
                                      oedepict.OELegendColorStyle_LightGreen,
                                      oedepict.OELegendInteractiveStyle_Toggle)
opts.SetButtonWidthScale(1.5)
opts.SetButtonHeightScale(1.5)
legend = oedepict.OELegendLayout(image, "Legend", opts)

legend_area = legend.GetLegendArea()
oedepict.OEAddWatermark(legend_area, "This is the legend area")
oedepict.OEAddInteractiveIcon(image, oedepict.OEIconLocation_BottomRight, 0.75)
oedepict.OEDrawLegendLayout(legend)

oedepict.OEWriteImage("LegendLayout.svg", image)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

refmol = oechem.OEGraphMol()
oechem.OESmilesToMol(refmol, "c1cc(c2cc(cnc2c1)CCCO)C(=O)CCO")
oedepict.OEPrepareDepiction(refmol)

fitmol = oechem.OEGraphMol()
oechem.OESmilesToMol(fitmol, "c1cc2ccc(cc2c(c1)C(=O)O)CCO")
oedepict.OEPrepareDepiction(fitmol)

mcss = oechem.OEMCSSearch(oechem.OEMCSType_Approximate)
atomexpr = oechem.OEExprOpts_DefaultAtoms
bondexpr = oechem.OEExprOpts_DefaultBonds
mcss.Init(refmol, atomexpr, bondexpr)
mcss.SetMCSFunc(oechem.OEMCSMaxBondsCompleteCycles())

alignres = oedepict.OEPrepareAlignedDepiction(fitmol, mcss)

image = oedepict.OEImage(400, 200)

rows, cols = 1, 2
grid = oedepict.OEImageGrid(image, rows, cols)

opts = oedepict.OE2DMolDisplayOptions(grid.GetCellWidth(), grid.GetCellHeight(),
                                      oedepict.OEScale_AutoScale)
opts.SetTitleLocation(oedepict.OETitleLocation_Hidden)

refscale = oedepict.OEGetMoleculeScale(refmol, opts)
fitscale = oedepict.OEGetMoleculeScale(fitmol, opts)
opts.SetScale(min(refscale, fitscale))

refdisp = oedepict.OE2DMolDisplay(mcss.GetPattern(), opts)
fitdisp = oedepict.OE2DMolDisplay(fitmol, opts)

if alignres.IsValid():
    refabset = oechem.OEAtomBondSet(alignres.GetPatternAtoms(), alignres.GetPatternBonds())
    oedepict.OEAddHighlighting(refdisp, oechem.OEBlueTint,
                               oedepict.OEHighlightStyle_BallAndStick, refabset)

    fitabset = oechem.OEAtomBondSet(alignres.GetTargetAtoms(), alignres.GetTargetBonds())
    oedepict.OEAddHighlighting(fitdisp, oechem.OEBlueTint,
                               oedepict.OEHighlightStyle_BallAndStick, fitabset)

refcell = grid.GetCell(1, 1)
oedepict.OERenderMolecule(refcell, refdisp)

fitcell = grid.GetCell(1, 2)
oedepict.OERenderMolecule(fitcell, fitdisp)

oedepict.OEWriteImage("MCSAlign.png", image)
oedepict.OEWriteImage("MCSAlign.pdf", image)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

refmol = oechem.OEGraphMol()
oechem.OESmilesToMol(refmol, "c1cc(c2cc(cnc2c1)CCCO)C(=O)CCO")
oedepict.OEPrepareDepiction(refmol)

fitmol = oechem.OEGraphMol()
oechem.OESmilesToMol(fitmol, "c1cc2ccc(cc2c(c1)C(=O)O)CCO")
oedepict.OEPrepareDepiction(fitmol)

mcss = oechem.OEMCSSearch(oechem.OEMCSType_Approximate)
atomexpr = oechem.OEExprOpts_DefaultAtoms
bondexpr = oechem.OEExprOpts_DefaultBonds
mcss.Init(refmol, atomexpr, bondexpr)
mcss.SetMCSFunc(oechem.OEMCSMaxBondsCompleteCycles())

image = oedepict.OEImage(400, 200)

rows = 1
cols = 2
grid = oedepict.OEImageGrid(image, rows, cols)

opts = oedepict.OE2DMolDisplayOptions(grid.GetCellWidth(),
                                      grid.GetCellHeight(), oedepict.OEScale_AutoScale)
opts.SetTitleLocation(oedepict.OETitleLocation_Hidden)

refscale = oedepict.OEGetMoleculeScale(refmol, opts)
fitscale = oedepict.OEGetMoleculeScale(fitmol, opts)
opts.SetScale(min(refscale, fitscale))

refdisp = oedepict.OE2DMolDisplay(mcss.GetPattern(), opts)
fitdisp = oedepict.OE2DMolDisplay(fitmol, opts)

unique = True
miter = mcss.Match(fitmol, unique)
if miter.IsValid():
    match = miter.Target()

    abset = oechem.OEAtomBondSet(match.GetPatternAtoms(), match.GetPatternBonds())
    oedepict.OEAddHighlighting(refdisp, oechem.OEBlueTint,
                               oedepict.OEHighlightStyle_BallAndStick, abset)

    abset = oechem.OEAtomBondSet(match.GetTargetAtoms(), match.GetTargetBonds())
    oedepict.OEAddHighlighting(fitdisp, oechem.OEBlueTint,
                               oedepict.OEHighlightStyle_BallAndStick, abset)

refcell = grid.GetCell(1, 1)
oedepict.OERenderMolecule(refcell, refdisp)

fitcell = grid.GetCell(1, 2)
oedepict.OERenderMolecule(fitcell, fitdisp)

oedepict.OEWriteImage("MCSNoAlignment.png", image)
oedepict.OEWriteImage("MCSNoAlignment.pdf", image)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

smiles = ["C1CC(C)CCC1", "C1CC(O)CCC1", "C1CC(Cl)CCC1",
          "C1CC(F)CCC1", "C1CC(Br)CCC1", "C1CC(N)CCC1"]


multi = oedepict.OEMultiPageImageFile(oedepict.OEPageOrientation_Landscape,
                                      oedepict.OEPageSize_US_Letter)
image = multi.NewPage()

opts = oedepict.OE2DMolDisplayOptions()

rows, cols = 2, 2
grid = oedepict.OEImageGrid(image, rows, cols)
grid.SetCellGap(20)
grid.SetMargins(20)
citer = grid.GetCells()

for smi in smiles:
    if not citer.IsValid():
        # go to next page
        image = multi.NewPage()
        grid = oedepict.OEImageGrid(image, rows, cols)
        grid.SetCellGap(20)
        grid.SetMargins(20)
        citer = grid.GetCells()

    cell = citer.Target()
    mol = oechem.OEGraphMol()
    oechem.OESmilesToMol(mol, smi)
    oedepict.OEPrepareDepiction(mol)
    opts.SetDimensions(cell.GetWidth(), cell.GetHeight(), oedepict.OEScale_AutoScale)
    disp = oedepict.OE2DMolDisplay(mol, opts)
    oedepict.OERenderMolecule(cell, disp)
    oedepict.OEDrawBorder(cell, oedepict.OEPen(oedepict.OERedPen))
    citer.Next()

oedepict.OEWriteMultiPageImage("MultiPage.pdf", multi)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

smiles = ["C1CC(C)CCC1", "C1CC(O)CCC1", "C1CC(Cl)CCC1",
          "C1CC(F)CCC1", "C1CC(Br)CCC1", "C1CC(N)CCC1"]

rows, cols = 2, 2
reportopts = oedepict.OEReportOptions(rows, cols)
reportopts.SetPageOrientation(oedepict.OEPageOrientation_Landscape)
reportopts.SetCellGap(20)
reportopts.SetPageMargins(20)
report = oedepict.OEReport(reportopts)

opts = oedepict.OE2DMolDisplayOptions(report.GetCellWidth(),
                                      report.GetCellHeight(), oedepict.OEScale_AutoScale)

for smi in smiles:
    mol = oechem.OEGraphMol()
    oechem.OESmilesToMol(mol, smi)
    oedepict.OEPrepareDepiction(mol)

    cell = report.NewCell()
    disp = oedepict.OE2DMolDisplay(mol, opts)
    oedepict.OERenderMolecule(cell, disp)
    oedepict.OEDrawBorder(cell, oedepict.OERedPen)

oedepict.OEWriteReport("MultiPageReport.pdf", report)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

###############################################################
# USED TO GENERATE CODE SNIPPETS FOR THE OEDEPICT DOCUMENTATION
###############################################################


def DepictMolecules(opts, smiles, basefilename, drawborder=False):

    mol = oechem.OEGraphMol()
    oechem.OESmilesToMol(mol, smiles)
    oedepict.OEPrepareDepiction(mol)

    disp = oedepict.OE2DMolDisplay(mol, opts)
    image = oedepict.OEImage(disp.GetWidth(), disp.GetHeight())
    oedepict.OERenderMolecule(image, disp)

    if drawborder:
        oedepict.OEDrawBorder(image, oedepict.OELightGreyPen)

    oedepict.OEWriteImage(basefilename + ".png", image)
    oedepict.OEWriteImage(basefilename + ".pdf", image)


smiles = "Cc1cccnc1/C=C/[C@H](C(=O)O)O title"
smiles_pgroup = "c1ccc(cc1)COC(=O)C(CCOC2CCCCO2)N title"

opts = oedepict.OE2DMolDisplayOptions()
DepictMolecules(opts, smiles, "OE2DMolDisplayOptions_Default")


########################################################################
# AROMATIC
########################################################################

width, height, scale = 300.0, 200.0, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
opts.SetAromaticStyle(oedepict.OEAromaticStyle_Circle)
DepictMolecules(opts, smiles, "OE2DMolDisplayOptions_SetAromaticStyle")

########################################################################
# ATOM
########################################################################

width, height, scale = 300.0, 200.0, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
opts.SetAtomColor(oechem.OEElemNo_O, oechem.OEColor(80, 0, 0))  # very dark red
opts.SetAtomColor(oechem.OEElemNo_N, oechem.OEColor(0, 0, 80))  # very dark blue
DepictMolecules(opts, smiles, "OE2DMolDisplayOptions_SetAtomColor")

width, height, scale = 300.0, 200.0, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
opts.SetAtomColorStyle(oedepict.OEAtomColorStyle_BlackMonochrome)
DepictMolecules(opts, smiles, "OE2DMolDisplayOptions_SetAtomColorStyle")

width, height, scale = 300.0, 200.0, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
font = oedepict.OEFont()
font.SetFamily(oedepict.OEFontFamily_Courier)
font.SetStyle(oedepict.OEFontStyle_Bold)
opts.SetAtomLabelFont(font)
DepictMolecules(opts, smiles, "OE2DMolDisplayOptions_SetAtomLabelFont")

width, height, scale = 300.0, 200.0, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
opts.SetAtomLabelFontScale(1.5)
DepictMolecules(opts, smiles, "OE2DMolDisplayOptions_SetAtomLabelFontScale")

width, height, scale = 300.0, 200.0, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
font = oedepict.OEFont()
font.SetStyle(oedepict.OEFontStyle_Bold)
font.SetColor(oechem.OEDarkGreen)
opts.SetAtomPropLabelFont(font)
opts.SetAtomPropertyFunctor(oedepict.OEDisplayAtomIdx())
DepictMolecules(opts, smiles, "OE2DMolDisplayOptions_SetAtomPropLabelFont")

width, height, scale = 300.0, 200.0, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
opts.SetAtomPropertyFunctor(oedepict.OEDisplayAtomIdx())
DepictMolecules(opts, smiles, "OE2DMolDisplayOptions_SetAtomPropertyFunctor")

width, height, scale = 300.0, 200.0, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
opts.SetAtomPropLabelFontScale(1.5)
opts.SetAtomPropertyFunctor(oedepict.OEDisplayAtomIdx())
DepictMolecules(opts, smiles, "OE2DMolDisplayOptions_SetAtomPropLabelFontScale")

width, height, scale = 300.0, 200.0, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
opts.SetAtomStereoStyle(oedepict.OEAtomStereoStyle_Display_All |
                        oedepict.OEAtomStereoStyle_HashWedgeStyle_Standard)
DepictMolecules(opts, smiles, "OE2DMolDisplayOptions_SetAtomStereoStyle")

width, height, scale = 300.0, 200.0, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
opts.SetAtomVisibilityFunctor(oechem.OEAtomIsInRing())
DepictMolecules(opts, smiles, "OE2DMolDisplayOptions_SetAtomVisibilityFunctor")

########################################################################
# BACKGROUND
########################################################################

width, height, scale = 300.0, 200.0, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
opts.SetBackgroundColor(oechem.OEYellowTint)
DepictMolecules(opts, smiles, "OE2DMolDisplayOptions_SetBackgroundColor")

########################################################################
# BOND
########################################################################

width, height, scale = 300.0, 200.0, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
opts.SetBondColorStyle(oedepict.OEBondColorStyle_Monochrome)
DepictMolecules(opts, smiles, "OE2DMolDisplayOptions_SetBondColorStyle")

width, height, scale = 300.0, 200.0, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
font = oedepict.OEFont()
font.SetStyle(oedepict.OEFontStyle_Bold)
font.SetColor(oechem.OEDarkGreen)
opts.SetBondPropLabelFont(font)
opts.SetBondPropertyFunctor(oedepict.OEDisplayBondIdx())
DepictMolecules(opts, smiles, "OE2DMolDisplayOptions_SetBondPropLabelFont")

width, height, scale = 300.0, 200.0, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
opts.SetBondPropertyFunctor(oedepict.OEDisplayBondIdx())
DepictMolecules(opts, smiles, "OE2DMolDisplayOptions_SetBondPropertyFunctor")

width, height, scale = 300.0, 200.0, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
opts.SetBondPropLabelFontScale(1.5)
opts.SetBondPropertyFunctor(oedepict.OEDisplayBondIdx())
DepictMolecules(opts, smiles, "OE2DMolDisplayOptions_SetBondPropLabelFontScale")

width, height, scale = 300.0, 200.0, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
opts.SetBondStereoStyle(oedepict.OEBondStereoStyle_Display_All)
DepictMolecules(opts, smiles, "OE2DMolDisplayOptions_SetBondStereoStyle")

width, height, scale = 300.0, 200.0, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
pen = oedepict.OEPen(oechem.OEBlack, oechem.OEBlack, oedepict.OEFill_On, 5.0)
opts.SetDefaultBondPen(pen)
DepictMolecules(opts, smiles, "OE2DMolDisplayOptions_SetDefaultBondPen")

width, height, scale = 300.0, 200.0, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
opts.SetBondLineGapScale(0.5)
DepictMolecules(opts, smiles, "OE2DMolDisplayOptions_SetBondLineGapScale")

width, height, scale = 300.0, 200.0, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
opts.SetBondLineAtomLabelGapScale(2.0)
DepictMolecules(opts, smiles, "OE2DMolDisplayOptions_SetBondLineAtomLabelGapScale")

width, height, scale = 300.0, 200.0, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
opts.SetBondWidthScaling(True)
DepictMolecules(opts, smiles, "OE2DMolDisplayOptions_SetBondWidthScaling")

########################################################################
#
########################################################################

width, height, scale = 300.0, 200.0, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
opts.SetHydrogenStyle(oedepict.OEHydrogenStyle_ImplicitTerminal)
DepictMolecules(opts, smiles, "OE2DMolDisplayOptions_SetHydrogenStyle")

########################################################################
# SUPER ATOMS
########################################################################

width, height, scale = 300.0, 200.0, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
font = oedepict.OEFont()
font.SetColor(oechem.OEDarkRed)
opts.SetSuperAtomLabelFont(font)
opts.SetSuperAtomStyle(oedepict.OESuperAtomStyle_All)
DepictMolecules(opts, smiles, "OE2DMolDisplayOptions_SetSuperAtomLabelFont")

width, height, scale = 300.0, 200.0, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
opts.SetSuperAtomStyle(oedepict.OESuperAtomStyle_All)
DepictMolecules(opts, smiles, "OE2DMolDisplayOptions_SetSuperAtomStyle")

########################################################################
# PROTECTIVE GROUP
########################################################################

width, height, scale = 300.0, 200.0, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
font = oedepict.OEFont()
font.SetColor(oechem.OEDarkRed)
opts.SetProtectiveGroupLabelFont(font)
opts.SetProtectiveGroupStyle(oedepict.OEProtectiveGroupStyle_All)
DepictMolecules(opts, smiles_pgroup, "OE2DMolDisplayOptions_SetProtectiveGroupLabelFont")

width, height, scale = 300.0, 200.0, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
opts.SetProtectiveGroupStyle(oedepict.OEProtectiveGroupStyle_All)
DepictMolecules(opts, smiles_pgroup, "OE2DMolDisplayOptions_SetProtectiveGroupStyle")

########################################################################
# TITLE
########################################################################

width, height, scale = 300.0, 200.0, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
font = oedepict.OEFont()
font.SetStyle(oedepict.OEFontStyle_Bold)
font.SetColor(oechem.OEDarkBrown)
opts.SetTitleFont(font)
DepictMolecules(opts, smiles, "OE2DMolDisplayOptions_SetTitleFont")

width, height, scale = 300.0, 200.0, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
opts.SetTitleLocation(oedepict.OETitleLocation_Bottom)
DepictMolecules(opts, smiles, "OE2DMolDisplayOptions_SetTitleLocation")

width, height, scale = 300.0, 200.0, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
opts.SetTitleHeight(20.0)
DepictMolecules(opts, smiles, "OE2DMolDisplayOptions_SetTitleHeight")

width, height, scale = 300.0, 200.0, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
opts.SetTitleFontScale(0.5)
DepictMolecules(opts, smiles, "OE2DMolDisplayOptions_SetTitleFontScale")

########################################################################
# LAYOUT
########################################################################

drawborder = True

opts = oedepict.OE2DMolDisplayOptions()
opts.SetHeight(150.0)
DepictMolecules(opts, smiles, "OE2DMolDisplayOptions_SetHeight", drawborder)

opts = oedepict.OE2DMolDisplayOptions()
opts.SetWidth(150.0)
DepictMolecules(opts, smiles, "OE2DMolDisplayOptions_SetWidth", drawborder)

opts = oedepict.OE2DMolDisplayOptions()
opts.SetScale(20.0)
DepictMolecules(opts, smiles, "OE2DMolDisplayOptions_SetScale", drawborder)

opts = oedepict.OE2DMolDisplayOptions()
width, height, scale = 300.0, 300.0, 20.0
opts.SetDimensions(width, height, scale)
DepictMolecules(opts, smiles, "OE2DMolDisplayOptions_SetDimensions", drawborder)

width, height, scale = 240.0, 180.0, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
opts.SetMargin(oedepict.OEMargin_Bottom, 25.0)
DepictMolecules(opts, smiles, "OE2DMolDisplayOptions_SetMargin", drawborder)

width, height, scale = 240.0, 180.0, oedepict.OEScale_AutoScale
opts = oedepict.OE2DMolDisplayOptions(width, height, scale)
opts.SetMargins(25.0)
DepictMolecules(opts, smiles, "OE2DMolDisplayOptions_SetMargins", drawborder)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

###############################################################
# USED TO GENERATE CODE SNIPPETS FOR THE OEDEPICT DOCUMENTATION
###############################################################


class Pred6MemAromAtom(oechem.OEUnaryAtomPred):
    def __call__(self, atom):
        return atom.IsAromatic() and oechem.OEAtomIsInAromaticRingSize(atom, 6)


class Pred6MemAromBond(oechem.OEUnaryBondPred):
    def __call__(self, bond):
        return bond.IsAromatic() and oechem.OEBondIsInAromaticRingSize(bond, 6)


def OEAddHighlighting_Predicate(disp):
    highlightstyle = oedepict.OEHighlightByBallAndStick(oechem.OELightGreen)
    oedepict.OEAddHighlighting(disp, highlightstyle, Pred6MemAromAtom())
    oedepict.OEAddHighlighting(disp, highlightstyle, Pred6MemAromBond())


def OEAddHighlighting_AtomAndBondPredicate(disp):
    highlightstyle = oedepict.OEHighlightByBallAndStick(oechem.OELightGreen)
    oedepict.OEAddHighlighting(disp, highlightstyle, Pred6MemAromAtom(), Pred6MemAromBond())


def OEAddHighlighting_OEMatch(disp):
    subs = oechem.OESubSearch("a1aaaaa1")
    unique = True
    highlightstyle = oedepict.OEHighlightByBallAndStick(oechem.OELightGreen)
    for match in subs.Match(disp.GetMolecule(), unique):
        oedepict.OEAddHighlighting(disp, highlightstyle, match)


def OEAddHighlighting_OEAtomBondSet(disp):
    mol = disp.GetMolecule()
    abset = oechem.OEAtomBondSet(mol.GetAtoms(Pred6MemAromAtom()),
                                 mol.GetBonds(Pred6MemAromBond()))

    highlightstyle = oedepict.OEHighlightByBallAndStick(oechem.OELightGreen)
    oedepict.OEAddHighlighting(disp, highlightstyle, abset)


def OEAddHighlighting_OESubSearch(disp):
    subsearch = oechem.OESubSearch("a1aaaaa1")
    highlightstyle = oedepict.OEHighlightByBallAndStick(oechem.OELightGreen)
    oedepict.OEAddHighlighting(disp, highlightstyle, subsearch)

########################################################################
#
########################################################################


mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "c1ccnc2c1[nH]c3c2cccc3")
oedepict.OEPrepareDepiction(mol)

width, height = 250, 180
opts = oedepict.OE2DMolDisplayOptions(width, height, oedepict.OEScale_AutoScale)
opts.SetTitleLocation(oedepict.OETitleLocation_Hidden)

disp = oedepict.OE2DMolDisplay(mol, opts)
OEAddHighlighting_Predicate(disp)
oedepict.OERenderMolecule("OEAddHighlighting-OEHighlightBase-Predicate.png", disp)
oedepict.OERenderMolecule("OEAddHighlighting-OEHighlightBase-Predicate.pdf", disp)

disp = oedepict.OE2DMolDisplay(mol, opts)
OEAddHighlighting_AtomAndBondPredicate(disp)
oedepict.OERenderMolecule("OEAddHighlighting-OEHighlightBase-AtomAndBondPredicate.png", disp)
oedepict.OERenderMolecule("OEAddHighlighting-OEHighlightBase-AtomAndBondPredicate.pdf", disp)

disp = oedepict.OE2DMolDisplay(mol, opts)
OEAddHighlighting_OEMatch(disp)
oedepict.OERenderMolecule("OEAddHighlighting-OEHighlightBase-OEMatch.png", disp)
oedepict.OERenderMolecule("OEAddHighlighting-OEHighlightBase-OEMatch.pdf", disp)

disp = oedepict.OE2DMolDisplay(mol, opts)
OEAddHighlighting_OEAtomBondSet(disp)
oedepict.OERenderMolecule("OEAddHighlighting-OEHighlightBase-OEAtomBondSet.png", disp)
oedepict.OERenderMolecule("OEAddHighlighting-OEHighlightBase-OEAtomBondSet.pdf", disp)

disp = oedepict.OE2DMolDisplay(mol, opts)
OEAddHighlighting_OESubSearch(disp)
oedepict.OERenderMolecule("OEAddHighlighting-OEHighlightBase-OESubSearch.png", disp)
oedepict.OERenderMolecule("OEAddHighlighting-OEHighlightBase-OESubSearch.pdf", disp)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

###############################################################
# USED TO GENERATE CODE SNIPPETS FOR THE OEDEPICT DOCUMENTATION
###############################################################


class Pred6MemAromAtom(oechem.OEUnaryAtomPred):
    def __call__(self, atom):
        return atom.IsAromatic() and oechem.OEAtomIsInAromaticRingSize(atom, 6)


class Pred6MemAromBond(oechem.OEUnaryBondPred):
    def __call__(self, bond):
        return bond.IsAromatic() and oechem.OEBondIsInAromaticRingSize(bond, 6)


def OEAddHighlighting_Predicate(disp):
    oedepict.OEAddHighlighting(disp, oechem.OEDarkGreen,
                               oedepict.OEHighlightStyle_Color, Pred6MemAromAtom())
    oedepict.OEAddHighlighting(disp, oechem.OEDarkGreen,
                               oedepict.OEHighlightStyle_Color, Pred6MemAromBond())


def OEAddHighlighting_AtomAndBondPredicate(disp):
    oedepict.OEAddHighlighting(disp, oechem.OEDarkGreen, oedepict.OEHighlightStyle_Color,
                               Pred6MemAromAtom(), Pred6MemAromBond())


def OEAddHighlighting_OEMatch(disp):
    subs = oechem.OESubSearch("a1aaaaa1")
    unique = True
    for match in subs.Match(disp.GetMolecule(), unique):
        oedepict.OEAddHighlighting(disp, oechem.OEDarkGreen, oedepict.OEHighlightStyle_Color, match)


def OEAddHighlighting_OEAtomBondSet(disp):
    abset = oechem.OEAtomBondSet(mol.GetAtoms(Pred6MemAromAtom()),
                                 mol.GetBonds(Pred6MemAromBond()))

    oedepict.OEAddHighlighting(disp, oechem.OEDarkGreen, oedepict.OEHighlightStyle_Color, abset)


def OEAddHighlighting_OESubSearch(disp):
    subsearch = oechem.OESubSearch("a1aaaaa1")
    oedepict.OEAddHighlighting(disp, oechem.OEDarkGreen, oedepict.OEHighlightStyle_Color, subsearch)


########################################################################
#
########################################################################

mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "c1ccnc2c1[nH]c3c2cccc3")
oedepict.OEPrepareDepiction(mol)

width, height = 250, 180
opts = oedepict.OE2DMolDisplayOptions(width, height, oedepict.OEScale_AutoScale)
opts.SetTitleLocation(oedepict.OETitleLocation_Hidden)

disp = oedepict.OE2DMolDisplay(mol, opts)
OEAddHighlighting_Predicate(disp)
oedepict.OERenderMolecule("OEAddHighlighting-OEHighlightStyle-Predicate.png", disp)
oedepict.OERenderMolecule("OEAddHighlighting-OEHighlightStyle-Predicate.pdf", disp)

disp = oedepict.OE2DMolDisplay(mol, opts)
OEAddHighlighting_AtomAndBondPredicate(disp)
oedepict.OERenderMolecule("OEAddHighlighting-OEHighlightStyle-AtomAndBondPredicate.png", disp)
oedepict.OERenderMolecule("OEAddHighlighting-OEHighlightStyle-AtomAndBondPredicate.pdf", disp)

disp = oedepict.OE2DMolDisplay(mol, opts)
OEAddHighlighting_OEMatch(disp)
oedepict.OERenderMolecule("OEAddHighlighting-OEHighlightStyle-OEMatch.png", disp)
oedepict.OERenderMolecule("OEAddHighlighting-OEHighlightStyle-OEMatch.pdf", disp)

disp = oedepict.OE2DMolDisplay(mol, opts)
OEAddHighlighting_OEAtomBondSet(disp)
oedepict.OERenderMolecule("OEAddHighlighting-OEHighlightStyle-OEAtomBondSet.png", disp)
oedepict.OERenderMolecule("OEAddHighlighting-OEHighlightStyle-OEAtomBondSet.pdf", disp)

disp = oedepict.OE2DMolDisplay(mol, opts)
OEAddHighlighting_OESubSearch(disp)
oedepict.OERenderMolecule("OEAddHighlighting-OEHighlightStyle-OESubSearch.png", disp)
oedepict.OERenderMolecule("OEAddHighlighting-OEHighlightStyle-OESubSearch.pdf", disp)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

###############################################################
# USED TO GENERATE CODE SNIPPETS FOR THE OEDEPICT DOCUMENTATION
###############################################################


def OEAddLabel_Predicate(disp):
    ringhighlight = oedepict.OEHighlightByBallAndStick(oechem.OELightGreen)
    oedepict.OEAddHighlighting(disp, ringhighlight,
                               oechem.OEAtomIsInRing(), oechem.OEBondIsInRing())
    ringlabel = oedepict.OEHighlightLabel("ring", oechem.OELightGreen)
    oedepict.OEAddLabel(disp, ringlabel, oechem.OEAtomIsInRing())

    chainhighlight = oedepict.OEHighlightByBallAndStick(oechem.OEBlueTint)
    oedepict.OEAddHighlighting(disp, chainhighlight,
                               oechem.OEAtomIsInChain(), oechem.OEBondIsInChain())
    chainlabel = oedepict.OEHighlightLabel("chain", oechem.OEBlueTint)
    oedepict.OEAddLabel(disp, chainlabel, oechem.OEAtomIsInChain())


def OEAddLabel_OEMatch(disp):
    subs = oechem.OESubSearch("a1aaaaa1")
    unique = True
    highlightstyle = oedepict.OEHighlightByBallAndStick(oechem.OELightGreen)
    for match in subs.Match(disp.GetMolecule(), unique):
        oedepict.OEAddHighlighting(disp, highlightstyle, match)
        label = oedepict.OEHighlightLabel("aromatic", oechem.OELightGreen)
        oedepict.OEAddLabel(disp, label, match)


def OEAddLabel_OEAtomBondSet(disp):
    mol = disp.GetMolecule()

    ringset = oechem.OEAtomBondSet(mol.GetAtoms(oechem.OEAtomIsInRing()),
                                   mol.GetBonds(oechem.OEBondIsInRing()))
    ringhighlight = oedepict.OEHighlightByBallAndStick(oechem.OELightGreen)
    oedepict.OEAddHighlighting(disp, ringhighlight, ringset)
    ringlabel = oedepict.OEHighlightLabel("ring", oechem.OELightGreen)
    oedepict.OEAddLabel(disp, ringlabel, ringset)

    chainset = oechem.OEAtomBondSet(mol.GetAtoms(oechem.OEAtomIsInChain()),
                                    mol.GetBonds(oechem.OEBondIsInChain()))
    chainhighlight = oedepict.OEHighlightByBallAndStick(oechem.OEBlueTint)
    oedepict.OEAddHighlighting(disp, chainhighlight, chainset)
    chainlabel = oedepict.OEHighlightLabel("chain", oechem.OEBlueTint)
    oedepict.OEAddLabel(disp, chainlabel, chainset)


def OEAddLabel_OEImage(image):

    label = oedepict.OEHighlightLabel("Hello!")
    oedepict.OEAddLabel(image, oedepict.OE2DPoint(50, 50), label)

    label.SetBoundingBoxPen(oedepict.OETransparentPen)
    oedepict.OEAddLabel(image, oedepict.OE2DPoint(100, 50), label)

    label.SetBoundingBoxPen(oedepict.OELightGreyPen)
    oedepict.OEAddLabel(image, oedepict.OE2DPoint(150, 50), label)

########################################################################
#
########################################################################


mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "CC(=O)C1Cc2ccccc2N1")
oedepict.OEPrepareDepiction(mol)

width, height = 250, 180
opts = oedepict.OE2DMolDisplayOptions(width, height, oedepict.OEScale_AutoScale)
opts.SetTitleLocation(oedepict.OETitleLocation_Hidden)

disp = oedepict.OE2DMolDisplay(mol, opts)
OEAddLabel_Predicate(disp)
oedepict.OERenderMolecule("OEAddLabel-Predicate.png", disp)
oedepict.OERenderMolecule("OEAddLabel-Predicate.pdf", disp)

disp = oedepict.OE2DMolDisplay(mol, opts)
OEAddLabel_OEMatch(disp)
oedepict.OERenderMolecule("OEAddLabel-OEMatch.png", disp)
oedepict.OERenderMolecule("OEAddLabel-OEMatch.pdf", disp)

disp = oedepict.OE2DMolDisplay(mol, opts)
OEAddLabel_OEAtomBondSet(disp)
oedepict.OERenderMolecule("OEAddLabel-OEAtomBondSet.png", disp)
oedepict.OERenderMolecule("OEAddLabel-OEAtomBondSet.pdf", disp)

image = oedepict.OEImage(200, 100)
OEAddLabel_OEImage(image)
oedepict.OEWriteImage("OEAddLabel-OEImageBase.png", image)
oedepict.OEWriteImage("OEAddLabel-OEImageBase.pdf", image)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "C1CCC2C/C=C/CCCC2C1")
oedepict.OEPrepareDepiction(mol)

width, height = 200, 200
opts = oedepict.OE2DMolDisplayOptions(width, height, oedepict.OEScale_AutoScale)
disp = oedepict.OE2DMolDisplay(mol, opts)
oedepict.OEAnnotateDepictionProblems(disp)

oedepict.OERenderMolecule("OEAnnotateDepictionProblems.png", disp)
oedepict.OERenderMolecule("OEAnnotateDepictionProblems.pdf", disp)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "C[N+](=C)(C)C1CCCCl1")
oedepict.OEPrepareDepiction(mol)

width, height = 200, 200
opts = oedepict.OE2DMolDisplayOptions(width, height, oedepict.OEScale_AutoScale)
disp = oedepict.OE2DMolDisplay(mol, opts)
oedepict.OEAnnotateValenceProblems(disp)

oedepict.OERenderMolecule("OEAnnotateValenceProblems.png", disp)
oedepict.OERenderMolecule("OEAnnotateValenceProblems.pdf", disp)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict
import sys

###############################################################
# USED TO GENERATE CODE SNIPPETS FOR THE OEDEPICT DOCUMENTATION
###############################################################


def main(argv=[__name__]):

    itf = oechem.OEInterface()
    oedepict.OEConfigureColor(itf, "mycolor", "c", "Example of using OEConfigureColor", "blue")

    if oechem.OECheckHelp(itf, argv):
        return True

    if not oechem.OEParseCommandLine(itf, argv):
        oechem.OEThrow.Fatal("Unable to interpret command line!")

    color = oechem.OEGetColor(itf, "mycolor")
    print(str(color))


if __name__ == "__main__":
    sys.exit(main(sys.argv))
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

width, height = 100, 50
image = oedepict.OEImage(width, height)

pen = oedepict.OEPen(oechem.OEWhite, oechem.OELightGreen, oedepict.OEFill_Off, 4.0)
oedepict.OEDrawBorder(image, pen)

oedepict.OEWriteImage("OEDrawBorder.png", image)
oedepict.OEWriteImage("OEDrawBorder.pdf", image)

width, height = 100, 50
image = oedepict.OEImage(width, height)

pen = oedepict.OEPen(oechem.OEWhite, oechem.OELightGreen, oedepict.OEFill_Off, 4.0)
oedepict.OEDrawCurvedBorder(image, pen, 15)

oedepict.OEWriteImage("OEDrawCurvedBorder.png", image)
oedepict.OEWriteImage("OEDrawCurvedBorder.pdf", image)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oedepict

width, height = 100, 50
image = oedepict.OEImage(width, height)

oedepict.OEDrawTextToCenter(image, "center", oedepict.OEDefaultFont)
oedepict.OEDrawBorder(image, oedepict.OELightGreyPen)

oedepict.OEWriteImage("OEDrawTextToCenter.png", image)
oedepict.OEWriteImage("OEDrawTextToCenter.pdf", image)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

###############################################################
# USED TO GENERATE CODE SNIPPETS FOR THE OEDEPICT DOCUMENTATION
###############################################################


def DrawHelloWorld(image, font):

    w = image.GetWidth()
    h = image.GetHeight()
    image.Clear(oechem.OEWhite)

    pen = oedepict.OEPen()
    image.DrawRectangle(oedepict.OE2DPoint(1.0, 1.0), oedepict.OE2DPoint(w - 1.0, h - 1.0), pen)

    image.DrawText(oedepict.OE2DPoint(w / 2.0, h / 2.0), "Hello World!", font)


def DrawHelloWorlds(font, basefilename):

    image = oedepict.OEImage(200, 60)
    DrawHelloWorld(image, font)

    oedepict.OEWriteImage(basefilename + ".png", image)
    oedepict.OEWriteImage(basefilename + ".pdf", image)


font = oedepict.OEFont()
DrawHelloWorlds(font, "OEFont_Default")

font = oedepict.OEFont()
font.SetFamily(oedepict.OEFontFamily_Times)
DrawHelloWorlds(font, "OEFont_SetFamily")

font = oedepict.OEFont()
font.SetStyle(oedepict.OEFontStyle_Bold | oedepict.OEFontStyle_Italic)
DrawHelloWorlds(font, "OEFont_SetStyle")

font = oedepict.OEFont()
font.SetSize(30)
DrawHelloWorlds(font, "OEFont_SetSize")

font = oedepict.OEFont()
font.SetAlignment(oedepict.OEAlignment_Right)
DrawHelloWorlds(font, "OEFont_SetAlignment")

font = oedepict.OEFont()
font.SetColor(oechem.OERed)
DrawHelloWorlds(font, "OEFont_SetColor")

font = oedepict.OEFont()
font.SetRotationAngle(180.0)
DrawHelloWorlds(font, "OEFont_SetRotationAngle")
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

###############################################################
# USED TO GENERATE CODE SNIPPETS FOR THE OEDEPICT DOCUMENTATION
###############################################################


def DepictMoleculesWithLabel(smiles, ss, highlight, label, basefilename):

    mol = oechem.OEGraphMol()
    oechem.OESmilesToMol(mol, smiles)
    oedepict.OEPrepareDepiction(mol)
    opts = oedepict.OE2DMolDisplayOptions(220, 160, oedepict.OEScale_AutoScale)
    opts.SetTitleLocation(oedepict.OETitleLocation_Hidden)
    disp = oedepict.OE2DMolDisplay(mol, opts)

    unique = True
    for match in ss.Match(mol, unique):
        oedepict.OEAddHighlighting(disp, highlight, match)
        oedepict.OEAddLabel(disp, label, match)

    image = oedepict.OEImage(disp.GetWidth(), disp.GetHeight())
    oedepict.OERenderMolecule(image, disp)

    oedepict.OEWriteImage(basefilename + ".png", image)
    oedepict.OEWriteImage(basefilename + ".pdf", image)


smiles = "c1ccc2c(c1)cc(O)cn2"
ss = oechem.OESubSearch("c1ncc(O)cc1")

highlight = oedepict.OEHighlightByLasso(oechem.OEDarkRed)
highlight.SetConsiderAtomLabelBoundingBox(True)

label = oedepict.OEHighlightLabel('match')
DepictMoleculesWithLabel(smiles, ss, highlight, label, "OEHighlightLabel_Default")

label = oedepict.OEHighlightLabel('match', oechem.OEDarkRed)
DepictMoleculesWithLabel(smiles, ss, highlight, label, "OEHighlightLabel_Color")


font = oedepict.OEFont(oedepict.OEFontFamily_Courier, oedepict.OEFontStyle_Bold, 12,
                       oedepict.OEAlignment_Center, oechem.OEDarkRed)
label = oedepict.OEHighlightLabel('match', font)
DepictMoleculesWithLabel(smiles, ss, highlight, label, "OEHighlightLabel_Font")

label = oedepict.OEHighlightLabel('match')
font = oedepict.OEFont(oedepict.OEFontFamily_Default, oedepict.OEFontStyle_Default, 12,
                       oedepict.OEAlignment_Center, oechem.OEDarkRed)
label.SetFont(font)
DepictMoleculesWithLabel(smiles, ss, highlight, label, "OEHighlightLabel_SetFont")

label = oedepict.OEHighlightLabel('match')
pen = oedepict.OEPen(oechem.OEColor(255, 220, 220), oechem.OEDarkRed, oedepict.OEFill_On, 16.0,
                     oedepict.OEStipple_ShortDash)
label.SetBoundingBoxPen(pen)
DepictMoleculesWithLabel(smiles, ss, highlight, label, "OEHighlightLabel_SetBoundingBoxPen")

label = oedepict.OEHighlightLabel('match')
label.SetFontScale(1.2)
DepictMoleculesWithLabel(smiles, ss, highlight, label, "OEHighlightLabel_SetFontScale")
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

###############################################################
# USED TO GENERATE CODE SNIPPETS FOR THE OEDEPICT DOCUMENTATION
###############################################################


def WriteTable(tableoptions, basefilename):

    image = oedepict.OEImage(300, 200)
    table = oedepict.OEImageTable(image, tableoptions)

    for idx, cell in enumerate(table.GetHeaderCells()):
        table.DrawText(cell, "(header %d)" % (idx + 1))

    for idx, cell in enumerate(table.GetStubColumnCells()):
        table.DrawText(cell, "(stub %d)" % (idx + 1))

    onlybody = True
    for row in range(1, table.NumRows(onlybody) + 1):
        for col in range(1, table.NumColumns(onlybody) + 1):
            cell = table.GetBodyCell(row, col)
            table.DrawText(cell, "(body %d, %d)" % (row, col))

    oedepict.OEDrawBorder(image, oedepict.OELightGreyPen)
    oedepict.OEWriteImage(basefilename + ".png", image)
    oedepict.OEWriteImage(basefilename + ".pdf", image)


tableopts = oedepict.OEImageTableOptions(4, 4, oedepict.OEImageTableStyle_MediumBlue)
WriteTable(tableopts, "OEImageTableOptions_Default")

tableopts = oedepict.OEImageTableOptions(4, 4, oedepict.OEImageTableStyle_MediumBlue)
tableopts.SetColumnWidths([20, 10, 20, 10])
WriteTable(tableopts, "OEImageTableOptions_SetColumnWidths")

tableopts = oedepict.OEImageTableOptions(4, 4, oedepict.OEImageTableStyle_MediumBlue)
tableopts.SetRowHeights([10, 20, 30, 40])
WriteTable(tableopts, "OEImageTableOptions_SetRowHeights")

tableopts = oedepict.OEImageTableOptions(4, 4, oedepict.OEImageTableStyle_MediumBlue)
tableopts.SetBaseFontSize(6)
WriteTable(tableopts, "OEImageTableOptions_SetBaseFontSize")

tableopts = oedepict.OEImageTableOptions(4, 4, oedepict.OEImageTableStyle_MediumBlue)
pen = oedepict.OEPen(oechem.OEBlack, oechem.OEDarkBlue, oedepict.OEFill_Off, 2.0)
tableopts.SetCellBorderPen(pen)
WriteTable(tableopts, "OEImageTableOptions_SetCellBorderPen")

tableopts = oedepict.OEImageTableOptions(4, 4, oedepict.OEImageTableStyle_MediumBlue)
evenrow = True
tableopts.SetCellColor(oechem.OELightGrey, not evenrow)
WriteTable(tableopts, "OEImageTableOptions_SetCellColor")

tableopts = oedepict.OEImageTableOptions(4, 4, oedepict.OEImageTableStyle_MediumBlue)
font = oedepict.OEFont(oedepict.OEFontFamily_Default,
                       oedepict.OEFontStyle_Italic | oedepict.OEFontStyle_Bold,
                       8, oedepict.OEAlignment_Left, oechem.OEDarkRed)
tableopts.SetCellFont(font)
WriteTable(tableopts, "OEImageTableOptions_SetCellFont")

tableopts = oedepict.OEImageTableOptions(4, 4, oedepict.OEImageTableStyle_MediumBlue)
tableopts.SetHeader(False)
WriteTable(tableopts, "OEImageTableOptions_SetHeader")

tableopts = oedepict.OEImageTableOptions(4, 4, oedepict.OEImageTableStyle_MediumBlue)
tableopts.SetHeaderColor(oechem.OELightGrey)
WriteTable(tableopts, "OEImageTableOptions_SetHeaderColor")

tableopts = oedepict.OEImageTableOptions(4, 4, oedepict.OEImageTableStyle_MediumBlue)
font = oedepict.OEFont(oedepict.OEFontFamily_Default, oedepict.OEFontStyle_Default, 12,
                       oedepict.OEAlignment_Right, oechem.OEPinkTint)
tableopts.SetHeaderFont(font)
WriteTable(tableopts, "OEImageTableOptions_SetHeaderFont")

tableopts = oedepict.OEImageTableOptions(4, 4, oedepict.OEImageTableStyle_MediumBlue)
tableopts.SetMargin(oedepict.OEMargin_Left, 10.0)
tableopts.SetMargin(oedepict.OEMargin_Right, 10.0)
WriteTable(tableopts, "OEImageTableOptions_SetMargin")

tableopts = oedepict.OEImageTableOptions(4, 4, oedepict.OEImageTableStyle_MediumBlue)
tableopts.SetMargins(10.0)
WriteTable(tableopts, "OEImageTableOptions_SetMargins")

tableopts = oedepict.OEImageTableOptions(4, 4, oedepict.OEImageTableStyle_MediumBlue)
tableopts.SetStubColumn(True)
WriteTable(tableopts, "OEImageTableOptions_SetStubColumn")

tableopts = oedepict.OEImageTableOptions(4, 4, oedepict.OEImageTableStyle_MediumBlue)
tableopts.SetStubColumn(True)
tableopts.SetStubColumnColor(oechem.OELightGrey)
WriteTable(tableopts, "OEImageTableOptions_SetStubColumnColor")

tableopts = oedepict.OEImageTableOptions(4, 4, oedepict.OEImageTableStyle_MediumBlue)
tableopts.SetStubColumn(True)
font = oedepict.OEFont(oedepict.OEFontFamily_Default, oedepict.OEFontStyle_Default, 12,
                       oedepict.OEAlignment_Right, oechem.OEPinkTint)
tableopts.SetStubColumnFont(font)
WriteTable(tableopts, "OEImageTableOptions_SetStubColumnFont")
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict
import sys

if len(sys.argv) != 2:
    oechem.OEThrow.Usage("%s <imagefile>" % sys.argv[0])

filename = sys.argv[1]
ext = oechem.OEGetFileExtension(filename)
if not oedepict.OEIsRegisteredImageFile(ext):
    oechem.OEThrow.Fatal("Unknown image type!")
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

###############################################################
# USED TO GENERATE CODE SNIPPETS FOR THE OEDEPICT DOCUMENTATION
###############################################################


def DrawFigure(image, pen):

    w = image.GetWidth()
    h = image.GetHeight()
    image.Clear(oechem.OEWhite)

    a = oedepict.OE2DPoint(10.0, 10.0)
    b = oedepict.OE2DPoint(w - 10, h - 10.0)
    image.DrawRectangle(a, b, pen)

    a = oedepict.OE2DPoint(20.0, 20.0)
    b = oedepict.OE2DPoint(w - 20, h - 20.0)
    image.DrawLine(a, b, pen)

    a = oedepict.OE2DPoint(60.0, 20.0)
    b = oedepict.OE2DPoint(20.0, 60.0)
    image.DrawLine(a, b, pen)


def DrawFigures(pen, basefilename):

    image = oedepict.OEImage(80, 80)
    DrawFigure(image, pen)

    oedepict.OEWriteImage(basefilename + ".png", image)
    oedepict.OEWriteImage(basefilename + ".pdf", image)


pen = oedepict.OEPen()
DrawFigures(pen, "OEPen_Default")

pen = oedepict.OEPen()
pen.SetForeColor(oechem.OERed)
DrawFigures(pen, "OEPen_SetForeColor")

pen = oedepict.OEPen()
pen.SetFill(oedepict.OEFill_On)
pen.SetBackColor(oechem.OEBlueTint)
DrawFigures(pen, "OEPen_SetBackColor")


pen = oedepict.OEPen()
pen.SetLineWidth(4)
pen.SetLineCap(oedepict.OELineCap_Square)
DrawFigures(pen, "OEPen_SetLineCap")

pen = oedepict.OEPen()
pen.SetLineWidth(4)
pen.SetLineJoin(oedepict.OELineJoin_Miter)
DrawFigures(pen, "OEPen_SetLineJoin")

pen = oedepict.OEPen()
pen.SetLineWidth(5.0)
DrawFigures(pen, "OEPen_SetLineWidth")

pen = oedepict.OEPen()
pen.SetLineStipple(oedepict.OEStipple_ShortDash)
DrawFigures(pen, "OEPen_SetLineStipple")

pen = oedepict.OEPen()
pen.SetLineStipple(oedepict.OEStipple_ShortDash)
pen.SetStippleFactor(2)
DrawFigures(pen, "OEPen_SetStippleFactor")
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "c1cc(N)cc(S(=O)(=O)O)c1 3-aminobenzenesulfonic acid")
oedepict.OEPrepareDepiction(mol)
oedepict.OEPrepareDepiction(mol)

opts = oedepict.OE2DMolDisplayOptions(200.0, 200.0, oedepict.OEScale_AutoScale)
disp = oedepict.OE2DMolDisplay(mol, opts)
oedepict.OERenderMolecule("OERenderMolecule-fname-disp.png", disp)
oedepict.OERenderMolecule("OERenderMolecule-fname-disp.pdf", disp)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "c1cc(N)cc(S(=O)(=O)O)c1 3-aminobenzenesulfonic acid")
oedepict.OEPrepareDepiction(mol)
oedepict.OEPrepareDepiction(mol)

oedepict.OERenderMolecule("OERenderMolecule-fname-mol.png", mol)
oedepict.OERenderMolecule("OERenderMolecule-fname-mol.pdf", mol)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "c1cc(N)cc(S(=O)(=O)O)c1 3-aminobenzenesulfonic acid")
oedepict.OEPrepareDepiction(mol)
oedepict.OEPrepareDepiction(mol)

image = oedepict.OEImage(200.0, 200.0)
opts = oedepict.OE2DMolDisplayOptions(image.GetWidth(), image.GetHeight(),
                                      oedepict.OEScale_AutoScale)
disp = oedepict.OE2DMolDisplay(mol, opts)
oedepict.OERenderMolecule(image, disp)
oedepict.OEWriteImage("OERenderMolecule-image-disp.png", image)
oedepict.OEWriteImage("OERenderMolecule-image-disp.pdf", image)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "c1cc(N)cc(S(=O)(=O)O)c1 3-aminobenzenesulfonic acid")
oedepict.OEPrepareDepiction(mol)

image = oedepict.OEImage(200.0, 200.0)
oedepict.OERenderMolecule(image, mol)
oedepict.OEWriteImage("OERenderMolecule-image-mol.png", image)
oedepict.OEWriteImage("OERenderMolecule-image-mol.pdf", image)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "c1cc(N)cc(S(=O)(=O)O)c1 3-aminobenzenesulfonic acid")
oedepict.OEPrepareDepiction(mol)

opts = oedepict.OE2DMolDisplayOptions(200.0, 200.0, oedepict.OEScale_AutoScale)
disp = oedepict.OE2DMolDisplay(mol, opts)

ofs = oechem.oeofstream("OERenderMolecule-stream-disp.png")
oedepict.OERenderMolecule(ofs, "png", disp)
ofs = oechem.oeofstream("OERenderMolecule-stream-disp.pdf")
oedepict.OERenderMolecule(ofs, "pdf", disp)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "c1cc(N)cc(S(=O)(=O)O)c1 3-aminobenzenesulfonic acid")
oedepict.OEPrepareDepiction(mol)

ofs = oechem.oeofstream("OERenderMolecule-stream-mol.png")
oedepict.OERenderMolecule(ofs, "png", mol)
ofs = oechem.oeofstream("OERenderMolecule-stream-mol.pdf")
oedepict.OERenderMolecule(ofs, "pdf", mol)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

###############################################################
# USED TO GENERATE CODE SNIPPETS FOR THE OEDEPICT DOCUMENTATION
###############################################################


def CreateReportLayout():

    rows, cols = 3, 2
    reportopts = oedepict.OEReportOptions(rows, cols)
    reportopts.SetPageWidth(100.0)
    reportopts.SetPageHeight(150.0)
    reportopts.SetPageMargins(5.0)
    reportopts.SetCellGap(5.0)
    reportopts.SetHeaderHeight(15.0)
    reportopts.SetFooterHeight(15.0)
    report = oedepict.OEReport(reportopts)

    borderpen = oedepict.OEPen(oechem.OELightGrey, oechem.OELightGrey, oedepict.OEFill_Off, 1.0)

    first = report.NewBody()
    oedepict.OEDrawBorder(first, borderpen)

    nrgridpages = 3
    for p in range(0, nrgridpages):
        for c in range(0, report.NumRowsPerPage() * report.NumColsPerPage()):
            cell = report.NewCell()
            oedepict.OEDrawBorder(cell, borderpen)

    last = report.NewBody()
    oedepict.OEDrawBorder(last, borderpen)

    for page in report.GetPages():
        oedepict.OEDrawBorder(page, oedepict.OEBlackPen)
    for header in report.GetHeaders():
        oedepict.OEDrawBorder(header, borderpen)
    for footer in report.GetFooters():
        oedepict.OEDrawBorder(footer, borderpen)

    return report


def HighlightCell(cell, idx):

    font = oedepict.OEFont(oedepict.OEFontFamily_Default, oedepict.OEFontStyle_Default, 10,
                           oedepict.OEAlignment_Center, oechem.OEBlack)
    color = oechem.OEColor(oechem.OELightGrey)
    borderpen = oedepict.OEPen(color, color, oedepict.OEFill_On, 1.0)

    oedepict.OEDrawBorder(cell, borderpen)
    p = oedepict.OE2DPoint(cell.GetWidth() / 2.0, cell.GetHeight() / 2.0 + font.GetSize() / 2.0)
    cell.DrawText(p, "(%d)" % idx, font)


def WriteReportPageByPage(report, filenamebase):

    for pidx in range(1, report.NumPages() + 1):
        oedepict.OEWriteReport("%s-%d.pdf" % (filenamebase, pidx), report, pidx)
        oedepict.OEWriteReport("%s-%d.png" % (filenamebase, pidx), report, pidx)


report = CreateReportLayout()
idx = 1
for cell in report.GetCells():
    pass
    HighlightCell(cell, idx)
    idx += 1
WriteReportPageByPage(report, "OEReportIter-cells-all")


report = CreateReportLayout()
idx = 1
row = 2
for cell in report.GetCells(0, row, 0):
    pass
    HighlightCell(cell, idx)
    idx += 1
WriteReportPageByPage(report, "OEReportIter-cells-allpages-row-allcols")


report = CreateReportLayout()
idx = 1
col = 2
for cell in report.GetCells(0, 0, col):
    pass
    HighlightCell(cell, idx)
    idx += 1
WriteReportPageByPage(report, "OEReportIter-cells-allpages-allrows-col")


report = CreateReportLayout()
idx = 1
row = 2
col = 2
for cell in report.GetCells(0, row, col):
    pass
    HighlightCell(cell, idx)
    idx += 1
WriteReportPageByPage(report, "OEReportIter-cells-allpages-row-col")


report = CreateReportLayout()
idx = 1
page = 3
row = 2
for cell in report.GetCells(page, row, 0):
    pass
    HighlightCell(cell, idx)
    idx += 1
WriteReportPageByPage(report, "OEReportIter-cells-page-row-allcols")


report = CreateReportLayout()
idx = 1
page = 3
col = 2
for cell in report.GetCells(page, 0, col):
    pass
    HighlightCell(cell, idx)
    idx += 1
WriteReportPageByPage(report, "OEReportIter-cells-page-allrows-col")


report = CreateReportLayout()
idx = 1
page = 3
row = 2
col = 2
for cell in report.GetCells(page, row, col):
    pass
    HighlightCell(cell, idx)
    idx += 1
WriteReportPageByPage(report, "OEReportIter-cells-page-row-col")


report = CreateReportLayout()
idx = 1
for header in report.GetHeaders():
    pass
    HighlightCell(header, idx)
    idx += 1
WriteReportPageByPage(report, "OEReportIter-headers")


report = CreateReportLayout()
idx = 1
for footer in report.GetFooters():
    pass
    HighlightCell(footer, idx)
    idx += 1
WriteReportPageByPage(report, "OEReportIter-footers")


report = CreateReportLayout()
idx = 1
for body in report.GetBodies():
    pass
    HighlightCell(body, idx)
    idx += 1
WriteReportPageByPage(report, "OEReportIter-bodies")

report = CreateReportLayout()
WriteReportPageByPage(report, "OEReportIter-pages")
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

###############################################################
# USED TO GENERATE CODE SNIPPETS FOR THE OEDEPICT DOCUMENTATION
###############################################################


def ScaleReportOptions(opts, scale):

    for margin in [oedepict.OEMargin_Top, oedepict.OEMargin_Bottom,
                   oedepict.OEMargin_Left, oedepict.OEMargin_Right]:
        opts.SetPageMargin(margin, scale * opts.GetPageMargin(margin))
    opts.SetCellGap(scale * opts.GetCellGap())
    opts.SetHeaderHeight(scale * opts.GetHeaderHeight())
    opts.SetFooterHeight(scale * opts.GetFooterHeight())
    opts.SetPageWidth(scale * opts.GetPageWidth())
    opts.SetPageHeight(scale * opts.GetPageHeight())
    return opts


def CreateScaleReportLayout(opts, scale):

    opts = ScaleReportOptions(opts, scale)
    report = oedepict.OEReport(opts)

    borderpen = oedepict.OEPen(oechem.OEGrey, oechem.OEGrey, oedepict.OEFill_Off, 1.0)

    first = report.NewBody()
    oedepict.OEDrawBorder(first, borderpen)

    nrgridpages = 1
    for p in range(0, nrgridpages):
        for c in range(0, report.NumRowsPerPage() * report.NumColsPerPage()):
            cell = report.NewCell()
            oedepict.OEDrawBorder(cell, borderpen)

    for page in report.GetPages():
        oedepict.OEDrawBorder(page, oedepict.OEBlackPen)

    if opts.GetHeaderHeight() > 0.0:
        for header in report.GetHeaders():
            oedepict.OEDrawBorder(header, borderpen)
    if opts.GetFooterHeight() > 0.0:
        for footer in report.GetFooters():
            oedepict.OEDrawBorder(footer, borderpen)

    return report


def WriteReportPageByPage(report, filenamebase):

    for pidx in range(1, report.NumPages() + 1):
        oedepict.OEWriteReport("%s-%d.pdf" % (filenamebase, pidx), report, pidx)
        oedepict.OEWriteReport("%s-%d.png" % (filenamebase, pidx), report, pidx)


scale = 0.25

opts = oedepict.OEReportOptions(3, 2)
report = CreateScaleReportLayout(opts, scale)
WriteReportPageByPage(report, "OEReportOptions_Default")

opts = oedepict.OEReportOptions(3, 2)
opts.SetPageSize(oedepict.OEPageSize_US_Legal)
report = CreateScaleReportLayout(opts, scale)
WriteReportPageByPage(report, "OEReportOptions_SetPageSize")

opts = oedepict.OEReportOptions(3, 2)
opts.SetPageOrientation(oedepict.OEPageOrientation_Landscape)
report = CreateScaleReportLayout(opts, scale)
WriteReportPageByPage(report, "OEReportOptions_SetPageOrientation")

opts = oedepict.OEReportOptions(3, 2)
opts.SetPageWidth(opts.GetPageWidth() * 0.50)
report = CreateScaleReportLayout(opts, scale)
WriteReportPageByPage(report, "OEReportOptions_SetPageWidth")

opts = oedepict.OEReportOptions(3, 2)
opts.SetPageHeight(opts.GetPageHeight() * 0.50)
report = CreateScaleReportLayout(opts, scale)
WriteReportPageByPage(report, "OEReportOptions_SetPageHeight")

opts = oedepict.OEReportOptions(3, 2)
opts.SetPageMargin(oedepict.OEMargin_Left, 100)
opts.SetPageMargin(oedepict.OEMargin_Right, 100)
report = CreateScaleReportLayout(opts, scale)
WriteReportPageByPage(report, "OEReportOptions_SetPageMargin")

opts = oedepict.OEReportOptions(3, 2)
opts.SetPageMargins(100)
report = CreateScaleReportLayout(opts, scale)
WriteReportPageByPage(report, "OEReportOptions_SetPageMargins")

opts = oedepict.OEReportOptions(3, 2)
opts.SetCellGap(100)
report = CreateScaleReportLayout(opts, scale)
WriteReportPageByPage(report, "OEReportOptions_SetCellGap")

opts = oedepict.OEReportOptions(3, 2)
opts.SetHeaderHeight(100)
report = CreateScaleReportLayout(opts, scale)
WriteReportPageByPage(report, "OEReportOptions_SetHeaderHeight")

opts = oedepict.OEReportOptions(3, 2)
opts.SetFooterHeight(100)
report = CreateScaleReportLayout(opts, scale)
WriteReportPageByPage(report, "OEReportOptions_SetFooterHeight")
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

###############################################################
# USED TO GENERATE CODE SNIPPETS FOR THE OEDEPICT DOCUMENTATION
###############################################################


def PrepareDepiction(mol, clearcoords=False, suppressH=True):

    oechem.OESetDimensionFromCoords(mol)
    oechem.OEPerceiveChiral(mol)

    if mol.GetDimension() != 2 or clearcoords:
        if mol.GetDimension() == 3:
            oechem.OE3DToBondStereo(mol)
            oechem.OE3DToAtomStereo(mol)
        if suppressH:
            oechem.OESuppressHydrogens(mol)
        oechem.OEAddDepictionHydrogens(mol)

        oechem.OEDepictCoordinates(mol)
        oechem.OEMDLPerceiveBondStereo(mol)

    mol.SetDimension(2)
    return True


mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "C[C@H]([C@@H](C(=O)O)N)O")
PrepareDepiction(mol)
oedepict.OERenderMolecule("PrepareDepiction.png", mol)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "c1ccccc1")
oedepict.OEPrepareDepiction(mol)
data = oedepict.OERenderMoleculeToString("svg", mol)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

refmol = oechem.OEGraphMol()
oechem.OESmilesToMol(refmol, "O=C(O)C(N)")
oedepict.OEPrepareDepiction(refmol)
ss = oechem.OESubSearch(refmol, oechem.OEExprOpts_DefaultAtoms, oechem.OEExprOpts_DefaultBonds)

aminosmiles = ["O=C(O)[C@@H](N)Cc1c[nH]cn1 Histidine",
               "CC(C)[C@@H](C(=O)O)N Valine",
               "C[C@H]([C@@H](C(=O)O)N)O Threonine",
               "C1C[C@H](NC1)C(=O)O Proline"]

aminoacids = []

for smi in aminosmiles:
    mol = oechem.OEGraphMol()
    oechem.OESmilesToMol(mol, smi)
    oedepict.OEPrepareDepiction(mol)
    aminoacids.append(oechem.OEGraphMol(mol))

image = oedepict.OEImage(400, 400)

rows, cols = 2, 2
grid = oedepict.OEImageGrid(image, rows, cols)

opts = oedepict.OE2DMolDisplayOptions(grid.GetCellWidth(),
                                      grid.GetCellHeight(), oedepict.OEScale_AutoScale)
opts.SetAtomStereoStyle(oedepict.OEAtomStereoStyle_Display_All)

minscale = float("inf")
for amino in aminoacids:
    minscale = min(minscale, oedepict.OEGetMoleculeScale(amino, opts))
opts.SetScale(minscale)

for amino, cell in zip(aminoacids, grid.GetCells()):
    alignres = oedepict.OEPrepareAlignedDepiction(amino, ss)
    disp = oedepict.OE2DMolDisplay(amino, opts)
    if alignres.IsValid():
        oedepict.OEAddHighlighting(disp, oechem.OELightGreen,
                                   oedepict.OEHighlightStyle_Stick, alignres)
    oedepict.OERenderMolecule(cell, disp)

oedepict.OEWriteImage("SubSearchAlign.png", image)
oedepict.OEWriteImage("SubSearchAlign.pdf", image)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

smarts = "O=C(O)C(N)"
ss = oechem.OESubSearch(smarts)

aminosmiles = ["O=C(O)[C@@H](N)Cc1c[nH]cn1 Histidine",
               "CC(C)[C@@H](C(=O)O)N Valine",
               "C[C@H]([C@@H](C(=O)O)N)O Threonine",
               "C1C[C@H](NC1)C(=O)O Proline"]

aminoacids = []

for smi in aminosmiles:
    mol = oechem.OEGraphMol()
    oechem.OESmilesToMol(mol, smi)
    oedepict.OEPrepareDepiction(mol)
    aminoacids.append(oechem.OEGraphMol(mol))

image = oedepict.OEImage(400, 400)

rows, cols = 2, 2
grid = oedepict.OEImageGrid(image, rows, cols)

opts = oedepict.OE2DMolDisplayOptions(grid.GetCellWidth(),
                                      grid.GetCellHeight(), oedepict.OEScale_AutoScale)
opts.SetAtomStereoStyle(oedepict.OEAtomStereoStyle_Display_All)

minscale = float("inf")
for amino in aminoacids:
    minscale = min(minscale, oedepict.OEGetMoleculeScale(amino, opts))
opts.SetScale(minscale)

for amino, cell in zip(aminoacids, grid.GetCells()):
    miter = ss.Match(amino, True)
    if miter.IsValid():
        match = miter.Target()
        disp = oedepict.OE2DMolDisplay(amino, opts)
        oedepict.OEAddHighlighting(disp, oechem.OELightGreen,
                                   oedepict.OEHighlightStyle_Stick, match)
        oedepict.OERenderMolecule(cell, disp)

oedepict.OEWriteImage("SubSearchNoAlignment.png", image)
oedepict.OEWriteImage("SubSearchNoAlignment.pdf", image)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

width, height = 400, 200
image = oedepict.OEImage(width, height)

mol = oechem.OEGraphMol()
smiles = "Cc1cccnc1/C=C/[C@H](C(=O)O)O"
oechem.OESmilesToMol(mol, smiles)
oedepict.OEPrepareDepiction(mol)

opts = oedepict.OE2DMolDisplayOptions(width, height, oedepict.OEScale_AutoScale)
opts.SetMargins(10)
disp = oedepict.OE2DMolDisplay(mol, opts)

font = oedepict.OEFont(oedepict.OEFontFamily_Default, oedepict.OEFontStyle_Default, 12,
                       oedepict.OEAlignment_Center, oechem.OEDarkRed)

for adisp in disp.GetAtomDisplays():
    atom = adisp.GetAtom()
    toggletext = "atom idx=%s" % atom.GetIdx()
    oedepict.OEDrawSVGToggleText(disp, adisp, toggletext, font)

oedepict.OERenderMolecule("ToggleAtomText.svg", disp)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

width, height = 400, 200
image = oedepict.OEImage(width, height)

mol = oechem.OEGraphMol()
smiles = "Cc1cccnc1/C=C/[C@H](C(=O)O)O"
oechem.OESmilesToMol(mol, smiles)
oedepict.OEPrepareDepiction(mol)

opts = oedepict.OE2DMolDisplayOptions(width, height, oedepict.OEScale_AutoScale)
opts.SetMargins(10)
disp = oedepict.OE2DMolDisplay(mol, opts)

font = oedepict.OEFont(oedepict.OEFontFamily_Default, oedepict.OEFontStyle_Default, 12,
                       oedepict.OEAlignment_Center, oechem.OEDarkRed)

for bdisp in disp.GetBondDisplays():
    bond = bdisp.GetBond()
    toggletext = "bond idx=%s" % bond.GetIdx()
    oedepict.OEDrawSVGToggleText(disp, bdisp, toggletext, font)

oedepict.OERenderMolecule("ToggleBondText.svg", disp)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "C1CCCCC1O")
oedepict.OEPrepareDepiction(mol)

width, height = 400, 200
image = oedepict.OEImage(width, height)


class UserDataSVGAtomIdxMarkup(oedepict.OEAtomSVGMarkupBase):
    def GetClassName(self, atom):
        return "user-def-atom-class"

    def GetGroupId(self, atom):
        return "used-def-atom-{}".format(atom.GetIdx())

    def CreateCopy(self):
        return UserDataSVGAtomIdxMarkup().__disown__()


opts = oedepict.OE2DMolDisplayOptions(width, height, oedepict.OEScale_AutoScale)
opts.SetAtomSVGMarkupFunctor(UserDataSVGAtomIdxMarkup())
disp = oedepict.OE2DMolDisplay(mol, opts)


oedepict.OERenderMolecule(image, disp)
oedepict.OEWriteImage("UserAtomMarkup.svg", image)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "C1CCCCC1O")
oedepict.OEPrepareDepiction(mol)

width, height = 400, 200
image = oedepict.OEImage(width, height)


class UserDataSVGBondIdxMarkup(oedepict.OEBondSVGMarkupBase):
    def GetClassName(self, bond):
        return "user-def-bond-class"

    def GetGroupId(self, bond):
        return "user-def-bond-{}".format(bond.GetIdx())

    def CreateCopy(self):
        return UserDataSVGBondIdxMarkup().__disown__()


opts = oedepict.OE2DMolDisplayOptions(width, height, oedepict.OEScale_AutoScale)
opts.SetBondSVGMarkupFunctor(UserDataSVGBondIdxMarkup())
disp = oedepict.OE2DMolDisplay(mol, opts)


oedepict.OERenderMolecule(image, disp)
oedepict.OEWriteImage("UserBondMarkup.svg", image)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "c1ccccc1")
oedepict.OEPrepareDepiction(mol)

image = oedepict.OEImage(200, 200)
oedepict.OERenderMolecule(image, mol)
data = oedepict.OEWriteImageToString("svg", image)
#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oedepict

mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "c1ccccc1")
oedepict.OEPrepareDepiction(mol)

report = oedepict.OEReport(3, 1)
oedepict.OERenderMolecule(report.NewCell(), mol)
data = oedepict.OEWriteReportToString("pdf", report)