OEAddHighlightingΒΆ

Highlights atoms and/or bonds of the displayed molecule.

The overloaded versions of the OEAddHighlighting function
Link Description
OEAddHighlighting(disp, highlight, atompred) highlights atoms with OEHighlightBase
OEAddHighlighting(disp, highlight, bondpred) highlights bonds with OEHighlightBase
OEAddHighlighting(disp, highlight, atompred, bondpred) highlights atoms and bonds with OEHighlightBase
OEAddHighlighting(disp, highlight, match) highlights atoms and bonds of a match with OEHighlightBase
OEAddHighlighting(disp, highlight, abset) highlights atoms and bonds of a set with OEHighlightBase
OEAddHighlighting(disp, color, style, atompred) highlights atoms with color and style
OEAddHighlighting(disp, color, style, bondpred) highlights bonds with color and style
OEAddHighlighting(disp, color, style, atompred, bondpred) highlights atoms and bonds with color and style
OEAddHighlighting(disp, color, style, match) highlights atoms and bonds of a match with color and style
OEAddHighlighting(disp, color, style, abset) highlights atoms and bonds of a set with color and style

Parameters :

disp
The OE2DMolDisplay object of which atoms add/or bonds being highlighted.
highlight
The OEHighlightBase object that specifies the style of the highlighting.
color
The OEColor object that specifies the color of the highlighting.
style
The style of the highlighting from the OEHighlightStyle namespace.
atompred
OEAddHighlighting function highlights only atoms for which the given atom predicate returns true.
bondpred
OEAddHighlighting function highlights only bonds for which the given bond predicate returns true.
match
OEAddHighlighting function highlights the target atoms and bonds of the OEMatchBase object.
abset
Stores the atoms and bonds being highlighted.

Highlights atom and/or bonds with the style implemented in the given OEHighlightBase object

The atoms and bonds being highlighted can be specified either by a predicate or an OEMatchBase object or an OEAtomBondSet object.

The following code snippets show different ways to highlight any 6 membered aromatic ring in a molecule using the OEHighlightByBallAndStick highlighting class. They all generate the image shown in Figure: Example of highlighting 6-membered aromatic rings.

  1. Highlighting using atom and bond predicates:

    void OEAddHighlighting(OE2DMolDisplay &disp, const OEHighlightBase &highlight,
                           const OESystem::OEUnaryPredicate<OEChem::OEAtomBase> &atompred)
    

    Highlights atoms with the style implemented in the given OEHighlightBase object. The atoms being highlighted are specified by given atom predicate.

    void OEAddHighlighting(OE2DMolDisplay &disp, const OEHighlightBase &highlight,
                           const OESystem::OEUnaryPredicate<OEChem::OEBondBase> &bondpred)
    

    Highlights bonds with the style implemented in the given OEHighlightBase object. The bonds being highlighted are specified by given bond predicates.

    void OEAddHighlighting(OE2DMolDisplay& disp, const OEHighlightBase& highlight,
                           const OESystem::OEUnaryPredicate<OEChem::OEAtomBase> &atompred,
                           const OESystem::OEUnaryPredicate<OEChem::OEBondBase> &bondpred)
    

    Highlights atoms and bonds with the style implemented in the given OEHighlightBase object. The atoms and bonds being highlighted are specified by given atom and bond predicates, respectively.

    Example: (See image generated in Example of highlighting 6-membered aromatic rings)

    class Pred6MemAromAtom(OEUnaryAtomPred):
        def __call__(self, atom):
            return atom.IsAromatic() and OEAtomIsInAromaticRingSize(atom, 6)
    
    
    class Pred6MemAromBond(OEUnaryBondPred):
        def __call__(self, bond):
            return bond.IsAromatic() and OEBondIsInAromaticRingSize(bond, 6)
    
    
    def OEAddHighlighting_Predicate(disp):
        highlightstyle = OEHighlightByBallAndStick(OELightGreen)
        OEAddHighlighting(disp, highlightstyle, Pred6MemAromAtom())
        OEAddHighlighting(disp, highlightstyle, Pred6MemAromBond())
    
    
    def OEAddHighlighting_AtomAndBondPredicate(disp):
        highlightstyle = OEHighlightByBallAndStick(OELightGreen)
        OEAddHighlighting(disp, highlightstyle, Pred6MemAromAtom(), Pred6MemAromBond())
    
  2. Highlighting using an OEMatchBase object that is initialized by substructure search or maximum common substructure search:

    void OEAddHighlighting(OE2DMolDisplay &disp, const OEHighlightBase &highlight,
                           const OEChem::OEMatchBase &match)
    

    Example: (See image generated in Example of highlighting 6-membered aromatic rings)

    def OEAddHighlighting_OEMatch(disp):
        subs = OESubSearch("a1aaaaa1")
        unique = True
        highlightstyle = OEHighlightByBallAndStick(OELightGreen)
        for match in subs.Match(disp.GetMolecule(), unique):
            OEAddHighlighting(disp, highlightstyle, match)
    
  3. Highlighting using an OEAtomBondSet object that stores the atoms and bonds being highlighted:

    void OEAddHighlighting(OE2DMolDisplay &disp, const OEHighlightBase &highlight,
                           const OEChem::OEAtomBondSet &abset)
    

    Example: (See image generated in Example of highlighting 6-membered aromatic rings)

    def OEAddHighlighting_OEAtomBondSet(disp):
        mol = disp.GetMolecule()
        abset = OEAtomBondSet(mol.GetAtoms(Pred6MemAromAtom()),
                              mol.GetBonds(Pred6MemAromBond()))
    
        highlightstyle = OEHighlightByBallAndStick(OELightGreen)
        OEAddHighlighting(disp, highlightstyle, abset)
    
../../_images/OEAddHighlighting-OEHighlightBase-OEMatch.png

Example of highlighting 6-membered aromatic rings

Highlights atoms and/or bonds with the given color and style

The atoms and bonds being highlighted can be specified either by a predicate or an OEMatchBase object or an OEAtomBondSet object.

The following code snippets show three different ways to highlight any 6 membered aromatic ring in a molecule using the built-in highlighting styles. They all generate the image shown in Figure: Example of highlighting 6-membered aromatic rings.

  1. Highlighting using atom and bond predicates:

    void OEAddHighlighting(OE2DMolDisplay &disp, const OESystem::OEColor &color,
                           unsigned int style,
                           const OESystem::OEUnaryPredicate<OEChem::OEAtomBase> &atompred)
    

    Highlights atoms with the given color and style. The atoms being highlighted are specified by given atom predicate.

    void OEAddHighlighting(OE2DMolDisplay &disp, const OESystem::OEColor &color,
                           unsigned int style,
                           const OESystem::OEUnaryPredicate<OEChem::OEBondBase> &bondpred)
    

    Highlights bonds with the given color and style. The bonds being highlighted are specified by given bonds predicate.

    void OEAddHighlighting(OE2DMolDisplay& disp, const OESystem::OEColor& color,
                           unsigned int style,
                           const OESystem::OEUnaryPredicate<OEChem::OEAtomBase> &atompred,
                           const OESystem::OEUnaryPredicate<OEChem::OEBondBase> &bondpred)
    

    Highlights atoms and bonds with the given color and style. The atoms and bonds being highlighted are specified by given atom and bond predicates, respectively.

    Example: (See image generated in Example of highlighting 6-membered aromatic rings)

    class Pred6MemAromAtom(OEUnaryAtomPred):
        def __call__(self, atom):
            return atom.IsAromatic() and OEAtomIsInAromaticRingSize(atom, 6)
    
    
    class Pred6MemAromBond(OEUnaryBondPred):
        def __call__(self, bond):
            return bond.IsAromatic() and OEBondIsInAromaticRingSize(bond, 6)
    
    
    def OEAddHighlighting_Predicate(disp):
        OEAddHighlighting(disp, OEDarkGreen, OEHighlightStyle_Color, Pred6MemAromAtom())
        OEAddHighlighting(disp, OEDarkGreen, OEHighlightStyle_Color, Pred6MemAromBond())
    
    
    def OEAddHighlighting_AtomAndBondPredicate(disp):
        OEAddHighlighting(disp, OEDarkGreen, OEHighlightStyle_Color,
                          Pred6MemAromAtom(), Pred6MemAromBond())
    
  2. Highlighting using an OEMatchBase object that is initialized by substructure search:

    void OEAddHighlighting(OE2DMolDisplay &disp, const OESystem::OEColor &color,
                           unsigned int style, const OEChem::OEMatchBase &match)
    

    Example: (See image generated in Example of highlighting 6-membered aromatic rings)

    def OEAddHighlighting_OEMatch(disp):
        subs = OESubSearch("a1aaaaa1")
        unique = True
        for match in subs.Match(disp.GetMolecule(), unique):
            OEAddHighlighting(disp, OEDarkGreen, OEHighlightStyle_Color, match)
    
  3. Highlighting using an OEAtomBondSet object that stores the atoms and bonds being highlighted:

    void OEAddHighlighting(OE2DMolDisplay &disp, const OESystem::OEColor &color,
                           unsigned int style, const OEChem::OEAtomBondSet &abset)
    

    Example: (See image generated in Example of highlighting 6-membered aromatic rings)

    def OEAddHighlighting_OEAtomBondSet(disp):
        abset = OEAtomBondSet(mol.GetAtoms(Pred6MemAromAtom()),
                              mol.GetBonds(Pred6MemAromBond()))
    
        OEAddHighlighting(disp, OEDarkGreen, OEHighlightStyle_Color, abset)
    
../../_images/OEAddHighlighting-OEHighlightStyle-OEMatch.png

Example of highlighting 6-membered aromatic rings

See also