OEAddLabelΒΆ

Adds labels to a molecule display.

The overloaded versions of the OEAddLabel function
Link Description
OEAddLabel(disp, label, match) adding label to atoms of a match
OEAddLabel(disp, label, abset) adding label to set of atoms
OEAddLabel(disp, label, atompred) adding label to atoms specified by a predicate

Parameters :

disp
The OE2DMolDisplay object on which the label is going to be positioned.
label
The OEHighlightLabel object that stores properties that determine the styles of the label along with the text of the label itself.
match
The label is positioned based on the target atoms of the OEMatchBase object.
abset
The label is positioned based on the atoms stored in the OEAtomBondSet object.
atompred
The label is positioned based on the atoms for which the given atom predicate returns true.

Note

It is recommended to use the OEAddLabel along with the OEAddHighlighting.

void OEAddLabel(OE2DMolDisplay &disp,
                const OEHighlightLabel &label,
                const OEChem::OEMatchBase &match)

Adds label to atoms of an OEMatchBase object that can be initialized by substructure search or maximum common substructure search.

Example:

private static void OEAddLabel_OEMatch(OE2DMolDisplay disp) {
    OEMolBase mol = disp.GetMolecule();

    OESubSearch subs = new OESubSearch("a1aaaaa1");
    boolean unique = true;
    OEHighlightByBallAndStick highlight = new OEHighlightByBallAndStick(oechem.getOELightGreen());
    for (OEMatchBase match : subs.Match(mol, unique)) {
        oedepict.OEAddHighlighting(disp, highlight, match);
        OEHighlightLabel label = new OEHighlightLabel("aromatic", oechem.getOELightGreen());
        oedepict.OEAddLabel(disp, label, match);
    }
}

private static void OEAddLabel_OEAtomBondSet(OE2DMolDisplay disp) {
    OEMolBase mol = disp.GetMolecule();

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

    OEAtomBondSet chainset = new OEAtomBondSet(mol.GetAtoms(new OEAtomIsInChain()), 
                                               mol.GetBonds(new OEBondIsInChain()));
    OEHighlightByBallAndStick chainhighlight = new OEHighlightByBallAndStick(oechem.getOEBlueTint());
    oedepict.OEAddHighlighting(disp, chainhighlight, chainset);
ighlightLabel chainlabel = new OEHighlightLabel("chain", oechem.getOEBlueTint());
    oedepict.OEAddLabel(disp, chainlabel, chainset);
}

///////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////

public static void main(String argv[]) {
    OEGraphMol mol = new OEGraphMol();
    oechem.OESmilesToMol(mol, "CC(=O)C1Cc2ccccc2N1");
    oedepict.OEPrepareDepiction(mol);

    int width  = 250;
    int height = 180;
    OE2DMolDisplayOptions opts = new OE2DMolDisplayOptions(width, height, OEScale.AutoScale);
    opts.SetTitleLocation(OETitleLocation.Hidden);

    {
        OE2DMolDisplay disp = new OE2DMolDisplay(mol, opts);
        OEAddLabel_Predicate(disp);
        oedepict.OERenderMolecule("OEAddLabel-Predicate.png", disp);
    }

    {
        OE2DMolDisplay disp = new OE2DMolDisplay(mol, opts);
        OEAddLabel_OEMatch(disp);
        oedepict.OERenderMolecule("OEAddLabel-OEMatch.png", disp);
    }

    {
        OE2DMolDisplay disp = new OE2DMolDisplay(mol, opts);
        OEAddLabel_OEAtomBondSet(disp);
        oedepict.OERenderMolecule("OEAddLabel-OEAtomBondSet.png", disp);
    }
}
../../_images/OEAddLabel-OEMatch.png

Example of adding label to 6-membered aromatic ring

void OEAddLabel(OE2DMolDisplay &disp,
                const OEHighlightLabel &label,
                const OEChem::OEAtomBondSet &abset)

Adds label to atoms stored in the OEAtomBondSet object.

Example:

private static void OEAddLabel_OEAtomBondSet(OE2DMolDisplay disp) {
    OEMolBase mol = disp.GetMolecule();

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

    OEAtomBondSet chainset = new OEAtomBondSet(mol.GetAtoms(new OEAtomIsInChain()), 
                                               mol.GetBonds(new OEBondIsInChain()));
    OEHighlightByBallAndStick chainhighlight = new OEHighlightByBallAndStick(oechem.getOEBlueTint());
    oedepict.OEAddHighlighting(disp, chainhighlight, chainset);
ighlightLabel chainlabel = new OEHighlightLabel("chain", oechem.getOEBlueTint());
    oedepict.OEAddLabel(disp, chainlabel, chainset);
}
../../_images/OEAddLabel-OEAtomBondSet.png

Example of adding label to ring and chain components of a molecule

void OEAddLabel(OE2DMolDisplay &disp,
                const OEHighlightLabel &label,
                const OESystem::OEUnaryPredicate<OEChem::OEAtomBase> &atompred)

Adds label to atoms for which the given atom predicate returns true.

Example:

private static void OEAddLabel_Predicate(OE2DMolDisplay disp) {
    OEHighlightByBallAndStick ringhighlight = new OEHighlightByBallAndStick(oechem.getOELightGreen());
epict.OEAddHighlighting(disp, ringhighlight, new OEAtomIsInRing(), new OEBondIsInRing());
ighlightLabel ringlabel = new OEHighlightLabel("ring", oechem.getOELightGreen());
    oedepict.OEAddLabel(disp, ringlabel, new OEAtomIsInRing());

    OEHighlightByBallAndStick chainhighlight = new OEHighlightByBallAndStick(oechem.getOEBlueTint());
epict.OEAddHighlighting(disp, chainhighlight, new OEAtomIsInChain(), new OEBondIsInChain());
ighlightLabel chainlabel = new OEHighlightLabel("chain", oechem.getOEBlueTint());
epict.OEAddLabel(disp, chainlabel, new OEAtomIsInChain());
}
../../_images/OEAddLabel-Predicate.png

Example of adding label to ring and chain components of a molecule