Created
March 13, 2016 18:51
-
-
Save hainm/31e18ade8c1fb53c1d26 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pytraj as pt | |
import numpy as np | |
traj = pt.iterload('tz2.nc', 'tz2.parm7') | |
# note: use pt.load method if your trajectory is fit well to memory | |
c0 = pt.center_of_mass(traj, ':1-3') | |
c1 = pt.center_of_mass(traj, ':4-7') | |
c2 = pt.center_of_mass(traj, ':8-10') | |
c3 = pt.center_of_mass(traj, ':11-13') | |
# create a new array with shape=(n_frames, 4, 3) | |
xyz = np.hstack((c0, c1, c2, c3)).reshape(traj.n_frames, 4, 3) | |
print(xyz.shape) | |
# create a fake Topology with 4 atoms | |
fake_top = pt.tools.make_fake_topology(n_atoms=4) | |
# save to disk if using vmd | |
# fake_top.save('myfakeparm.parm7') | |
print(fake_top) | |
# write your fake trajectory | |
pt.write_traj('mytraj.nc', xyz, top=fake_top, overwrite=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment