Error when running Pairwise RMSD between two trajectories

67 views
Skip to first unread message

akashp...@gmail.com

unread,
May 24, 2021, 10:01:17 AM5/24/21
to MDnalysis discussion
Hi all,

I wanted to calculate the Pairwise RMSD between two trajectories. I am getting an error when running the commands  in my notebook. Please find my code below:

GLY0 = mda.Universe(top, traj1)
GLY10 = mda.Universe(top, traj2)

prmsd = np.zeros((len(GLY0.trajectory),   # GLY0 on y-axis
                  len(GLY10.trajectory)))               # GLY10 on x-axis

from MDAnalysis.analysis import diffusionmap, align, rms

for i, frame_GLY0 in enumerate(GLY0.trajectory): 
    r = rms.RMSD(GLY10.trajectory, GLY0.trajectory,
                ref_frame=i).run()
    prmsd[i] = r.rmsd[:, -1]  


Error:

AttributeError Traceback (most recent call last) <ipython-input-14-331c3e3848f8> in <module> 5 6 for i, frame_GLY0 in enumerate(GLY0.trajectory): # assigns an index to each item in an iterable object that can be used to reference the item later ----> 7 r = rms.RMSD(GLY10.trajectory, GLY0.trajectory, 8 ref_frame=i).run() 9 prmsd[i] = r.rmsd[:, -1] # select 3rd column with RMSD values ~/opt/anaconda3/lib/python3.8/site-packages/MDAnalysis/analysis/rms.py in __init__(self, atomgroup, reference, select, groupselections, weights, weights_groupselections, tol_mass, ref_frame, **kwargs) 474 475 """ --> 476 super(RMSD, self).__init__(atomgroup.universe.trajectory, 477 **kwargs) 478 self.atomgroup = atomgroup AttributeError: 'DCDReader' object has no attribute 'universe'

Any guidance will be much appreciated.

Thanks,

Akash

Oliver Beckstein

unread,
May 24, 2021, 12:41:19 PM5/24/21
to mdnalysis-discussion
Hi Akash,

Try passing atomgroups instead of trajectories

 R = rms.RMSD(GLY10, GLY0, ref_frame=i).run()

because the RMSD analysis class takes atomgroups or universes.

You also don’t have to iterate over GLY0.trajectory; you could just do `for i in range(GLY0.trajectory.n_frames)` to get the frame numbers.

Oliver

--
You received this message because you are subscribed to the Google Groups "MDnalysis discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mdnalysis-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mdnalysis-discussion/c3ecc314-c4a1-45f9-a169-c0504240f9f7n%40googlegroups.com.

--
Oliver Beckstein (he/his/him)







Reply all
Reply to author
Forward
0 new messages