From f9608da39498a7428f64397815b97b577df0bc3b Mon Sep 17 00:00:00 2001 From: Stefan Stoll Date: Fri, 2 May 2025 07:58:27 -0700 Subject: [PATCH 1/4] small simplication in bisect_alignment --- src/chilife/alignment_methods.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/chilife/alignment_methods.py b/src/chilife/alignment_methods.py index 4755c37..1196f91 100644 --- a/src/chilife/alignment_methods.py +++ b/src/chilife/alignment_methods.py @@ -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 ---------- @@ -78,12 +78,12 @@ 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 @@ -91,18 +91,18 @@ def bisect_alignment(N, 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 From e60689a70c5f13a28dfe4abc16338ef6941f753e Mon Sep 17 00:00:00 2001 From: Maxx Tessmer Date: Fri, 2 May 2025 08:57:53 -0700 Subject: [PATCH 2/4] reduce test precision requirement --- tests/test_SpinLabel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_SpinLabel.py b/tests/test_SpinLabel.py index e467d8f..e0212f3 100755 --- a/tests/test_SpinLabel.py +++ b/tests/test_SpinLabel.py @@ -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) From 1883c912f467e6ea2a7165c50815612d5949ccbb Mon Sep 17 00:00:00 2001 From: Maxx Tessmer Date: Fri, 2 May 2025 09:00:00 -0700 Subject: [PATCH 3/4] Update test data --- tests/test_chiLife.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_chiLife.py b/tests/test_chiLife.py index 74d54fc..84b868d 100755 --- a/tests/test_chiLife.py +++ b/tests/test_chiLife.py @@ -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 From 718be16b9cd58cdefa426420312b1a0a7d945043 Mon Sep 17 00:00:00 2001 From: Maxx Tessmer Date: Fri, 2 May 2025 09:09:23 -0700 Subject: [PATCH 4/4] Fix test data --- tests/test_data/bbdep.pdb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_data/bbdep.pdb b/tests/test_data/bbdep.pdb index 184bebe..37bd23e 100755 --- a/tests/test_data/bbdep.pdb +++ b/tests/test_data/bbdep.pdb @@ -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 @@ -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