Skip to content

Commit 8bb0c50

Browse files
Comments
1 parent d8c3bb9 commit 8bb0c50

3 files changed

Lines changed: 18 additions & 15 deletions

File tree

src/geometre/draw.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ def pymol_drawing(filepath, geometric_centers, rot_centers, twist_axis, pitch_ax
3131
for i in range(num_centers):
3232
cmd.pseudoatom('geo_centers', pos=tuple(geometric_centers[i]))
3333
# Uncommented lines preserved from original function:
34-
# cmd.pseudoatom('ref_1', pos=tuple(geometric_centers[i] + 6 * unit_vector))
35-
# cmd.pseudoatom('ref_2', pos=tuple(geometric_centers[i] - 6 * unit_vector))
36-
# cmd.select('unit_1', selection='model ref_1 and name PS{}'.format(str(i + 1)))
37-
# cmd.select('unit_2', selection='model ref_2 and name PS{}'.format(str(i + 1)))
38-
# cmd.distance('unit_vector', selection1='unit_1', selection2='unit_2')
34+
cmd.pseudoatom('ref_1', pos=tuple(geometric_centers[i] + 6 * unit_vector))
35+
cmd.pseudoatom('ref_2', pos=tuple(geometric_centers[i]))
36+
cmd.select('unit_1', selection='model ref_1 and name PS{}'.format(str(i + 1)))
37+
cmd.select('unit_2', selection='model ref_2 and name PS{}'.format(str(i + 1)))
38+
cmd.distance('unit_vector', selection1='unit_1', selection2='unit_2')
3939

4040
if i < num_centers - 1:
41-
unit_vector = units_rots[i] @ (rots[i][0].apply(unit_vector))
41+
unit_vector = units_rots[i] @ (rots[i][0].apply(unit_vector)) # matrix multiplication
4242
unit_vector = rots[i][1].apply(unit_vector, inverse=True)
4343

4444

@@ -77,6 +77,9 @@ def pymol_drawing(filepath, geometric_centers, rot_centers, twist_axis, pitch_ax
7777
cmd.distance('curvature_axis', selection1='point1', selection2='curvature_point')
7878

7979

80+
81+
82+
8083
# Place pseudoatoms for the last geometric center
8184
l = np.sqrt(np.sum((geometric_centers[-1] - geometric_centers[-2]) ** 2, axis=0)) * 1.5
8285
cmd.pseudoatom('twist_ref', pos=tuple(geometric_centers[-1] + l * twist_axis[-1][1]))

src/geometre/geometry.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,21 +126,21 @@ def widest_circle_fit(units, centers, window):
126126
# considering all the projected coordinates of the C-alpha
127127
circle = CircleModel()
128128
circle.estimate(pca_centers)
129-
res = minimize(widest_circle, circle.params[0:2], args=(data_transformed))
129+
res = minimize(widest_circle, circle.params[0:2], args=data_transformed)
130130

131-
center = res.x
131+
center = res.x # The best argument of the minimization result
132132
centers_list.append(pca.inverse_transform(center))
133133
index_list.append([*range(min_index, max_index)])
134134

135-
# Fun is the value of the objective function at x
136-
# Here we are changing the sign for keeping the smallest crown
135+
# Fun is the value of the objective function at x (i.e. the inverse of the best crown width)
136+
# Here we are changing the sign for keeping the best crown
137137
score_list.append(-res.fun)
138138

139-
# Select the widest crown
139+
140+
# For each unit of each window, select centers corresponding to the best score (widest crown)
140141
def_centers = np.empty((num_units, 3))
141142
best_score = np.full(num_units, -np.inf)
142143

143-
# For each unit of each window, select centers corresponding to the best score (widest crown)
144144
# Iterate windows
145145
for center, indexes, score in zip(centers_list, index_list, score_list):
146146
# Iterate units

src/geometre/process.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,18 @@ def compute(filepath, chain, units_ids, ins_ids=None, window=6):
9595
rot_centers = widest_circle_fit(units_coords, geometric_centers, window=window)
9696
logger.debug("Geometric centers and rotation centers calculated.")
9797

98-
# Calculate rotation angle (yaw angle) for each pair of units
98+
# Calculate rotation angle (yaw angle / curvature) for each pair of units
9999
rot_angles = [get_angle(rot_centers[i] - geometric_centers[i], rot_centers[i] - geometric_centers[i + 1])
100100
for i in range(num_centers - 1)]
101101

102102
# Calculate the axes
103103
pitch_axis, twist_axis, rots = build_ref_axes(geometric_centers, rot_centers)
104104
logger.debug("Reference axes built for geometry calculations.")
105105

106-
# Calculate rotations and scores
106+
# Calculate rotations and scores with TM-align
107107
units_rots, tmscores = [], []
108108
for i in range(num_centers - 1):
109-
# TM-align
109+
110110
# We provide rots to superimpose the reference systems of the two consecutive units
111111
alignment = get_unit_rotation(units_coords[i:i + 2], units_seqs[i:i + 2], rots[i])
112112
units_rots.append(alignment.u) # Rotation matrix

0 commit comments

Comments
 (0)