Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/chilife/alignment_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ def rosetta_alignment(N, CA, C):

@alignment_method
def bisect_alignment(N, CA, C):
"""Calculates a rotation matrix and translation to transform an amino acid from the local coordinate frame to the
global coordinate frame for a given residue with backbone coordinates (N, C, CA). Principal axis bisects the
N->Ca->C angle.
"""Calculates the rotation matrix and translation to transform an amino acid from the local coordinate frame to the
global coordinate frame for a given residue with backbone coordinates (N, C, CA). The principal z axis bisects the
N-CA-C angle, and y is in the N-CA-C plane perpendicular to z, approximately pointing from C to N.

Parameters
----------
Expand All @@ -78,31 +78,31 @@ def bisect_alignment(N, CA, C):

Returns
-------
rotation_matrix : numpy ndarray (3x3)
Rotation matrix to rotate spin label to achieve the correct orientation.
rotation_matrix : numpy .darray (3x3)
Rotation matrix to rotate spin label to achieve the correct orientation.
origin : numpy.ndarray (1x3)
New origin position in 3-dimensional space.
"""
# Define new Z axis that bisects N<--CA-->C angle
# Define new z axis: bisector of N-CA-C angle
CA_N = N - CA
CA_N /= np.linalg.norm(CA_N)
CA_C = C - CA
CA_C /= np.linalg.norm(CA_C)
zaxis = CA_N + CA_C
zaxis = zaxis / np.linalg.norm(zaxis)

# Define new y-axis
yaxis_plane = N - C
z_comp = yaxis_plane.dot(zaxis)
yaxis = yaxis_plane - z_comp * zaxis
# Define new y axis: perpendicular to z in N-CA-C plane
yaxis = CA_N - CA_C
yaxis = yaxis / np.linalg.norm(yaxis)

# Define new x axis
# Define new x axis: perpendicular to y and z
xaxis = np.cross(yaxis, zaxis)

# Create rotation matrix
rotation_matrix = np.array([xaxis, yaxis, zaxis])

origin = CA

return rotation_matrix, origin


Expand Down
2 changes: 1 addition & 1 deletion tests/test_SpinLabel.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def test_add_protein(label):
lib.protein_setup()

with np.load(f"test_data/{label}_label.npz") as f:
np.testing.assert_almost_equal(f["coords"], lib._coords)
np.testing.assert_almost_equal(f["coords"], lib._coords, decimal=5)
np.testing.assert_almost_equal(f["weights"], lib.weights)


Expand Down
2 changes: 1 addition & 1 deletion tests/test_chiLife.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def test_create_library():
)

SL = chilife.SpinLabel('___', 238, protein)
np.testing.assert_allclose(SL.spin_centers, np.array([[-24.444481, 15.084166, 14.754087]]))
np.testing.assert_allclose(SL.spin_centers, np.array([[-24.444479, 15.084169, 14.754088]]))

struct = mda.Universe('test_data/trt_sorted.pdb')
pos = struct.atoms[:3].positions
Expand Down
4 changes: 2 additions & 2 deletions tests/test_data/bbdep.pdb
Original file line number Diff line number Diff line change
Expand Up @@ -3143,7 +3143,7 @@ ATOM 3 O R1C A 211 -16.726 2.285 12.253 0.10 1.00 O
ATOM 4 CB R1C A 211 -16.533 -0.969 12.162 0.10 1.00 C
ATOM 5 SG R1C A 211 -18.233 -0.504 12.139 0.10 1.00 S
ATOM 6 SD R1C A 211 -18.780 -0.051 10.270 0.10 1.00 S
ATOM 7 CE R1C A 211 -19.192 -1.537 9.414 0.10 1.00 C
ATOM 7 CE R1C A 211 -19.192 -1.538 9.414 0.10 1.00 C
ATOM 8 C3 R1C A 211 -19.738 -1.350 8.009 0.10 1.00 C
ATOM 9 C4 R1C A 211 -19.861 -0.128 7.484 0.10 1.00 C
ATOM 10 C2 R1C A 211 -20.187 -2.404 7.019 0.10 1.00 C
Expand Down Expand Up @@ -4852,7 +4852,7 @@ ATOM 11 C5 R1C A 211 -16.525 -6.890 16.627 0.00 1.00 C
ATOM 12 N1 R1C A 211 -15.270 -7.373 16.077 0.00 1.00 N
ATOM 13 C8 R1C A 211 -14.566 -7.197 13.730 0.00 1.00 C
ATOM 14 C9 R1C A 211 -13.335 -5.977 15.575 0.00 1.00 C
ATOM 15 C6 R1C A 211 -16.461 -6.620 18.123 0.00 1.00 C
ATOM 15 C6 R1C A 211 -16.460 -6.620 18.123 0.00 1.00 C
ATOM 16 C7 R1C A 211 -17.674 -7.834 16.297 0.00 1.00 C
ATOM 17 O1 R1C A 211 -14.762 -8.425 16.429 0.00 1.00 O
TER
Expand Down