Note
syntax might be changed in future.
try pytraj
online:
In [1]: import pytraj as pt
In [2]: from pytraj.datasets import DatasetList as CpptrajDatasetList
# create pytraj.TrajectoryIterator, no data is actually loaded yet.
In [3]: traj = pt.iterload("tz2.ortho.nc", "tz2.ortho.parm7")
In [4]: traj
Out[4]:
pytraj.TrajectoryIterator, 10 frames:
Size: 0.001183 (GB)
<Topology: 5293 atoms, 1704 residues, 1692 mols, PBC with box type = ortho>
# create a list of commands (cpptraj's style)
# advantage: endless streaming calculation, even TB of data.
In [5]: commands = ['autoimage',
...: 'distance :3 :7',
...: 'distance :3 :10',
...: 'vector :2 :3',
...: 'vector box',
...: 'vector ucellx',
...: ]
...:
# create a CpptrajDatasetList object to hold all datasets
In [6]: dslist = CpptrajDatasetList()
In [7]: dslist
Out[7]: <pytraj.datasets.CpptrajDatasetList - 0 datasets>
# create an ActionList object to hold all actions
In [8]: actlist = pt.ActionList(commands, traj.top, dslist=dslist)
# perform the actions, only a single frame is loaded
# data is saved to dslist
In [9]: for frame in traj:
...: actlist.compute(frame)
...: dslist
...:
Out[9]: <pytraj.datasets.CpptrajDatasetList - 5 datasets>
# get values for each Dataset
In [10]: for d in dslist: print(d)