LOOS  v2.3.2
loos.pyloos.trajectories.VirtualTrajectory Class Reference

Virtual trajectory composed of multiple Trajectory objects This class can combine multiple loos.pyloos.Trajectory objects into one big "virtual" trajectory. More...

Inheritance diagram for loos.pyloos.trajectories.VirtualTrajectory:
Collaboration diagram for loos.pyloos.trajectories.VirtualTrajectory:

Public Member Functions

def __init__ (self, trajs, kwargs)
 
def append (self, traj)
 
def stride (self, n)
 
def skip (self, n)
 
def allStride (self, n)
 
def allSkip (self, n)
 
def setSubset (self, selection)
 
def frame (self)
 
def index (self)
 
def frameLocation (self, i)
 Returns information about the ith frame in the VirtualTrajectory The tuple returned has the following format: More...
 
def __len__ (self)
 
def __getitem__ (self, i)
 
def __iter__ (self)
 
def reset (self)
 
def next (self)
 

Detailed Description

Virtual trajectory composed of multiple Trajectory objects This class can combine multiple loos.pyloos.Trajectory objects into one big "virtual" trajectory.

Any skips or strides set in the contained trajectories will be honored. In addition, a skip and a stride for the whole meta-trajectory are available. These can be set via keyword arguments when creating a VirtualTrajectory,

Keyword Description
skip=n Skip the first n-frames of the virtual trajectory
stride=n Step through the virtual trajectory n frames at a time
iterator=i Use the python iterator object i to select frames from the virtual trajectory

There is no requirement that the subsets used for all trajectories must be the same. Ideally, the frame (subset) that is returned should be compatible (e.g. same atoms in the same order), but the models used for each trajectory (and the corresponding subset selection) can vary. Why would you want to do this? Imagine combining three different GPCRs where the subsets are the common trans-membrane C-alphas. This makes processing all of the ensembles together easier.

WARNING

Since each contained trajectory can have a different set of shared atoms it updates, care must be taken when pre-selecting atoms.

Examples:

1 model = loos.createSystem('foo.pdb')
2 Takes a filename (\a fname) and an AtomicGroup model (\a model).
3 Takes a filename (\a fname) and an AtomicGroup model (\a model).
4 Takes a filename (\a fname) and an AtomicGroup model (\a model).
5 traj1 = loos.pyloos.Trajectory('foo-1.dcd', model)
6 traj2 = loos.pyloos.Trajectory('foo-2.dcd', model)
7 vtraj = loos.pyloos.VirtualTrajectory(traj1, traj2)
8 
9 for frame in vtraj:
10  print frame.centroid()

Adding another trajectory in with its own stride and skip

1 traj3 = loos.pyloos.Trajectory('foo-3.dcd', skip=50, stride=2)
2 vtraj.append(traj3)

Same as above but stride through the combined trajectory

1 vtraj10 = loos.pyloos.VirtualTrajectory(traj1, traj2, stride=10)
Combines multiple loos.pyloos.Trajectory objects into one big virtual trajectory
>>> vtraj = loos.pyloos.VirtualTrajectory(traj1, traj2, traj3)
    Keyword arguments:
        skip = # of frames to skip at start of composite traj
      stride = # of frames to step through in the composite traj
    iterator = Python iterator used to pick frames from the composite traj

See the Doxygen documentation for more details.

Definition at line 304 of file trajectories.py.

Member Function Documentation

def loos.pyloos.trajectories.VirtualTrajectory.__getitem__ (   self,
  i 
)
Return the ith frame in the composite trajectory.  Supports
Python slicing.  Negative indices are relative to the end of
the composite trajectory.

Definition at line 484 of file trajectories.py.

def loos.pyloos.trajectories.VirtualTrajectory.__len__ (   self)
Total number of frames

Definition at line 475 of file trajectories.py.

def loos.pyloos.trajectories.VirtualTrajectory.allSkip (   self,
  n 
)
Sets the skip of all contained trajectories

Definition at line 369 of file trajectories.py.

def loos.pyloos.trajectories.VirtualTrajectory.allStride (   self,
  n 
)
Sets the stride of all contained trajectories

Definition at line 361 of file trajectories.py.

def loos.pyloos.trajectories.VirtualTrajectory.append (   self,
  traj 
)
Add a trajectory to the end of the virtual trajectory.  Resets
the iterator state

Definition at line 339 of file trajectories.py.

def loos.pyloos.trajectories.VirtualTrajectory.frame (   self)
Return the current frame/model.  If the iterator is past the
end of the trajectory list, return the last valid frame.

Definition at line 384 of file trajectories.py.

def loos.pyloos.trajectories.VirtualTrajectory.frameLocation (   self,
  i 
)

Returns information about the ith frame in the VirtualTrajectory The tuple returned has the following format:

1 (frame-index, traj-index, trajectory, real-frame-within-trajectory)

Consider the following,

1 t1 = loos.pyloos.Trajectory('foo.dcd', model) # 50 frames
2 t2 = loos.pyloos.Trajectory('bar.dcd', model) # 25 frames
  • frame-index is the index into the corresponding trajectory object. For example, frameLocation(50) would have a frame-index of 0 because vt[50] would return the first frame from t2.
  • traj-index is the index into the list of managed trajectories for the frame. In the above example, the traj-index will be 1.
  • trajectory is the actual loos.pyloos.Trajectory object that contains the frame.
  • real-frame-within-trajectory is the same as calling trajectory.frameNumber(frame-index).

Instead of the t1 above, imagine it was setup this way,

1 t1 = loos.pyloos.Trajectory('foo.dcd', model, skip=25)

Now, vt.frameLocation(0) will return (0, 0, t1, 25), and vt.frameLocation(25) will return (25, 1, t2, 0)

Python documentation:

Return info about where a frame comes from.
>>> (frame-index, traj-index, trajectory, real-frame-within-trajectory) = vtraj.frameLocation(i)

Definition at line 438 of file trajectories.py.

def loos.pyloos.trajectories.VirtualTrajectory.index (   self)
Return index into composite trajectory for current frame

Definition at line 399 of file trajectories.py.

def loos.pyloos.trajectories.VirtualTrajectory.setSubset (   self,
  selection 
)
Set the subset selection for all managed trajectories

Definition at line 377 of file trajectories.py.

def loos.pyloos.trajectories.VirtualTrajectory.skip (   self,
  n 
)
Set the skip of the combined trajectory

Definition at line 354 of file trajectories.py.

def loos.pyloos.trajectories.VirtualTrajectory.stride (   self,
  n 
)
Set the stride of the combined trajectory

Definition at line 347 of file trajectories.py.


The documentation for this class was generated from the following file: