added trajectory wrap method
Previously there was only a function to wrapAtoms for individual frames. This extends that to the whole trajectory.
This should probably have more testing
I generated a trajectory of Na and Cl in a small water box where wrapping occurs. I visualized it and have quantitative support. I'll test the function on this.
@jamesmkrieger, I have a dcd file with wrapping and am trying to run the following code with it:
from prody import *
f = DCDFile("nacl_namd.dcd")
f.hasUnitcell
f.wrap()
The f.hasUnitcell is True, but when I try to wrap I get the following error:
In [5]: f.wrap()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
File ~/apps/miniforge3/envs/prody-wrap_traj/lib/python3.8/site-packages/ProDy-2.0.2-py3.8-linux-x86_64.egg/prody/measure/transform.py:530, in wrapAtoms(frame, unitcell, center)
529 try:
--> 530 unitcell = frame.getUnitcell()[:3]
531 except AttributeError:
AttributeError: 'numpy.ndarray' object has no attribute 'getUnitcell'
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
Cell In[5], line 1
----> 1 f.wrap()
File ~/apps/miniforge3/envs/prody-wrap_traj/lib/python3.8/site-packages/ProDy-2.0.2-py3.8-linux-x86_64.egg/prody/trajectory/trajbase.py:397, in TrajBase.wrap(self, unitcell, center)
395 LOGGER.progress('Wrapping trajectory ...', len(coordsets))
396 for i, coordset in enumerate(coordsets):
--> 397 wrapped.addCoordset(wrapAtoms(coordset), unitcell=unitcell, center=center)
398 LOGGER.update(i)
400 LOGGER.finish()
File ~/apps/miniforge3/envs/prody-wrap_traj/lib/python3.8/site-packages/ProDy-2.0.2-py3.8-linux-x86_64.egg/prody/measure/transform.py:532, in wrapAtoms(frame, unitcell, center)
530 unitcell = frame.getUnitcell()[:3]
531 except AttributeError:
--> 532 raise TypeError('unitcell information must be provided')
534 half = unitcell / 2
535 ucmin = center - half
TypeError: unitcell information must be provided
Am I doing something wrong?
I don’t really remember these functions so I don’t know. Did you actually set a unit cell or anything like that?
The frames do have a unitcell:
In [17]: f.getFrame(1).getUnitcell()
Out[17]:
array([29.05412292, 29.05412292, 29.05412292, 93.09894122, 93.09894122,
93.09894122])
I wonder where we are ending up with a numpy array. Maybe DCDFile isn’t the right object?
I'll look into this a bit more.
Thanks