Depicting Tripos Atom Types

Problem

You want to depict the Tripos atom types on your molecule. See example in Figure 1.

../_images/triposatom2img.png

Figure 1. Example of depicting Tripos atom types

Ingredients

Difficulty Level

../_images/chilly.png

Solution

The OEDepict TK allows you to display any atom property as a string next to the atomic label on your molecular diagram. First you have to create a class derived from the OEDisplayAtomPropBase abstract base class of which __call__ method returns the type string of an atom.

 1class TriposTypeLabel(oedepict.OEDisplayAtomPropBase):
 2    def __init__(self):
 3        oedepict.OEDisplayAtomPropBase.__init__(self)
 4
 5    def __call__(self, atom):
 6        return atom.GetType()
 7
 8    def CreateCopy(self):
 9        copy = TriposTypeLabel()
10        return copy.__disown__()

Before depicting the molecule, you have to call the OETriposAtomTypeNames function that sets the atom name property of each atom to be the Tripos type (see line 3 in the code below).

Then the TriposTypeLabel class, defined above, can be used to customize the molecule depiction. When a OE2DMolDisplay object is constructed to depict a molecule, it takes an OE2DMolDisplayOptions object that stores all the options that determine how a molecule is depicted. By default, no atom property label is rendered next to the atoms. This default behavior can be overwritten by calling the OE2DMolDisplayOptions.SetAtomPropertyFunctor method (see line 6 in the code below).

When you render the molecule the Tripos atom type label will be depicted next to the atom. See example in Figure 1.

1def DepictMoleculeWithTriposAtomTypes(image, mol):
2
3    oechem.OETriposAtomTypeNames(mol)
4
5    opts = oedepict.OE2DMolDisplayOptions(image.GetWidth(), image.GetHeight(), oedepict.OEScale_AutoScale)
6    opts.SetAtomPropertyFunctor(TriposTypeLabel())
7
8    disp = oedepict.OE2DMolDisplay(mol, opts)
9    oedepict.OERenderMolecule(image, disp)

Discussion

Similarly, you can also display bond property information on your molecule image. You can find examples in the Displaying Bond Properties section of the OEDepict TK manual.

See also in OEChem TK manual

API

See also in OEDepict TK manual

Theory

API