cpptraj icon indicating copy to clipboard operation
cpptraj copied to clipboard

Support reading xyz format for dataset?

Open hainm opened this issue 6 years ago • 3 comments

hi, writing .xyz format is ok in pytraj but getting error for reading.

In [12]: traj = pt.load('../tz2.crd', '../tz2.parm7')

In [13]: traj.save("test.xyz")

In [14]: pt._verbose()

In [15]: pt.load("test.xyz", traj.top)
	Reading '/Users/haichit/pytraj_github/pytraj/cpptraj/test/Test_XYZformat/test.xyz' as XYZ
	Single title detected.
Error: Cannot use trajectories with unknown # of frames as data set.

hainm avatar Apr 02 '19 03:04 hainm

Can cpptraj support reading xyz format to DataSet_Coords_TRJ since pytraj uses it under the hood? thanks.

hainm avatar Apr 02 '19 03:04 hainm

Hmm...I'll have to think about the best way to do this. Since the XYZ format is not well-defined, the only way to reliably detect the number of frames in an XYZ trajectory is to read through the actual trajectory. We could probably estimate the number of frames semi-reliably assuming the number of atoms/title sizes/etc do not change throughout the trajectory. Also, it's likely that XYZ format trajectories are not that long, so doing a blank read through to determine the number of frames might not be that costly.

drroe avatar Apr 05 '19 12:04 drroe

Also, it's likely that XYZ format trajectories are not that long, so doing a blank read through to determine the number of frames might not be that costly.

yeah, agree.

hainm avatar Apr 05 '19 15:04 hainm