I am trying to convert trajectory file to numpy file. And I tried various ways based on the Tutorial.
1. How can I export timestep data?
>import MDAnalysis as mda
>u= mda.Universe("myfile.pdb","myfile.xtc")
>ts.positions
array([49.750004,68.86,63.250004],[48.83,69.18,63.620003],[49.950005,69.23,62.300003], ..., [70.07001,64.9,37.960003],[71.1,65.26,38.54],[70.130005,64.25,36.86]], dtype=float32]
>>> with mda.Writer("test.xls", ts.positions) as W:
... for ts in u.trajectory:
... W.write(ts.positions)
... TypeError: No trajectory or frame writer for format 'XLS'
How can I export it?
2. Is there any way to transfer trajectory file(xtc) to numpy(npy)?
In tutorial 6.26, they say The
MemoryReader can be used to either directly generate a trajectory as a numpy array or by transferring an existing trajectory to memory.
So I expect MemoryReader can help me to convert trajectory as a numpy array, but in tutorial there are none of the explanation about it. So could you hlep me to do this?
Thanks a lot.