LOOS 4.1.0
The Lightweight Object Oriented Structural analysis library/toolkit
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
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:
Inheritance graph
[legend]
Collaboration diagram for loos.pyloos.trajectories.VirtualTrajectory:
Collaboration graph
[legend]

Public Member Functions

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

Protected Member Functions

 _initFrameList (self)
 
 _getSlice (self, s)
 

Protected Attributes

 _skip
 
 _stride
 
 _nframes
 
 _iterator
 
 _trajectories
 
 _index
 
 _framelist
 
 _trajlist
 
 _stale
 

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:

model = loos.createSystem('foo.pdb')
Takes a filename (\a fname) and an AtomicGroup model (\a model).
Takes a filename (\a fname) and an AtomicGroup model (\a model).
Takes a filename (\a fname) and an AtomicGroup model (\a model).
traj1 = loos.pyloos.Trajectory('foo-1.dcd', model)
traj2 = loos.pyloos.Trajectory('foo-2.dcd', model)
vtraj = loos.pyloos.VirtualTrajectory(traj1, traj2)
for frame in vtraj:
print frame.centroid()
Python-based wrapper for LOOS Trajectories This class turns a loos Trajectory into something more pyt...
Definition trajectories.py:55
Virtual trajectory composed of multiple Trajectory objects This class can combine multiple loos....
Definition trajectories.py:311
AtomicGroup createSystem(const std::string &filename)
Factory function for reading in structure files.
Definition sfactories.cpp:117

Adding another trajectory in with its own stride and skip

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

Same as above but stride through the combined trajectory

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.

Member Function Documentation

◆ __getitem__()

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.

Reimplemented in loos.pyloos.trajectories.AlignedVirtualTrajectory.

◆ __len__()

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

◆ allSkip()

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

◆ allStride()

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

◆ append()

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

Reimplemented in loos.pyloos.trajectories.AlignedVirtualTrajectory.

◆ frame()

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.

◆ frameBoundaries()

loos.pyloos.trajectories.VirtualTrajectory.frameBoundaries ( self)
Return a list containing the index of the first frame associated with
each traj
>>> b = vt.frameBoundaries()
len(b) will be the number of trajectories in vt + 1.
-> can slice the data from the nth traj from an array with b[n]:b[n+1]

◆ frameLocation()

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

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

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

Consider the following,

t1 = loos.pyloos.Trajectory('foo.dcd', model) # 50 frames
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,

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)

◆ index()

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

◆ setSubset()

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

◆ skip()

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

◆ stride()

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

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