COM calculations

Skip to first unread message

Mahesh Yadav

Apr 27, 2022, 10:57:11 AM4/27/22
to MDnalysis discussion
Hello guys,

This question is not explicitly related to the MDAnalysis, but a combination of H5MD & MDAnanlysis. I slice a trajectory which contains the coordinates of seven different proteins (2 copies each) and DPPC. After that I follow the usual procedures to select_atoms and calculate the center_of_mass, which I store as a timeseries. The timeseries contains all the proteins & DPPC. But now I want to store the timeseries of each protein in separate  groups in a `.h5` file. But I'm completely confused how to achieve this? Should I create a slice for each protein? 

Hugo Macdermott-Opeskin

Jul 22, 2022, 11:13:00 PM7/22/22
to MDnalysis discussion

Sorry for the slow response.

Are you trying to create a trajectory (what i assume you mean by a .h5 file) for each protein?
If so I would suggest you use something like the following:

import MDAnalysis as mda
u = mda.Universe("topology.tpr", "trajectory.h5md")
protein_1 = u.select_atoms("some selection that selects protein 1")
with mda.Writer("output.h5md", n_atoms=protein_1.n_atoms) as W:
    for ts in u.trajectory: W.write(protein_1)


Let me know if that helps. FYI your original code is not visible. 
Reply all
Reply to author
0 new messages