Skip to content

Commit 9d7948b

Browse files
committed
corrections to get_residue_custom_axes
1 parent b5340fc commit 9d7948b

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

CodeEntropy/levels/axes.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -324,10 +324,10 @@ def get_residue_custom_axes(self, edges, center):
324324
two edge atoms of the residue (heavy atoms bonded
325325
to neighbouring residues), and the rotation centre.
326326
327-
E1---O
328-
\ |
329-
\ |
330-
E2
327+
Q --- E2
328+
| |
329+
| |
330+
E1 ---- O --- P
331331
Args:
332332
edges: (2,3) positions of two edge atoms
333333
center: (3,) coordinates of the rotation centre
@@ -339,20 +339,30 @@ def get_residue_custom_axes(self, edges, center):
339339
x_axis = -E1O_vector
340340
# y axis is perpendicular to x
341341
# in the same plane as E2
342-
# look for projection of E1-E2 on E1-O
342+
# look for projection of E1-E2 on E1-O (E1-P)
343343
E1E2_vector = edges[1].position - edges[0].position
344344
projection = (
345345
np.dot(E1O_vector, E1E2_vector) / (np.linalg.norm(E1O_vector) ** 2)
346346
) * E1O_vector
347-
# get the perpendicular onto E1-O
347+
# get the perpendicular onto E1-O (P-E2)
348+
# P-E2 = P-E1 + E1-E2
348349
perpendicular = E1E2_vector - projection
350+
print(
351+
f"The perpendicular is perpendicular to the projection: "
352+
f"{np.dot(projection, perpendicular)}"
353+
)
349354
# get the perpendicular through O (Q-O)
350355
# first get P-Q diagonal through paralellogram rule
351356
# P- Q = P-E2 + P-O
352357
diagonal = -(projection - E1O_vector) + perpendicular
353358
# get the parallel of P-E2 through O
354359
# OQ = OP + PQ
355360
y_axis = (projection - E1O_vector) + diagonal
361+
print(
362+
f"The y-axis and perpendicular are "
363+
f"parallel: {np.cross(perpendicular, y_axis)}"
364+
)
365+
print(f"The x and y axis are parallel: {np.cross(x_axis, y_axis)}")
356366
z_axis = np.cross(x_axis, y_axis)
357367
x_axis /= np.linalg.norm(x_axis)
358368
y_axis /= np.linalg.norm(y_axis)
@@ -361,6 +371,8 @@ def get_residue_custom_axes(self, edges, center):
361371

362372
return rot_axes
363373

374+
return rot_axes
375+
364376
def get_bonded_axes(self, system, atom, dimensions: np.ndarray):
365377
"""Compute UA rotational axes from bonded topology around a heavy atom.
366378

0 commit comments

Comments
 (0)