OEAddHighlighting

Highlights atoms and/or bonds of the displayed molecule.

The overloaded versions of the OEAddHighlighting function using OEHighlightBase

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, highlight, subsearch)

highlights atoms and bonds of substructure matches OEHighlightBase

The overloaded versions of the OEAddHighlighting function using color and style

Link

Description

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

OEAddHighlighting(disp, color, style, subsearch)

highlights atoms and bonds of substructure matches

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.

subsearch

The substructure search object of the matches 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 : public OEUnaryPredicate<OEAtomBase>
    {
    public:
      bool operator()(const OEAtomBase &atom) const
      {
        return atom.IsAromatic() && OEAtomIsInAromaticRingSize(atom, 6);
      }
      OEUnaryFunction<OEAtomBase,bool> *CreateCopy() const
      {
        return new Pred6MemAromAtom;
      }
    };
    
    class Pred6MemAromBond : public OEUnaryPredicate<OEBondBase>
    {
    public:
      bool operator()(const OEBondBase &bond) const
      {
        return bond.IsAromatic() && OEBondIsInAromaticRingSize(bond, 6);
      }
      OEUnaryFunction<OEBondBase,bool> *CreateCopy() const
      {
        return new Pred6MemAromBond;
      }
    };
    
    void OEAddHighlighting_Predicate(OE2DMolDisplay& disp)
    {
      OEHighlightByBallAndStick highlightstyle(OELightGreen);
      OEAddHighlighting(disp, highlightstyle, Pred6MemAromAtom());
      OEAddHighlighting(disp, highlightstyle, Pred6MemAromBond());
    }
    
    void OEAddHighlighting_AtomAndBondPredicate(OE2DMolDisplay& disp)
    {
      OEHighlightByBallAndStick highlightstyle(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)

    void  OEAddHighlighting_OEMatch(OE2DMolDisplay& disp)
    {
      const OEMolBase* mol = disp.GetMolecule();
    
      OESubSearch ss("a1aaaaa1");
      const bool unique = true;
      OEHighlightByBallAndStick highlightstyle(OELightGreen);
      for (OEIter<const OEMatchBase> mi = ss.Match(*mol, unique); mi; ++mi)
        OEAddHighlighting(disp, highlightstyle, mi);
    }
    
  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)

    void OEAddHighlighting_OEAtomBondSet(OE2DMolDisplay& disp)
    {
      const OEMolBase* mol = disp.GetMolecule();
      const OEAtomBondSet abset(mol->GetAtoms(Pred6MemAromAtom()),
                                mol->GetBonds(Pred6MemAromBond()));
    
      OEHighlightByBallAndStick highlightstyle(OELightGreen);
      OEAddHighlighting(disp, highlightstyle, abset);
    }
    
  4. Highlighting using an OESubSearch of which matches are being highlighted:

    void OEAddHighlighting(OE2DMolDisplay &disp, const OEHighlightBase &highlight,
                           const OEChem::OESubSearch &subsearch)
    

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

    void  OEAddHighlighting_OESubSearch(OE2DMolDisplay& disp)
    {
      OESubSearch subsearch("a1aaaaa1");
      OEHighlightByBallAndStick highlightstyle(OELightGreen);
      OEAddHighlighting(disp, highlightstyle, subsearch);
    }
    
../../_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 : public OEUnaryPredicate<OEAtomBase>
    {
    public:
      bool operator()(const OEAtomBase &atom) const
      {
        return atom.IsAromatic() && OEAtomIsInAromaticRingSize(atom, 6u);
      }
      OEUnaryFunction<OEAtomBase,bool> *CreateCopy() const
      {
        return new Pred6MemAromAtom;
      }
    };
    
    class Pred6MemAromBond : public OEUnaryPredicate<OEBondBase>
    {
    public:
      bool operator()(const OEBondBase &bond) const
      {
        return bond.IsAromatic() && OEBondIsInAromaticRingSize(bond, 6u);
      }
      OEUnaryFunction<OEBondBase,bool> *CreateCopy() const
      {
        return new Pred6MemAromBond;
      }
    };
    
    void OEAddHighlighting_Predicate(OE2DMolDisplay& disp)
    {
      OEAddHighlighting(disp, OEDarkGreen, OEHighlightStyle::Color, Pred6MemAromAtom());
      OEAddHighlighting(disp, OEDarkGreen, OEHighlightStyle::Color, Pred6MemAromBond());
    }
    
    void OEAddHighlighting_AtomAndBondPredicate(OE2DMolDisplay& disp)
    {
      OEAddHighlighting(disp, OEDarkGreen, OEHighlightStyle::Color,
                        Pred6MemAromAtom(), Pred6MemAromBond());
    }
    
  2. Highlighting using an OEMatchBase object that is initialized by substructure search or maximum common 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)

    void OEAddHighlighting_OEMatch(OE2DMolDisplay& disp)
    {
      OESubSearch subs("a1aaaaa1");
      const bool unique = true;
      for (OEIter<const OEMatchBase> mi = subs.Match(*disp.GetMolecule(), unique); mi; ++mi)
        OEAddHighlighting(disp, OEDarkGreen, OEHighlightStyle::Color, *mi);
    }
    
  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)

    void OEAddHighlighting_OEAtomBondSet(OE2DMolDisplay& disp)
    {
      const OEMolBase* mol = disp.GetMolecule();
      const OEAtomBondSet abset(mol->GetAtoms(Pred6MemAromAtom()),
                                mol->GetBonds(Pred6MemAromBond()));
      OEAddHighlighting(disp, OEDarkGreen, OEHighlightStyle::Color, abset);
    }
    
  4. Highlighting using an OESubSearch of which matches are being highlighted:

void OEAddHighlighting(OE2DMolDisplay &disp, const OESystem::OEColor& color,
                       unsigned int style, const OEChem::OESubSearch &subsearch);

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

void  OEAddHighlighting_OESubSearch(OE2DMolDisplay& disp)
{
  OESubSearch subsearch("a1aaaaa1");
  OEAddHighlighting(disp, OEDarkGreen, OEHighlightStyle::Color, subsearch);
}
../../_images/OEAddHighlighting-OEHighlightStyle-OEMatch.png

Example of highlighting 6-membered aromatic rings

See also