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)

    static class Pred6MemAromAtom extends OEUnaryAtomPred {
        @Override
        public boolean constCall(OEAtomBase atom) {
            return atom.IsAromatic() && oechem.OEAtomIsInAromaticRingSize(atom, 6);
        }
    
        @Override
        public OEUnaryAtomBoolFunc CreateCopy() {
            OEUnaryAtomBoolFunc copy = new Pred6MemAromAtom();
            copy.swigReleaseOwnership();
            return copy;
        }
    }
    
    static class Pred6MemAromBond extends OEUnaryBondPred {
        @Override
        public boolean constCall(OEBondBase bond) {
            return bond.IsAromatic() && oechem.OEBondIsInAromaticRingSize(bond, 6);
        }
    
        @Override
        public OEUnaryBondBoolFunc CreateCopy() {
            OEUnaryBondBoolFunc copy = new Pred6MemAromBond();
            copy.swigReleaseOwnership();
            return copy;
        }
    }
    
    private static void OEAddHighlighting_Predicate(OE2DMolDisplay disp) {
        OEHighlightByBallAndStick highlightstyle = new OEHighlightByBallAndStick(oechem.getOELightGreen());
        oedepict.OEAddHighlighting(disp, highlightstyle, new Pred6MemAromAtom());
        oedepict.OEAddHighlighting(disp, highlightstyle, new Pred6MemAromBond());
    }
    
    private static void OEAddHighlighting_AtomAndBondPredicate(OE2DMolDisplay disp) {
        OEHighlightByBallAndStick highlightstyle = new OEHighlightByBallAndStick(oechem.getOELightGreen());
        oedepict.OEAddHighlighting(disp, highlightstyle, new Pred6MemAromAtom(), new 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)

    private static void OEAddHighlighting_OEMatch(OE2DMolDisplay disp) {
        OESubSearch subs = new OESubSearch("a1aaaaa1");
        boolean unique = true;
        OEHighlightByBallAndStick highlightstyle = new OEHighlightByBallAndStick(oechem.getOELightGreen());
        for (OEMatchBase match : subs.Match(disp.GetMolecule(), unique)) {
            oedepict.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)

    private static void OEAddHighlighting_OEAtomBondSet(OE2DMolDisplay disp) {
        OEMolBase mol = disp.GetMolecule();
        OEAtomBondSet abset = new OEAtomBondSet(mol.GetAtoms(new Pred6MemAromAtom()),
                mol.GetBonds(new Pred6MemAromBond()));
        OEHighlightByBallAndStick highlightstyle = new OEHighlightByBallAndStick(oechem.getOELightGreen());
        oedepict.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)

    private static void OEAddHighlighting_OESubSearch(OE2DMolDisplay disp) {
        OESubSearch subsearch = new OESubSearch("a1aaaaa1");
        OEHighlightByBallAndStick highlightstyle = new OEHighlightByBallAndStick(oechem.getOELightGreen());
        oedepict.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)

    static class Pred6MemAromAtom extends OEUnaryAtomPred {
        @Override
        public boolean constCall(OEAtomBase atom) {
            return atom.IsAromatic() && oechem.OEAtomIsInAromaticRingSize(atom, 6);
        }
    
        @Override
        public OEUnaryAtomBoolFunc CreateCopy() {
            OEUnaryAtomBoolFunc copy = new Pred6MemAromAtom();
            copy.swigReleaseOwnership();
            return copy;
        }
    }
    
    static class Pred6MemAromBond extends OEUnaryBondPred {
        @Override
        public boolean constCall(OEBondBase bond) {
            return bond.IsAromatic() && oechem.OEBondIsInAromaticRingSize(bond, 6);
        }
    
        @Override
        public OEUnaryBondBoolFunc CreateCopy() {
            OEUnaryBondBoolFunc copy = new Pred6MemAromBond();
            copy.swigReleaseOwnership();
            return copy;
        }
    }
    
    private static void OEAddHighlighting_Predicate(OE2DMolDisplay disp) {
        oedepict.OEAddHighlighting(disp, oechem.getOEDarkGreen(), OEHighlightStyle.Color, new Pred6MemAromAtom());
        oedepict.OEAddHighlighting(disp, oechem.getOEDarkGreen(), OEHighlightStyle.Color, new Pred6MemAromBond());
    }
    
    private static void OEAddHighlighting_AtomAndBondPredicate(OE2DMolDisplay disp) {
        oedepict.OEAddHighlighting(disp, oechem.getOEDarkGreen(), OEHighlightStyle.Color, 
        new Pred6MemAromAtom(), new 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)

    private static void OEAddHighlighting_OEMatch(OE2DMolDisplay disp) {
        OESubSearch subs = new OESubSearch("a1aaaaa1");
        boolean unique = true;
        for (OEMatchBase match : subs.Match(disp.GetMolecule(), unique)) {
            oedepict.OEAddHighlighting(disp, oechem.getOEDarkGreen(), 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)

    private static void OEAddHighlighting_OEAtomBondSet(OE2DMolDisplay disp) {
        OEMolBase mol = disp.GetMolecule();
        OEAtomBondSet abset = new OEAtomBondSet(mol.GetAtoms(new Pred6MemAromAtom()),
                mol.GetBonds(new Pred6MemAromBond()));
        oedepict.OEAddHighlighting(disp, oechem.getOEDarkGreen(), 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)

private static void OEAddHighlighting_OESubSearch(OE2DMolDisplay disp) {
    OESubSearch subsearch = new OESubSearch("a1aaaaa1");
    oedepict.OEAddHighlighting(disp, oechem.getOEDarkGreen(), OEHighlightStyle.Color, subsearch);
}
../../_images/OEAddHighlighting-OEHighlightStyle-OEMatch.png

Example of highlighting 6-membered aromatic rings

See also