6GDC Hydropahy#

This 3D visualization show the selection of atoms together with the hydropathy index of each residue, and the average hydropathy index of each angle. This system and calculation is covered in more detail in the Binding Pocket Analysis tutorial.

Code To Produce Above Plot#
import ProteoTwirl.ProteinRotation as pt
import MDAnalysis as mda
import numpy as np
from ProteoTwirl.Visualization.Plot3D import plot_property_3d, plot_3d,_value_color_func, _value_size_func
from ProteoTwirl.Selectors.Selector import ExposedAtomSelector, ClippingPlaneSelector, FieldOfViewSelector

#╭────────────────────────────────────────────────────────╮#
#│               LOAD & CALCULATE HYDROPATHY              │#
#╰────────────────────────────────────────────────────────╯#

# Get Ligand Center - For Binding Pocket Position
universe    = mda.Universe("Test_Data/6GDC.pdb")
ligand      = universe.select_atoms("resname FB2 and resid 305")
ligand_cog  = np.mean(ligand.positions, axis = 0)


# Load Protein Centered on Binding Pocket
protein_structure = pt.ProteinRotation(
    protein                 = "Test_Data/6GDC.pdb",
    selection               = "protein and not element H",
    base_rotation           = None,
    center_selection        = False,
    center                  = ligand_cog,
    )


# Calculate Hydropathy for Binding Pocket
protein_structure.add_property(
    property            ="count.Hydropathy",
    rotation_res        =  128,
    agg_method          = "mean",
    use_default         =False,
    rotation_range      =  None,
    selectors           = [
                            ClippingPlaneSelector((None,0)),
                            FieldOfViewSelector(7),
                            ExposedAtomSelector()
                        ]
)


#╭────────────────────────────────────────────────────────╮#
#│                        SET COLOR                       │#
#╰────────────────────────────────────────────────────────╯#

# Set color per angle
min_val     = np.min(protein_structure.mean_Hydropathy)
max_val     = np.max(protein_structure.mean_Hydropathy)


def color_white_selection (index, angle, val, cur_angle):

    if cur_angle :
        return "#ffffff"

    return _value_color_func(index, angle, val, cur_angle,min_val,max_val-min_val, "plasma")

color_val   = lambda index, angle, val, cur_angle : color_white_selection (index, angle, val, cur_angle)


#╭────────────────────────────────────────────────────────╮#
#│                       SET RADIUS                       │#
#╰────────────────────────────────────────────────────────╯#

def size_selection (index, angle, val, cur_angle):

    if cur_angle :
        return 12.5

    return _value_size_func(index, angle, val, cur_angle,min_val,max_val-min_val, (1,10))

size_val   = lambda index, angle, val, cur_angle : size_selection (index, angle, val, cur_angle)



#╭────────────────────────────────────────────────────────╮#
#│                  GET SELECTED INDICES                  │#
#╰────────────────────────────────────────────────────────╯#

# Get Atom Selections for Binding Pocket
prot_it = protein_structure.iter(
    rotation_res    =  128,
    selectors       = [
                        ClippingPlaneSelector((None,0)),
                        FieldOfViewSelector(7),
                        ExposedAtomSelector()
                    ]
)


md_atom_selection = []
selections        = []
for it_positions,it_atom,it_indices in prot_it :
    md_atom_selection.append(it_atom)
    selections.append(it_indices)

plot_3d(
    protein_rotation    = protein_structure,
    selections          = selections,
    angles              = protein_structure._angle_spaces[0],
    values              = protein_structure.mean_Hydropathy,
    selected_color      = "Hydropathy Index",
    selected_radius     = 1.5,
    unselected_radius   = 0.25,
    unselected_color    = "Hydropathy Index",
    angle_color         = color_val,
    angle_radius        = size_selection,
    background          = "#14181e",
    html_path           = "6GDC_Gallery.html"

)