@@ -223,7 +223,6 @@ def get_UA_axes(self, data_container, index: int, res_position):
223223 ValueError:
224224 If axis construction fails.
225225 """
226-
227226 index = int (index ) # bead index
228227 heavy_atoms = data_container .atoms .select_atoms ("mass 2 to 999" )
229228
@@ -298,16 +297,19 @@ def get_UA_axes(self, data_container, index: int, res_position):
298297 trans_center = np .array (data_container .center_of_mass ())
299298 trans_axes = data_container .atoms .principal_axes ()
300299
301- residue_heavy_atoms = residue .atoms .select_atoms ("mass 2 to 999" )
302- # look for heavy atoms in residue of interest
303- heavy_atom_indices = []
304- for atom in residue_heavy_atoms :
305- heavy_atom_indices .append (atom .index )
306- # we find the nth heavy atom
307- # where n is the bead index
308- heavy_atom_index = heavy_atom_indices [index ]
309- heavy_atom = residue .atoms .select_atoms (f"index { heavy_atom_index } " )
310-
300+ if len (heavy_atoms ) > 1 :
301+ residue_heavy_atoms = residue .atoms .select_atoms ("mass 2 to 999" )
302+ # look for heavy atoms in residue of interest
303+ heavy_atom_indices = []
304+ for atom in residue_heavy_atoms :
305+ heavy_atom_indices .append (atom .index )
306+ # we find the nth heavy atom
307+ # where n is the bead index
308+ heavy_atom_index = heavy_atom_indices [index ]
309+ heavy_atom = residue .atoms .select_atoms (f"index { heavy_atom_index } " )
310+ else :
311+ # only the one heavy atom
312+ heavy_atom = heavy_atoms [0 ]
311313 if trans_axes is None :
312314 raise ValueError ("Unable to compute translation axes for UA bead." )
313315
0 commit comments