-
Notifications
You must be signed in to change notification settings - Fork 38
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
reimaging and interfacing with mdraj #260
Comments
Sorry the formatting got kind of messed up. I made a gist version here. In the mean time, while pytraj --> mdtraj is nontrivial, I hope someone finds this useful: https://gist.github.com/evanfeinberg/6d1379b1556cef92d0ec#file-reimage-py |
hi, https://help.github.com/articles/github-flavored-markdown/ Per loading back from traj = md.load(traj_file)
traj_pytraj = mdio.load_mdtraj(traj)
traj_pytraj.autoimage()
traj.xyz[:] = traj_pytraj.xyz / 10. # need to convert from `Angstrom` to `nm`
# that's it. and you just use xyz-updated`traj` as `mdtraj` object. Note: calling Hai |
@hainm , that's awesome!! I just tested it and it worked. so much better. Thank you!!! |
great. @evanfeinberg: I am just curious what kind of pairwise distance you want do calculate? import pytraj.common_actions as pyca
from pytraj import load_sample_data
traj = load_sample_data()
d = pyca.calc_matrix(traj[0], '@CA', traj.top)
print (d.to_ndarray()) # 1D array, need to reshape to n_atoms * n_atoms |
Hi for some reason I only just saw this now -- will do this asap and report back. |
Hi,
On suggestion of @swails , I'm moving mdtraj/mdtraj#814 to here. Thanks to @hainm , I have much cleaner code now for reimaging a single pdb. load_mdtraj was very helpful.
Since I want to add pairwise distances as features to my trajectory, I need to reimage all trajectories. However, I realize that while it's easy to go from mdtraj --> pytraj, it's nontrivial to go from pytraj --> mdtraj , either directly or via HDF5 format. So I had to develop a little workaround. It seems to work, but it would be nice if it were cleaner. The gist is that I load a .h5 trajectory in mdtraj, use pytraj's load_mdtraj feature to transfer it over, autoimage() it, save it as a dcd trajectory, separately save a frame as a pdb to act as the topology, re-load that dcd/pdb combo into mdtraj, and then save it once again as a .h5 to complete the cycle. It would be great if I could circumvent the middle steps and just dump a pytraj object straight to h5, or convert it back somehow to an mdtraj object. Any thoughts?
Cheers,
Evan
The text was updated successfully, but these errors were encountered: