pytraj icon indicating copy to clipboard operation
pytraj copied to clipboard

write_traj problem when selecting a mask and specific frames

Open krlitros87 opened this issue 2 years ago • 1 comments

Hi, I'm trying to save multiple frames from a trajectory, extracting only a selection (with mask) of atoms/residues pt.write_traj('t.pdb',traj,overwrite=True,options='multi',frame_indices=range(0,traj.n_frames,int(traj.n_frames/int(frames)))) This creates a single pdb file without problems.

But when trying to save only a selection of atoms per file, pt.write_traj('t.pdb',traj(mask=(':1-476')),overwrite=True,options='multi',frame_indices=range(0,traj.n_frames,int(traj.n_frames/int(frames)))) it will save all the frames of the simulation, instead of the selection of frames I choose with 'frame_indices'

What could be the problem? Thanks!

krlitros87 avatar Oct 11 '22 18:10 krlitros87

Dear @krlitros87 It's a known bug. Can you please try pytraj.iterframe instead?

pt.write_traj("abc.pdb", pt.iterframe(traj, mask='@CA', frame_indices = range(0, 8, 2)),  options='multi')

hainm avatar Oct 13 '22 19:10 hainm