Molecule Styling

OE3DMolStyle

An OEMolBase has a default style without the addition of an OE3DMolStyle. The OE3DMolStyle class gives a multitude of customization options for the OEMolBase, from coloring to labeling. Outside of OEMolBase, OE3DMolStyle can be applied to an OEAtomBase and an OEConfBase. There is a hierarchy when applying OE3DMolStyle to each one of these classes: OEMolBase -> OEConfBase -> OEAtomBase.

Atom Labeling

Preset labels can be applied using SetAtomLabelType. Custom labels can be applied to specific atoms utilizing SetAtomLabelText. SetAtomLabelType takes in OEAtomLabelScheme. The example below depicts the B-Factor above each one of the respective atoms in the molecule.

mol = oechem.OEMol()
molSty = oechem.OE3DMolStyle()
molSty.SetAtomLabelType(oechem.OEAtomLabelScheme_BFactor)
oechem.OESetStyle(mol, molSty)

Styling and Typing

There are multiple styling and typing options for an OE3DMolStyle. OEAtomStyle can be set using SetAtomStyle. This allows for customization of the visibility of the atoms in a molecule, which ranges from hidden atoms to CPK atom styling. In the example below the atoms are set to display as Ball and Stick.

mol = oechem.OEMol()
molSty = oechem.OE3DMolStyle()
molSty.SetAtomStyle(oechem.OEAtomStyle_BallAndStick)
oechem.OESetStyle(mol, molSty)

OEProteinStyle can be set utilizing SetProteinStyle. This allows for customization of the protein from hidden to ribbon. The example below set the protein style to CAlpha, which depicts the protein with edges at the CAlphas.

mol = oechem.OEMol()
molSty = oechem.OE3DMolStyle()
molSty.SetProteinStyle(oechem.OEProteinStyle_CAlpha)
oechem.OESetStyle(mol, molSty)

OEContourStyle can be set utilizing SetContourStyle. This allows for customization of the contour from hidden to solid. SetGridType takes in the OEStyleGridType constant to specify the type of the grid being depicted. The example below set the grid style to mesh and the drid type to electrostatic. This will depict the grid in mesh form for better visibility of the other components of the molecule.

mol = oechem.OEMol()
molSty = oechem.OE3DMolStyle()
molSty.SetContourStyle(oechem.OEContourStyle_Mesh)
molSty.SetGridType(oechem.OEStyleGridType_Electrostatic)
oechem.OESetStyle(mol, molSty)

SetSurfaceStyle utilizes OEChem_OESurfaceStyle to depict the surface by mesh, point, and solid. OESurfaceType allows for surface typing when set by SetSurfaceType. The example below style a molecular surface to be depicted in points.

mol = oechem.OEMol()
molSty = oechem.OE3DMolStyle()
molSty.SetSurfaceStyle(oechem.OESurfaceStyle_Points)
molSty.SetSetSurfaceTypeGridType(oechem.OESurfaceType_Molecular)
oechem.OESetStyle(mol, molSty)

Hydrogen visibility is customizable by utilizing OEHydrogenVisibility in SetHydrogenVisibility. This allows for all hydrogen, polar hydrogen, and hidden hydrogen depictions. In the example below sets up an OE3DMolStyle to only depict the polar hydrogens in the molecule.

mol = oechem.OEMol()
molSty = oechem.OE3DMolStyle()
molSty.SetHydrogenVisibility(oechem.OEHydrogenVisibility_Polar)
oechem.OESetStyle(mol, molSty)

Atom to atom interactions is depicted using arrows from one atom to another. By default this is set to off. SetInteractionStyle utilizes OEInteractionStyle to toggle between intermolecular hydrogen bond interaction depiction, intramolecular hydrogen bond interaction depiction, and no bond interaction depiction. In this example we set the the interaction style to intramolecular hydrogen bond depiction.

mol = oechem.OEMol()
molSty = oechem.OE3DMolStyle()
molSty.SetInteractionStyle(oechem.OEInteractionStyle_IntramolecularHBonds)
oechem.OESetStyle(mol, molSty)

Colorer

Multple aspects of the molecule can be colored when OE3DMolStyle takes advantage of OEMolStyleColorer. There are preset color schemes for all parts of the molecule from atoms to protein, but custom colors can also be added for better personalization of the molecule.

OEAtomColorScheme provides multple preset atom color schemes when specified in the construction of an OEMolStyleColorer. SetAtomColorer takes in the OEMolStyleColorer. Atoms are colored by element by default, but this allows for coloring by b factor, residues, formal charge, and other aspects of the atoms and/or molecule. The labels of an atom can also be colored when an OEMolStyleColorer with a default color and/or custom colors by atom name or atomic number. The color of a grid can also be set with a default color specified in an OEMolStyleColorer. The OEMolStyleColorer with the default color can be set to the OE3DMolStyle with SetGridContourColorer.

OESurfaceColorScheme provides customization of surfaces with preset color schemes. These color schemes are applied similarly to how atom color schemes are applied but by utilizing SetSurfaceColorer. When a color scheme isn’t specified the surface is colored by the default color, by default the surface is colored blue.

Proteins can be colored utilizing a color scheme from OEProteinColorScheme but it can also colored with a constant from OEAtomColorScheme. The OEMolStyleColorer utilized for the protein can be set to the OE3DMolStyle with SetProteinColorer. The example below adds the different coloring options to the molecule. The protein is colored by residue. The atoms are colored by element, with a default color of white, but the OEMolStyleColorer also overwrites preset colors of certain atoms by atomic number. The grid is colored pink and the surface is colored by surface potential.

mol = oechem.OEMol()
molSty = oechem.OE3DMolStyle()
protCol = oechem.OEMolStyleColorer(oechem.OEAtomColorScheme_Residue)
atomCol = oechem.OEMolStyleColorer(oechem.OEAtomColorScheme_Element, oechem.OEWhite)
gridCol = oechem.OEMolStyleColorer(OEPink)
surfCol = oechem.OEMolStyleColorer(OESurfaceColorScheme::SurfacePotential)

atomCol.AddColor(6, oechem.OEGreen)
atomCol.AddColor(7, oechem.OERed)
atomCol.AddColor(8, oechem.OEBlue)


molSty.SetAtomColorer(atomCol)
molSty.SetProteinColorer(protCol)
molSty.SetGridContourColorer(gridCol)
molSty.SetSurfaceColorer(surfCol)
oechem.OESetStyle(mol, molSty)

See also