Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added trajectory wrap method #1344

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

jamesmkrieger
Copy link
Contributor

Previously there was only a function to wrapAtoms for individual frames. This extends that to the whole trajectory.

@jamesmkrieger jamesmkrieger force-pushed the wrap_traj branch 2 times, most recently from be6141c to e255fd2 Compare March 11, 2021 10:44
@jamesmkrieger jamesmkrieger marked this pull request as draft December 20, 2021 17:49
@jamesmkrieger
Copy link
Contributor Author

This should probably have more testing

@jamesmkrieger jamesmkrieger added the Enhancement Improvement to an already-existing feature. label Dec 20, 2021
@jamesmkrieger jamesmkrieger marked this pull request as ready for review November 5, 2023 19:57
@atbogetti atbogetti self-assigned this May 7, 2024
@atbogetti
Copy link
Member

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.
image

@atbogetti
Copy link
Member

@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?

@jamesmkrieger
Copy link
Contributor Author

I don’t really remember these functions so I don’t know. Did you actually set a unit cell or anything like that?

@atbogetti
Copy link
Member

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])

@jamesmkrieger
Copy link
Contributor Author

I wonder where we are ending up with a numpy array. Maybe DCDFile isn’t the right object?

@atbogetti
Copy link
Member

I'll look into this a bit more.

@jamesmkrieger
Copy link
Contributor Author

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Improvement to an already-existing feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants