Closed pindakaas42 closed 5 years ago
Most pytraj functions take a Trajectory-like or a list of Trajectory.
can you post an example about taking list of trajectory here? I don't recall I implemented it.
Would it be possible to implement this behaviour for compute?
Work around is join the trajectories (in memory) to a single one; or using iterload(list_of_filenames, ...)
pt.iterload([fn0, fn1, ...], top=...)
otherwise, try below
from itertools import chain
class FrameIter:
def __init__(self, trajs):
self._trajs = trajs
@property
def top(self):
# assume all trajs have the same topology
return self._trajs[0].top
def __iter__(self):
for frame in chain(self._trajs):
yield frame
In [25]: traj = pt.datafiles.load_tz2()
In [26]: traj2 = pt.datafiles.load_tz2()
In [27]: pt.compute(['rmsd @CA', 'radgyr'], FrameIter([traj, traj2]))
Out[27]:
OrderedDict([('RMSD_00000',
array([ 1.94667955e-07, 2.54596866e+00, 4.22333034e+00, ...,
4.97189564e+00, 5.53947712e+00, 4.83201237e+00])),
('RoG_00001',
array([ 9.4451051 , 9.57459712, 10.19233494, ..., 7.48343543,
7.43238185, 7.62039157])),
('RoG_00001[Max]',
array([ 15.79878713, 16.75193828, 16.92138667, ..., 13.66140902,
13.25220774, 12.69288639]))])
Hallo, first thank you for your answers the second one is a great idea. As for an example for functions that take lists of trajectories distance and angle , also dihedral and angle, come to mind, although for example rmsd or drmsd don't take lists.
As for an example for functions that take lists of trajectories distance and angle , also dihedral and angle, come to mind, although for example rmsd or drmsd don't take lists.
Thanks. I did not realize that those methods can accept a list of trajs. It's side effect. :D I will recommend user to follow 2nd solution above. Thanks for trying. Cheers and I close this issue now.
Reopen until I update example of passing list of trajs for the docs of pytraj.compute
.
It's actually also mentioned in the documentation. That's how I started doing it in the first place.
Ha, I see, my bad.
Most pytraj functions take a Trajectory-like or a list of Trajectory. Would it be possible to implement this behaviour for compute?
Thank you very much.