TorchDockingFFT

class Dock2D.Utility.TorchDockingFFT.TorchDockingFFT(padded_dim, num_angles, swap_plot_quadrants=False, normalization='ortho', model_name=None, debug=False)

Utility class to perform FFT-based docking.

__init__(padded_dim, num_angles, swap_plot_quadrants=False, normalization='ortho', model_name=None, debug=False)

Initialize docking FFT based on desired usage.

Parameters
  • padded_dim – dimension of final padded box to follow Nyquist’s theorem.

  • num_angles – number of angles to sample

  • angle – single angle to rotate a shape and evaluate FFT

  • swap_plot_quadrants – swap FFT output quadrants to make plots origin centered

  • normalization – specify normalization for the torch.fft2() and torch.irfft2() operations, default is set to ortho

  • debug – shows what rotations look like depending on num_angles

check_fft_predictions(energies, receptor, ligand, gt_rot, gt_txy, plot_pub=False)

Test function to see how fft scores looks from raw, unlearned, bulk and boundary features used in dataset generation.

Parameters
  • energies – computed fft energies

  • receptor – receptor shape grid image

  • ligand – ligand shape grid image

  • gt_rot – ground truth rotation

  • gt_txy – ground truth translation

dock_rotations(receptor_feats, ligand_feats, angle, weight_bulk, weight_crossterm, weight_bound)

Compute FFT scores of shape features in the space of all rotations and translation ligand features. Rotationally sample the the ligand feature using specified number of angles, and repeat the receptor features to match in size. Then compute docking score using dock_translations().

Parameters
  • receptor_feats – receptor bulk and boundary feature single features

  • ligand_feats – ligand bulk and boundary feature single features

  • angle – angle is the case where we only want to sample 1 correlation at a specific angle, default is None, otherwise the num_angles just does np.linspace() from 0 to 360.

  • weight_bulk – bulk scoring coefficient

  • weight_crossterm – crossterm scoring coefficient

  • weight_bound – boundary scoring coefficient

Returns

scored docking feature correlation

dock_translations(receptor_sampled_stack, ligand_sampled_stack, weight_bulk, weight_crossterm, weight_bound)

Compute FFT score on receptor and rotationally sampled ligand feature stacks of bulk, crossterms, and boundary features. Maximum score -> minimum energy.

Parameters
  • receptor_sampled_stackself.num_angles repeated stack of receptor bulk and boundary features

  • ligand_sampled_stackself.num_angles rotated and repeated stack of receptor bulk and boundary features

  • weight_bulk – bulk scoring coefficient

  • weight_crossterm – crossterm scoring coefficient

  • weight_bound – boundary scoring coefficient

Returns

FFT score using scoring function

encode_transform(gt_rot, gt_txy)

Encode the ground-truth transformation as a (flattened) 3D one-hot array.

Parameters
  • gt_rot – ground truth rotation in radians [[gt_rot]], expected to be between -pi and +pi.

  • gt_txy – ground truth translation [[x], [y]].

Returns

flattened one hot encoded array.

extract_transform(fft_score)

Returns the transformation [alpha, [tx, ty]] corresponding to the best (maximum) score

Parameters

fft_score – fft score grid

Returns

predicted rotation index and translation indices