UtilityFunctions
- class Dock2D.Utility.UtilityFunctions.UtilityFunctions(experiment=None, model_name=None)
- check_model_gradients(model)
Check current model parameters and gradients in-place. Specifically if weights are frozen or updating
- make_boundary(grid_shape, gaussian_blur_bulk=False)
Create the boundary feature for data generation and unit testing.
- Parameters
grid_shape – input shape grid image
- Returns
features stack with original shape as “bulk” and created “boundary”
- orthogonalize_feats(scoring_weights, feat_stack)
Orthogonalize learned shape features for single shape.
- Parameters
scoring_weights – learned scoring coefficients from scoring function
feat_stack – feature stack for one shape [bulk, boundary]
- Returns
orthogonalized feature stack
- plot_assembly(receptor, ligand, gt_rot, gt_txy, pred_rot=None, pred_txy=None, tiling=False, interaction_fact=False)
Plot the predicting docking pose for the IP task. From left to right, plots the ground truth docking pose, the pose passed into the model, and the predicted docking pose.
- Parameters
receptor – receptor shape grid image
ligand – ligand shape grid image
gt_rot – ground truth rotation
gt_txy – ground truth translation [x, y]
pred_rot – predicted rotation
pred_txy – predicted translation [x, y]
- Returns
plotting object with specified poses
- plot_features(rec_feat, lig_feat, scoring_weights, plot_count=0, stream_name='trainset', model_name=None)
Plot the learned shape pair features (bulk and boundary) from the docking model from Docking in model_docking.py.
- Parameters
rec_feat – receptor feature stack
lig_feat – ligand feature stack
receptor – receptor shape grid image
ligand – ligand shape grid image
scoring_weights – learned scoring coefficients used in scoring function
plot_count – plotting index used in titles and filename
stream_name – data stream name
- plot_predicted_pose(receptor, ligand, gt_rot, gt_txy, pred_rot, pred_txy, plot_count, stream_name)
Plotting helper function for
plot_assembly()
.- Parameters
receptor – receptor shape grid image
ligand – ligand shape grid image
gt_rot – ground truth rotation
gt_txy – ground truth translation [x, y]
pred_rot – predicted rotation
pred_txy – predicted translation [x, y]
plot_count – plotting index used in titles and filename
stream_name – data stream name
- plot_rotation_energysurface(fft_score, pred_txy, num_angles=360, stream_name=None, plot_count=0, plot_pub=False)
Plot the lowest energy translation index from fft_score per rotation angle as an energy surface curve.
- Parameters
fft_score – FFT scores generated using a docker method.
pred_txy – predicted translation [x, y]
num_angles – number of angles used to generate fft_score
stream_name – data stream name
plot_count – plotting index used in titles and filename
- read_pkl(filename)
- Parameters
filename – filename.pkl to load
- Returns
data
- rotate(repr, angle)
Rotate a grid image using 2D rotation matrix.
- Parameters
repr – input grid image
angle – angle in radians
- Returns
rotated grid image
- rotate_gridligand(ligand, rotation_angle)
Rotate grid image in degrees using scipy.ndimage.rotate(), an alternative rotation function for
plot_assembly()
- Parameters
ligand – grid image of ligand
rotation_angle – angle in degrees
- Returns
rotated ligand
- swap_quadrants(input_volume)
FFT returns features centered with the origin at the center of the image, not at the top left corner.
- Parameters
input_volume – FFT output array
- translate_gridligand(ligand, tx, ty)
Translate grid image using scipy.ndimage.shift() for
plot_assembly()
- Parameters
ligand – grid image of ligand
tx – x dimension translation
ty – y dimension translation
- Returns
translated ligand
- weights_init(model)
Initialize weights for SE(2)-equivariant convolutional network. Generally unused for SE(2) network, as e2nn library has its own Kaiming He weight initialization.
- write_pkl(data, filename)
- Parameters
data – to write to .pkl file
filename – specify filename.pkl