Visualizing Protein-Ligand B-factor Map


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


  • OEChem TK - cheminformatics toolkit (including OEBio TK)

  • OEDepict TK - molecule depiction toolkit

  • Grapheme TK - molecule and property visualization toolkit

Difficulty level



Download code

See also Usage subsection.


The depict_bfactormap function illustrates how simple it is to generate these images.

  1. First the OEInteractionHintContainer object is constructed that stores information about possible interactions between the ligand and the protein.

  2. 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.

  3. The active site is then prepared for 2D depiction by invoking the OEPrepareActiveSiteDepiction function.

  4. When the OE2DActiveSiteDisplay object is constructed, residues are positioned around the ligand close to those atoms which they are interacting with.

  5. 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    """
 9    # perceive interactions
11    asite = oechem.OEInteractionHintContainer(protein, ligand)
12    if not asite.IsValid():
13        oechem.OEThrow.Fatal("Cannot initialize active site!")
14    asite.SetTitle(ligand.GetTitle())
16    oechem.OEPerceiveInteractionHints(asite)
18    # depiction
20    oegrapheme.OEPrepareActiveSiteDepiction(asite)
21    adisp = oegrapheme.OE2DActiveSiteDisplay(asite, opts)
22    oegrapheme.OERenderBFactorMap(image, adisp)



The following commands will generate the image shown in Figure 1:

prompt > wget
prompt > python3 -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)


See Discussion subsection of the Visualizing Protein-Ligand B-factor recipe.

See also in OEChem TK manual



See also in OEDepict TK manual



See also in GraphemeTM TK manual