@@ -84,15 +84,23 @@ def get_residue_axes(
8484 all heavy atoms bonded to edge heavy atom and compute their average
8585 position. Find all other heavy atoms in residue and compute their average
8686 position.The three points are now used to obtain determine residue
87- rotational axes. (see get_residue_custom_axes) Compute a custom MOI,
88- using heavy atom positions and heavy atom + hydrogen masses.
87+ rotational axes. (see get_residue_custom_axes) If there are
88+ only two heavy atoms in the residue/all heavy atoms are bonded to edge
89+ atom, x-axis is set along the vector between the edge atom and average
90+ position of bonded atoms, y-axis is arbitrary and z-axis is paralel
91+ to the two. This is the same as case 2 in get_bonded_axes. Compute a
92+ custom MOI, using heavy atom positions and heavy atom + hydrogen masses.
8993
9094 - If bonded to at least two other residues:
9195 * Translational axes are principal axes of data_container.
9296 * Find edge heavy atoms (i.e. heavy atoms bonded to neighbour residues)
9397 and find the shortest chain between them: the backbone. Edge atoms
9498 + backbone COM are used to determine residue rotational axes.
95- (see get_residue_custom_axes). Compute a custom MOI, using heavy
99+ (see get_residue_custom_axes). If the two edge heavy atoms
100+ are bonded to each other (i.e. there is no backbone), x-axis is set
101+ along the vector between the edge atom and average position of bonded
102+ atoms, y-axis is arbitrary and z-axis is paralel to the two. This is the
103+ same as case 2 in get_bonded_axes. Compute a custom MOI, using heavy
96104 atom positions and heavy atom + hydrogen masses.
97105
98106 Args:
@@ -175,10 +183,13 @@ def get_residue_axes(
175183 for atom in other_atoms :
176184 average_other_atoms += atom .position
177185 average_other_atoms /= len (average_other_atoms )
178-
179- rot_center , rot_axes = self .get_residue_custom_axes (
180- [edge_atom .position , average_other_atoms ], average_bonded_atom
181- )
186+ rot_center , rot_axes = self .get_residue_custom_axes (
187+ [edge_atom .position , average_other_atoms ], average_bonded_atom
188+ )
189+ else :
190+ rot_center , rot_axes = self .get_custom_axes (
191+ a = edge_atom .position , b = [average_bonded_atom ], c = np .zeros (3 )
192+ )
182193
183194 else :
184195 edges = [edge_atom_set [0 ].position , edge_atom_set [1 ].position ]
@@ -188,9 +199,13 @@ def get_residue_axes(
188199 for heavy_atom in backbone :
189200 backbone_center += heavy_atom .position
190201 backbone_center /= len (backbone )
191- rot_center , rot_axes = self .get_residue_custom_axes (
192- edges , backbone_center
193- )
202+ rot_center , rot_axes = self .get_residue_custom_axes (
203+ edges , backbone_center
204+ )
205+ else :
206+ rot_center , rot_axes = self .get_custom_axes (
207+ a = edges [0 ], b = [edges [1 ]], c = np .zeros (3 )
208+ )
194209
195210 moment_of_inertia = self .get_custom_residue_moment_of_inertia (
196211 center_of_mass = rot_center ,
@@ -272,6 +287,11 @@ def get_UA_axes(self, data_container, index: int, res_position):
272287 - If there are *no* bonds to other residues, use a custom principal axes
273288 from a moment-of-inertia (MOI) tensor that uses positions of heavy atoms
274289 only, but includes masses of heavy atom + bonded hydrogens.
290+ - If bonded to only one other residue and there are only two heavy atoms
291+ in the residue/all heavy atoms are bonded to edge atom,
292+ x-axis is set along the vector between the edge atom and average position
293+ of bonded atoms, y-axis is arbitrary and z-axis is paralel to the two.
294+ This is the same as case 2 in get_bonded_axes.
275295 - If bonded to only one other residue, find edge heavy atom
276296 (i.e. heavy atom bonded to neighbour residue). Find all heavy atoms
277297 bonded to edge heavy atom and compute their average position.
@@ -282,6 +302,11 @@ def get_UA_axes(self, data_container, index: int, res_position):
282302 (i.e. heavy atoms bonded to neighbour residues) and find the shortest
283303 chain between them: the backbone. Edge atoms + backbone COM are used
284304 to determine residue rotational axes. (see get_residue_custom_axes).
305+ - If bonded to at least two other residues and the two edge heavy atoms
306+ are bonded to each other (i.e. there is no backbone), x-axis is set along
307+ the vector between the edge atom and average position of bonded atoms,
308+ y-axis is arbitrary and z-axis is paralel to the two. This is the same
309+ as case 2 in get_bonded_axes.
285310
286311 - Rotational axes:
287312 Identify heavy atoms in the residue/molecule of interest and choose
@@ -361,10 +386,14 @@ def get_UA_axes(self, data_container, index: int, res_position):
361386 for atom in other_atoms :
362387 average_other_atoms += atom .position
363388 average_other_atoms /= len (other_atoms )
364- trans_center , trans_axes = self .get_residue_custom_axes (
365- [edge_atom .position , average_other_atoms ],
366- average_bonded_atom ,
367- )
389+ trans_center , trans_axes = self .get_residue_custom_axes (
390+ [edge_atom .position , average_other_atoms ],
391+ average_bonded_atom ,
392+ )
393+ else :
394+ trans_center , trans_axes = self .get_custom_axes (
395+ a = edge_atom .position , b = [average_bonded_atom ], c = np .zeros (3 )
396+ )
368397 else :
369398 # between 2 residues
370399 residue = data_container .residues [1 ]
@@ -377,18 +406,20 @@ def get_UA_axes(self, data_container, index: int, res_position):
377406 f"(bonded resindex { resindex_prev } or "
378407 f"resindex { resindex_next } )"
379408 )
380-
381409 edges = edge_set .positions
382410 backbone = self .get_chain (residue , edge_set [0 ], edge_set [1 ])
383411 if len (backbone ) > 0 :
384412 backbone_center = np .zeros (3 )
385413 for heavy_atom in backbone :
386414 backbone_center += heavy_atom .position
387415 backbone_center /= len (backbone )
388-
389- trans_center , trans_axes = self .get_residue_custom_axes (
390- edges , backbone_center
391- )
416+ trans_center , trans_axes = self .get_residue_custom_axes (
417+ edges , backbone_center
418+ )
419+ else :
420+ trans_center , trans_axes = self .get_custom_axes (
421+ a = edges [0 ], b = [edges [1 ]], c = np .zeros (3 )
422+ )
392423
393424 # look for heavy atoms in residue of interest
394425 heavy_atom_indices = []
0 commit comments