I have some working code using MDAnalysis that saves the residues center of mass time series in an array, but I wonder if there is a more Pythonic or overall efficient/fast way (comprehensions, array operations...) to do it.
import MDAnalysis as mda
mdau = mda.Universe(pdb, xtc)
arr = np.empty(( len(mdau.select_atoms("protein").residues), len(mdau.trajectory), 3 ))
# 288 protein residues, 1250 frames and 3 xyz-coordinates per center of mass; this array shape is important
for ts in mdau.trajectory:
for num, res in enumerate(mdau.select_atoms("protein").residues):
arr[num, ts.frame] = res.atoms.center_of_mass()
The .pdb and .xtc files I am using can be downloaded in these links: https://submission.gpcrmd.org/dynadb/files/Dynamics/11579_dyn_169.pdb https://submission.gpcrmd.org/dynadb/files/Dynamics/11576_trj_169.xtc