
All-atom coordinates from backbone frames and torsion angles (AlphaFold)
Source:R/Alfschn.R
Alfschn.RdAlgorithms 24 and 25 of the Supplementary Information to Jumper et al. (2021), pp. 30-31. Side chain atoms are placed by walking the torsion hierarchy: each torsion frame is its parent frame composed with a literature transform and a rotation about the torsion axis, which the construction places on the x-axis. Bond lengths and angles come from the caller-supplied literature tables, so only the torsions are free.
Arguments
- frames
List of backbone frames, each
list(R, t).- angles
Torsion angles, an
n x nframe x 2array of unnormalised (cos, sin) pairs as the network emits them.- littf
List of literature transforms into the parent frame.
- parent
Parent frame index per torsion frame; 0 means the frame hangs directly off the backbone frame.
- litx
Matrix of idealised atom positions,
natoms x 3.- frameof
Torsion frame index for each atom.
Details
This implements the algebra, not the amino-acid tables: the idealised geometry is an argument, never baked in.
Examples
rot <- function(a) { q <- c(1, a) / sqrt(1 + sum(a^2))
rbind(c(1 - 2 * (q[3]^2 + q[4]^2), 2 * (q[2] * q[3] - q[1] * q[4]), 2 * (q[2] * q[4] + q[1] * q[3])),
c(2 * (q[2] * q[3] + q[1] * q[4]), 1 - 2 * (q[2]^2 + q[4]^2), 2 * (q[3] * q[4] - q[1] * q[2])),
c(2 * (q[2] * q[4] - q[1] * q[3]), 2 * (q[3] * q[4] + q[1] * q[2]), 1 - 2 * (q[2]^2 + q[3]^2))) }
fr <- list(list(R = rot(c(0.1, 0, 0.2)), t = c(1, 0, 0)))
lit <- list(list(R = diag(3), t = c(0, 1, 0)), list(R = rot(c(0.2, 0, 0)), t = c(1, 1, 0)))
ang <- array(c(1, 0.6, 0, 0.8), c(1, 2, 2)) # (cos, sin) per torsion
sc <- Alfschn(fr, ang, lit, parent = c(0, 1), litx = rbind(c(1, 0, 0), c(0, 1, 1)), frameof = c(1, 2))
round(sc$x[1, , ], 3)
#> [,1] [,2] [,3]
#> [1,] 1.543 1.286 0.229
#> [2,] 1.484 1.305 1.474