Amber-MD / pytraj

Python interface of cpptraj
https://amber-md.github.io/pytraj
170 stars 38 forks source link

how to remove box information in the trajectory? #1463

Closed autodataming closed 5 years ago

autodataming commented 6 years ago

how to remove box information in the trajectory by pytraj?

hainm commented 6 years ago

hi, sorry for the late reply. (I thought your account is a spammer). What's your aim of removing the box information?

autodataming commented 6 years ago

Thank you. The aim is to extract protein conformations (no solvent and no water) from MD trajectory and get new mdcrd file and its corresponding prmtop file.

I hvae solved the problem by CPPTRAJ command. If pytraj can do this, it will be very cool.

hainm commented 6 years ago

hi @autodataming, can you try with below code and let me know if that works for you.

n [26]: traj = pt.datafiles.load_tz2_ortho()[:]

In [27]: traj
Out[27]: 
pytraj.Trajectory, 10 frames: 
Size: 0.001183 (GB)
<Topology: 5293 atoms, 1704 residues, 1692 mols, PBC with box type = ortho>

In [28]: traj.strip(':WAT')
Out[28]: 
pytraj.Trajectory, 10 frames: 
Size: 0.000049 (GB)
<Topology: 220 atoms, 13 residues, 1 mols, PBC with box type = ortho>

In [29]: traj.unitcells = None

In [30]: traj.top.box = pt.core.box.Box()

In [31]: traj.top.save('new.prmtop')

In [32]: pt.write_traj('new.nc', traj, overwrite=True)

In [33]: traj2 = pt.load('new.nc', 'new.prmtop')

In [34]: traj2
Out[34]: 
pytraj.Trajectory, 10 frames: 
Size: 0.000049 (GB)
<Topology: 220 atoms, 13 residues, 1 mols, non-PBC>