-
Notifications
You must be signed in to change notification settings - Fork 663
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
Applying Transformation to Chain of Traj doesn't Apply to First Frame of 2nd, 3rd... trajectories #3657
Comments
It seems that when chain.py uses activate_reader.ts, it is using a separate Timestep (different id() ) with the Timestep instance of the universe. Thus, when wrap.wrap() called the AtomGroup.wrap function, the latter is still on the last frame of the previous trajectory file, and does not wrap the appropriate frame. |
Hi @jaclark5 thanks for the detailed error report! I'm having a little trouble reproducing the problem, I did the code snippet below to try and reproduce and it seems to work fine (writes out a file where atoms either have positions of 0 or 1 for all frames). I'm not sure it will be possible for import MDAnalysis as mda
from MDAnalysisTests.datafiles import GRO, TRR
from MDAnalysis import transformations
u = mda.Universe(GRO, [TRR, TRR])
def set_every_other_zero(ts):
ts.positions[::2] = 0.0
return ts
def set_every_other_one(ts):
ts.positions[1::2] = 1.0
return ts
u.trajectory.add_transformations(set_every_other_zero,
set_every_other_one)
ag = u.atoms[:10]
with mda.Writer('new.pdb') as w:
for ts in u.trajectory:
w.write(ag) |
Hi @richardjgowers, the issue seems to specifically be with the |
This issue can be resolved with the following two lines of code:
|
@jaclark5 if you've already identified a fix, can I encourage you to create a PR? We have some documention in the User Guide on Contributing to the Main Code Base. |
@orbeckst it was brought up in the review of my Pull Request that this could also be an issue in the unwrap function. Indeed this is the case. If I run the example provided in this issue with a print statement in the unwrap function I obtain the following output: Notice again in the transition from dump_1 to dump_2, that the ts frame is correct, but it never transformed since the atom group ts has not been updated. |
Using the same example given in this issue, I looked at
In
Output: trans type, ts frame, ts id, mobile frame, mobile id Notice again that when the timestep switches to the second trajectory, the atom group uses the last frame of the previous trajectory. The result is that the first frame of the second trajectory is skipped all together. |
As this seems to be a broader problem with a common solution you can do one PR. |
Hey sure! I can get to it next week.
… On May 12, 2022, at 2:34 AM, Oliver Beckstein ***@***.***> wrote:
@jaclark5 if you've already identified a fix, can I encourage you to create a PR?
We have some documention in the User Guide on Contributing to the Main Code Base.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.
|
Expected behavior
After creating a universe with multiple trajectory files, and a series of transformations are applied following the protein example. Those transformations are expected to be applied to all frames.
Actual behavior
The first frame of the 2nd, 3rd, etc. trajectories are unwrapped. This is evidenced by writing out the coordinates to the screen, or writing to a pdb file.
It seems to be a discrepancy with the atoms.positions and ts._pos being synced, as the later is used by the Writer.
Code to reproduce the behavior
Run short LJ lammps simulation.
Import LAMMPS trajectories, center around bonded molecule, and write to pdb.
Current version of MDAnalysis
The text was updated successfully, but these errors were encountered: