Visualizing Protein-Ligand B-factor Map
Problem
You want to visualize the B-factor of an active site in order to reveal regions with high flexibility. See example in Figure 1. Atoms with high B-factor (i.e. high flexibility) are colored red, while blue color indicates low B-factors.
hover the mouse over any residue circle to display its B-factor
Figure 1. Example of depicting the B-factor map of 2A1B complex
See also
- Visualizing Protein-Ligand B-factor recipe that shows an alternative visualization 
Ingredients
| 
 | 
Difficulty level
 
Download
Solution
The depict_bfactormap function illustrates how simple it is to generate these images.
- First the OEInteractionHintContainer object is constructed that stores information about possible interactions between the ligand and the protein. 
- The interactions are perceived by calling the OEPerceiveInteractionHints function. When generating the B-factor map the interactions are only used to position the nearby residues around the depicted ligand. 
- The active site is then prepared for 2D depiction by invoking the OEPrepareActiveSiteDepiction function. 
- When the OE2DActiveSiteDisplay object is constructed, residues are positioned around the ligand close to those atoms which they are interacting with. 
- The OERenderBFactorMap function generates the interactive image in which the B-factor is projected into the ligand using a color gradient (red indicates atoms with high B-factor while blue color indicates low B-factors) - The residue cycles in the image act as hover buttons that reveal the atomic representation of the residue that is color coded by the B-factor. The color of the residue cycle indicates the average B-factor of the residue. 
 1def depict_bfactormap(image, protein, ligand, opts):
 2    """
 3    :type image: oedepict.OEImageBase
 4    :type protein: oechem.OEMolBase
 5    :type ligand: oechem.OEMolBase
 6    :type opts: oegrapheme.OE2DActiveSiteDisplayOptions
 7    """
 8
 9    # perceive interactions
10
11    asite = oechem.OEInteractionHintContainer(protein, ligand)
12    if not asite.IsValid():
13        oechem.OEThrow.Fatal("Cannot initialize active site!")
14    asite.SetTitle(ligand.GetTitle())
15
16    oechem.OEPerceiveInteractionHints(asite)
17
18    # depiction
19
20    oegrapheme.OEPrepareActiveSiteDepiction(asite)
21    adisp = oegrapheme.OE2DActiveSiteDisplay(asite, opts)
22    oegrapheme.OERenderBFactorMap(image, adisp)
Usage
Usage
The following commands will generate the image shown in Figure 1:
prompt > wget https://files.rcsb.org/download/1a1b.pdb
prompt > python3 bfactormap2img.py -complex 1a1b.pdb -out 1a1b.svg -interactive-legend
Command Line Parameters
Simple parameter list
    -height : Height of output image
    -width : Width of output image
    SplitMolComplex options :
      -covalentligand : Split covalent ligands
      -ligandname : Ligand name
    molecule display options :
      -aromstyle : Aromatic ring display style
    input/output options :
      -complex : Input filename of the protein-ligand complex
      -protein : Input filename of the protein
      -ligand : Input filename of the ligand
      -out : Output filename of the generated image
    active site display options:
      -interactive-legend : Visualize legend on mouse hover (SVG feature)
Discussion
See Discussion subsection of the Visualizing Protein-Ligand B-factor recipe.
See also in OEChem TK manual
Theory
- Biopolymers chapter 
- Protein Preparation chapter 
API
- OEPerceiveInteractionHints function 
See also in OEDepict TK manual
Theory
- Molecule Depiction chapter 
API
- OEImage class 
See also in GraphemeTM TK manual
API
- OE2DActiveSiteDisplay class 
- OEPrepareActiveSiteDepiction function 
- OERenderBFactorMap function