Amber-MD / pytraj

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

pytraj load does not properly filter by mask for pdb file #1414

Closed whitleyo closed 7 years ago

whitleyo commented 7 years ago

Hello,

I've been trying to use openmm for MD simulations, and when I try loading an openmm generated pdb file into pytraj, if I specify '!:WAT,CL-,Na+' as a mask, those residues are not removed.

Example:

traj2 = pt.load('test_omm_heat_solv_equil1.pdb', mask = '!:WAT,CL-,Na+')

traj2 Out[37]: pytraj.Trajectory, 10 frames: Size: 0.005610 (GB) <Topology: 25098 atoms, 7864 residues, 7751 mols, PBC with box type = ortho>

There are 115 residues in my protein, and ideally there should only be 1 molecule. It should be noted that I generated the pdb file by loading tleap generated amber crd and amber prmtop files into an openmm simulation, via the general paradigm:

prmtop = app.AmberPrmtopFile('input.prmtop') inpcrd = app.AmberInpcrdFile('input.inpcrd')

The water and ions are within the inpcrd and prmtop files generated by tleap.

Thanks for any input as to what might be going on.

hainm commented 7 years ago

hi, might be a bug

can you try

traj2 = pt.load('test_omm_heat_solv_equil1.pdb')
mask = '!:WAT,CL-,Na+'
traj3 = traj2[mask] # create new trajectory with given mask

# Or
traj2.strip(':WAT,Cl-,Na+') # striping based on mask and updated coordinates.
hainm commented 7 years ago

try to get resname

set(res.name for res in traj.top.residue) # not remember exact syntax right now.
hainm commented 7 years ago

I also suspect that openmm does not respect amber resname when writing pdb.

hainm commented 7 years ago

Just tried with tz2.pdb

In [8]: traj = pt.load('./tz2.pdb')

In [9]: 'WAT' in set(res.name for res in traj.top.residues)
Out[9]: True

In [10]: traj2 = pt.load('./tz2.pdb', mask='!:WAT')

In [11]: 'WAT' in set(res.name for res in traj2.top.residues)
Out[11]: False

Likely that my suspect is right

I also suspect that openmm does not respect amber resname when writing pdb.

hainm commented 7 years ago

It's been a while and have not heard from you yet, so I am assuming things are fine. Do feel free to reopen.