Models/
Models are split into two methodological categories, BruteForce and Sampling, for both the interaction pose (IP) and fact-of-interaction (FI) dataset tasks. For BruteForce, the models sample the entire space of rotations and translations. For Sampling, only a small subset of the transformational space is sampled.
The two core models modules use torch.nn.Module Docking()
and Interaction()
.
The docking module produces docking features and scoring coefficients using an SE(2)-Convolutional Neural Network, and scores the produced features using TorchDockingFFT.
The interaction module computes a probability of interaction based on free energies learned using the docking module.
Note
Using torch.nn.Module creates special members of __init__ and forward:
- __init__()
Initializes internal Module state, shared by both nn.Module and ScriptModule.
- forward()
Defines the computation performed at every call.
Should be overridden by all subclasses.
Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them. e.g. call `Docking()` instead of `Docking().forward()`, see code for examples.
Contents:
- class Dock2D.Models.model_docking.Docking(dockingFFT, plot_freq=1, debug=False)
- __init__(dockingFFT, plot_freq=1, debug=False)
Initialize parameters for Docking module and TorchDockingFFT used in the forward pass to generate shape features and scoring coefficients for the scoring function.
- Parameters
dim – dimension of final padded shape
num_angles – number of angles to use in FFT correlation
plot_freq – frequency at which to plot features
debug – set to True show debug verbose model
- forward(receptor, ligand, angle=None, training=False, plotting=False, plot_count=1, stream_name='trainset')
Generates features for both receptor and ligand shapes using the SE(2)-ConvNet. Computes a transformation-dependent score based on the correlation of these features,
\[\mathrm{corr}(\mathbf{t}, \phi, R, L) = \int R(\mathbf{r}) \mathbf{M}_\phi L(\mathbf{r}-\mathbf{t}) d\mathbf{r}\]on pairwise features, i.e. boundary:boundary, bulk:boundary, boundary:bulk, bulk:bulk.
- Parameters
receptor – receptor shape grid image
ligand – ligand shape grid image
training – set True for training, False for evalution.
plotting – create plots or not
plot_count – current plotting index
stream_name – data stream name
angle – single angle to rotate shape for single rotation slice FFT in sampling models
- Returns
fft_score
- class Dock2D.Models.model_interaction.Interaction
- __init__()
Initialize parameters for Interaction module and free energy integral calculation. The learned parameter for free energy decision threshold, \(F_0\), is initialized here. For the free energy integral, the volume used in the denominator is also initialized here.
- forward(brute_force=True, fft_scores=None, free_energies_visited=None)
Calculate the difference in free energy, \(\Delta F\), using either a stack of fft_scores or sampled free energies.
\[\Delta F = -\ln Z = -\ln \sum_{\mathbf{t}, \phi} e^{-E(\mathbf{t}, \phi)} - F_0\]then convert to a probability using a sigmoid function.
- Parameters
brute_force – set to True to calculate the BruteForce free energy integral using fft_scores converted to energies.
fft_scores – used in BruteForce free energy calculation
free_energies – sampling method free energy array
- Returns
pred_interact, deltaF, F, F_0
- class Dock2D.Models.model_sampling.SamplingDocker(dockingFFT, debug=False)
- __init__(dockingFFT, debug=False)
Initialize docking FFT and feature generation using the SE(2)-CNN.
- Parameters
dockingFFT – dockingFFT initialized to match dimensions of current sampling scheme
num_angles – If a single rotation slice correlation is desired, specify num_angles=1, else num_angles is the number of angles to linearly space -pi to +pi
debug – set to True show debug verbose model and plots
- forward(receptor, ligand, rotation=None, plot_count=1, stream_name='trainset', plotting=False, training=False)
Uses TorchDockingFFT() to compute feature correlations for a rotationally sampled stack of examples.
- Parameters
receptor – receptor shape grid image
ligand – ligand shape grid image
rotation – pass rotation for single angle correlation
plot_count – current plotting index
stream_name – data stream name
plotting – create plots or not
- Returns
lowest_energy, pred_rot, pred_txy, fft_score
- class Dock2D.Models.model_sampling.SamplingModel(dockingFFT, sample_steps=10, step_size=10, sig_alpha=2, IP=False, IP_MC=False, IP_LD=False, FI_BF=False, FI_MC=False, experiment=None)
- __init__(dockingFFT, sample_steps=10, step_size=10, sig_alpha=2, IP=False, IP_MC=False, IP_LD=False, FI_BF=False, FI_MC=False, experiment=None)
Initialize sampling for the two molecular recognition tasks, IP and FI. For IP, BruteForce (BF) and BruteSimplified (BS). For FI, BruteForce and MonteCarlo(MC)
Note
Langevin dynamics (LD) code for IP is included but not reported in our work.
- Parameters
dockingFFT – dockingFFT initialized to match dimensions of current sampling scheme
num_angles – If a single rotation slice correlation is desired, specify num_angles=1, else num_angles is the number of angles to linearly space -pi to +pi
sample_steps – number of samples per example
step_size – step size to use in the LD energy gradient based method
sig_alpha – sigma for rotation used in LD
IP – interaction pose prediction used for either BF or BS, only difference is the num_angles specified. If num_angles==1 runs the BS model, and BF otherwise.
IP_MC – Interaction pose trained using BS for docking features, and evaluation using MC.
IP_LD – Interaction pose trained using either BS or BF and evaluated using LD
FI_BF – Fact of interaction trained and evaluated using BF
FI_MC – Fact of interaction trained using MC and evaluated using BF
experiment – current experiment name
- forward(receptor, ligand, alpha=None, free_energies_visited=None, sig_alpha=None, plot_count=1, stream_name='trainset', plotting=False, training=True)
Run models and sampling for the two molecular recognition tasks, IP and FI. For IP, BruteForce (BF) and BruteSimplified (BS). For FI, BruteForce and MonteCarlo(MC)
- Parameters
receptor – receptor shape grid image
ligand – ligand shape grid image
alpha – rotation, default is None
free_energies_visited – free energies indices for FI_MC
sig_alpha – sigma alpha used in LD
plot_count – current plotting index
stream_name – data stream name
plotting – create plots or not
training – train if True, else evaluate
- Returns
depends on which model and task is being trained/evaluated