I am seeing this error, need help on this!
warnings.warn("Failed to guess the mass for the following atom types: {}".format(atom_type)) Traceback (most recent call last): File "traj_residue-z.py", line 48, in protein_z=protein.centroid()[2] IndexError: index 2 is out of bounds for axis 0 with size 0
The problem was solved through a discussion in the mailing list thread https://groups.google.com/g/mdnalysis-discussion/c/J8oJ0M9Rjb4/m/kSD2jURODQAJ
In brief: The traj_residue-z.py script contained the line
It turned out that the selection
'resid 1-%d' % (nprotein_res)would not select anything because the input GRO file started with resid 1327and hence the selection of resids starting at 1 did not match anything. This produced an empty AtomGroup
protein.The subsequent centroid calculation
failed because for an empty AtomGroup,
protein.centroid()returns an empty array and so trying to get the element at index 2 raisesIndexError.The solution (thanks to @IAlibay) was to
'resid 1-%d'to accommodate start and stop resids, ornprotein_resresiduesprotein = u.residues[:nprotein_res].atomsby slicing the ResiduesGroup.