-
Notifications
You must be signed in to change notification settings - Fork 767
Open
Description
Expected behavior
If I pass an atomgroup to RMSD, groupselections are taken only from that AtomGroup
Actual behavior
This does not happen for one of the target or reference for groupselections, resulting in an error when the RMSD is calculated due to mismatching atoms.
Code to reproduce the behavior
Error when selections are not subsets of atomgroups
In [1]: import MDAnalysis as mda
...: from MDAnalysis.tests.datafiles import PSF, DCD, CRD
...: from MDAnalysis.analysis import rms
In [2]: u = mda.Universe(PSF, DCD)
In [3]: ca = u.select_atoms('name CA')
In [4]: CORE = 'backbone and (resid 1-29 or resid 60-121 or resid 160-214)'
In [5]: R = rms.RMSD(ca, ca, select=CORE,
...: groupselections=[CORE],
...: ref_frame=0)
...: R.run()
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-5-76040dc15767> in <module>
2 groupselections=[CORE],
3 ref_frame=0)
----> 4 R.run()
~/anaconda3/envs/mdanalysis/lib/python3.7/site-packages/MDAnalysis/analysis/base.py in run(self, start, stop, step, verbose)
195 self.times[i] = ts.time
196 # logger.info("--> Doing frame {} of {}".format(i+1, self.n_frames))
--> 197 self._single_frame()
198 logger.info("Finishing up")
199 self._conclude()
~/anaconda3/envs/mdanalysis/lib/python3.7/site-packages/MDAnalysis/analysis/rms.py in _single_frame(self)
663 refpos, atoms['mobile'].positions,
664 weights=self.weights_groupselections[igroup-3],
--> 665 center=False, superposition=False)
666 else:
667 # only calculate RMSD by setting the Rmatrix to None (no need
~/anaconda3/envs/mdanalysis/lib/python3.7/site-packages/MDAnalysis/analysis/rms.py in rmsd(a, b, weights, center, superposition)
231 N = b.shape[0]
232 if a.shape != b.shape:
--> 233 raise ValueError('a and b must have same shape')
234
235 # superposition only works if structures are centered
ValueError: a and b must have same shapeWorking when selections are entirely within the atomgroups
In [7]: bb = u.select_atoms('backbone')
In [8]: R = rms.RMSD(bb, bb, select=CORE,
...: groupselections=[CORE],
...: ref_frame=0)
...: R.run()
Out[8]: <MDAnalysis.analysis.rms.RMSD at 0x1183f5f90>Current version of MDAnalysis
- Which version are you using? (run
python -c "import MDAnalysis as mda; print(mda.__version__)") 1.0.0 - Which version of Python (
python -V)? 3.7.3 - Which operating system?