Skip to content

Instantly share code, notes, and snippets.

@OniDaito
Created January 24, 2018 00:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OniDaito/ed79d4059ceb6ad853ad5ed10e363a44 to your computer and use it in GitHub Desktop.
Save OniDaito/ed79d4059ceb6ad853ad5ed10e363a44 to your computer and use it in GitHub Desktop.
NeRF function
# 3 atoms from the previous residue
# The first residue already has the first 3 atoms laid out
a = prev_res.a.clone()
b = prev_res.b.clone()
c = prev_res.c.clone()
d = @a
na = [@b,@c]
# Bond lengths, bond angles and torsions (already in radians, as extracted from the DB)
blengths = [1.53, 1.453, 1.325]
bangles = [PXL.Math.degToRad(115), PXL.Math.degToRad(109), PXL.Math.degToRad(121)]
torsions = [prev_res.omega, prev_res.psi, @phi]
for i in [0..2]
ab = PXL.Math.Vec3.sub(b,a)
abn = PXL.Math.Vec3.normalize(ab)
bc = PXL.Math.Vec3.sub(c,b)
bcn = PXL.Math.Vec3.multScalar(bc,1.0/blengths[i])
R = blengths[i]
# Initial 4th atom position
d.x = R * Math.cos(bangles[i])
d.y = R * Math.cos(torsions[i]) * Math.sin(bangles[i])
d.z = R * Math.sin(torsions[i]) * Math.sin(bangles[i])
# Move to reference fram
n = PXL.Math.Vec3.cross(ab,bcn).normalize()
nbc = PXL.Math.Vec3.cross(n,bcn)
m = new PXL.Math.Matrix3([bcn.x, bcn.y, bcn.z, nbc.x, nbc.y, nbc.z, n.x, n.y, n.z])
d.x = -d.x
m.multVec(d)
d.add(c)
# shift along to the next atom
if i != 2
a = b
b = c
c = d
d = na[i]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment