Visualization Example System#
All examples below will be created using the example system presented
below. In this setup, we will load 8JXW with added hydrogens, as
done in Loading Protein. After this, we will calculate a
property and a shape to plot.
import ProteoTwirl.ProteinRotation as pt
protein_structure = pt.ProteinRotation(
protein = "8JXW_H.pdb", # Protein structure to load
selection = "protein and segid E and not element H", # Select receptor only (in this case segment E)
base_rotation = "principle", # Align to principal axes
center_selection = True, # Set center of geometry to (0,0,0) (center of rotation)
atom_radii = "vdw", # Definition of radii to use, here van der Waals
# Default values avoid having to re-enter them for each added property
default_rotation_res = 128, # Number of angles to sample
default_rotation_range = None, # Can be set to min and max values for theta and phi angles
default_selectors = None, # Allows us to select atoms based on orientation
default_sampler = None, # How we sample angles, currently only Fibonacci sphere
)
# Show interactive view of the protein loaded
protein_structure
Once the protein is loaded, we will calculate a property. In this case, we will calculate the average hydropathy index of the exposed residues of the protein.
Hydropathy is a count property, and we can add it using the
name "count.Hydropathy". We also need to set the aggregation method to
"mean"; otherwise, no aggregation is performed, and we need one value
per angle to plot.
from ProteoTwirl.Selectors.Selector import ExposedAtomSelector
protein_structure.add_property(
property = "count.Hydropathy",
agg_method = "mean",
use_default = False,
rotation_res = 64,
selectors = [ExposedAtomSelector()],
workers = 1
)
>>> Adding mean_Hydropathy
print(len(protein_structure.mean_Hydropathy))
>>> 64
Lastly, we will construct a shape of the protein. Here, we will use an alpha shape and apply a small amount of hole filling to clean up the shape.
protein_structure.add_property(
property = "Alphashape",
hole_fill = 0.2,
use_default = False,
rotation_res = 64,
workers = 1
)
>>> Adding Alpha_Shape_45_HF20
print(len(protein_structure.Alpha_Shape_45_HF20))
>>> 64
protein_structure.Alpha_Shape_45_HF20[0]