i am using this code to obtain a complete trajectory of nacl association
from westpa.analysis import BasicMDTrajectory
from westpa.analysis import Run
run = Run.open('west.h5')
iter_num = int(input('iteration number: ')) # 32
walker_num = int(input('segment number: ')) # 18
iteration = run.iteration(iter_num)
walker = iteration.walker(walker_num)
trace = walker.trace()
trajectory = BasicMDTrajectory(traj_ext = '.xtc', top='step4.2_equilibration_nowater.gro', state_ext='.gro')
traj = trajectory(walker)
traj.save_xtc(f'traj_iter_{iter_num}_walker_{walker_num}')
run.close()
i have a file called step4.2_equilibration_nowater.gro in the common_files folder and the trajectory is .xtc (i am using GROMACS) then i tried to open one segment with the .gro file in VMD just to make sure that the files are correct and it opened.
However, this code produces an error:
Traceback (most recent call last):
File "/lfs01/workdirs/cairo029u1/1PHD/WESTPA/trial/nacl_gromacs/gromacs/westpa_files/get_traj.py", line 14, in <module>
traj = trajectory(walker)
File "/home/cairo029u1/.local/lib/python3.9/site-packages/westpa/analysis/trajectories.py", line 74, in __call__
value = self.fget(obj, include_initpoint=include_initpoint, **kwargs)
File "/home/cairo029u1/.local/lib/python3.9/site-packages/westpa/analysis/trajectories.py", line 273, in fget
frame = mdtraj.load(path, top=traj.top)
File "/home/cairo029u1/.local/lib/python3.9/site-packages/mdtraj/core/trajectory.py", line 430, in load
t = loader(tmp_file, **kwargs)
File "/home/cairo029u1/.local/lib/python3.9/site-packages/mdtraj/formats/gro.py", line 101, in load_gro
return f.read_as_traj(n_frames=n_frames, stride=stride,
File "/home/cairo029u1/.local/lib/python3.9/site-packages/mdtraj/formats/gro.py", line 222, in read_as_traj
coordinates, time, unitcell_vectors = self.read(stride=stride, atom_indices=atom_indices)
File "/home/cairo029u1/.local/lib/python3.9/site-packages/mdtraj/formats/gro.py", line 279, in read
frame_xyz, frame_box, frame_time = self._read_frame()
File "/home/cairo029u1/.local/lib/python3.9/site-packages/mdtraj/formats/gro.py", line 368, in _read_frame
assert self.n_atoms == int(line.strip())
AssertionError
what is the problem here?
Note: i modified the post_iter.sh to make it remove the pbc and the water (keep only two atoms Na and Cl) and saved the file as seg.xtc