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.Trajectory Class Reference

Python-based wrapper for LOOS Trajectories This class turns a loos Trajectory into something more python-like. More...

Inheritance diagram for loos.pyloos.trajectories.Trajectory:
Inheritance graph
[legend]
Collaboration diagram for loos.pyloos.trajectories.Trajectory:
Collaboration graph
[legend]

Public Member Functions

 __init__ (self, fname, model, **kwargs)
 Instantiate a Trajectory object.
 
 stride (self, n)
 
 skip (self, n)
 
 fileName (self)
 
 setSubset (self, selection)
 
 __iter__ (self)
 
 __len__ (self)
 
 reset (self)
 
 __next__ (self)
 
 nextFrame (self)
 
 trajectory (self)
 
 model (self)
 
 readFrame (self, i)
 
 frame (self)
 
 realIndex (self)
 
 index (self)
 
 frameNumber (self, i)
 
 __getitem__ (self, i)
 

Protected Member Functions

 _initFrameList (self)
 
 _getSlice (self, s)
 

Protected Attributes

 _skip
 
 _stride
 
 _iterator
 
 _subset
 
 _model
 
 _fname
 
 _traj
 
 _stale
 
 _framelist
 
 _index
 

Detailed Description

Python-based wrapper for LOOS Trajectories This class turns a loos Trajectory into something more python-like.

Behind the scenes, it wraps a loos::AtomicGroup and a loos::Trajectory. The behavior of the trajectory can be controlled through passed keywords,

Keyword Description
skip=n Skip the first n-frames of the wrapped trajectory
stride=n Step through the wrapped trajectory n-frames at a time
iterator=i Use the python iterator object i to select frames from the wrapped trajectory
subset=s Use 's' to select a subset of the model to use for each frame

Remember that all atoms are shared. If you want to decouple the trajectory from other groups, pass it a copy of the model.

examples:

model = loos.createSystem('foo.pdb')
traj = loos.pyloos.Trajectory('foo.dcd', model)
calphas = loos.selectAtoms(model, 'name == "CA"')
for frame in traj:
print calphas.centroid()
Python-based wrapper for LOOS Trajectories This class turns a loos Trajectory into something more pyt...
Definition trajectories.py:55
AtomicGroup selectAtoms(const AtomicGroup &source, const std::string selection)
Applies a string-based selection to an atomic group...
Definition utils.cpp:183
AtomicGroup createSystem(const std::string &filename)
Factory function for reading in structure files.
Definition sfactories.cpp:117

The same thing but skipping the first 50 frames and taking every other frame

traj = loos.pyloos.Trajectory('foo.dcd', model, skip=50, stride=2)

Only use frames 19-39 (i.e. the 20th through 40th frames)

traj = loos.pyloos.Trajectory('foo.dcd', model, iterator=range(19,40))

An alternative way of only iterating over a subset...

model = loos.createSystem('foo.pdb')
traj = loos.pyloos.Trajectory('foo.dcd', model, subset='name == "CA"')

Decouple the model stored in the trajectory,

traj = loos.pyloos.Trajectory('foo.dcd', model.copy())
Python-based wrapper for LOOS Trajectories
>>> model = loos.createSystem('foo.pdb')
>>> traj = loos.pyloos.Trajectory('foo.dcd', model)

keyword args:
    skip = # of frames to skip from start
  stride = # of frames to step through
iterator = Python iterator used to pick frame (overrides skip and stride)
  subset = Selection used to pick subset for each frame

See the Doxygen documentation for more details.

Member Function Documentation

◆ __getitem__()

loos.pyloos.trajectories.Trajectory.__getitem__ ( self,
i )
Handle array indexing and slicing.  Negative indices are
relative to the end of the trajectory

◆ __len__()

loos.pyloos.trajectories.Trajectory.__len__ ( self)
Number of frames in the trajectory

◆ fileName()

loos.pyloos.trajectories.Trajectory.fileName ( self)
Return the filename that this Trajectory represents

◆ frame()

loos.pyloos.trajectories.Trajectory.frame ( self)
Return the current frame (subset)

◆ frameNumber()

loos.pyloos.trajectories.Trajectory.frameNumber ( self,
i )
Returns the real frame numbers corresponding to the passed indices.  Can accept
either an integer or a list of integers.

For example:
>>> t = loos.pyloos.Trajectory('foo.dcd', model, skip=50)
>>> t.frameNumber(0)
50
>>> t.frameNumber(range(0,2))
[50, 51]

◆ index()

loos.pyloos.trajectories.Trajectory.index ( self)
The state of the iterator

◆ model()

loos.pyloos.trajectories.Trajectory.model ( self)
Return the current model

◆ nextFrame()

loos.pyloos.trajectories.Trajectory.nextFrame ( self)
Return the next frame in the trajectory, or False.
Intended for use in a while loop:
  while traj.nextFrame(): do_something

◆ readFrame()

loos.pyloos.trajectories.Trajectory.readFrame ( self,
i )
Read a frame and update the model

◆ realIndex()

loos.pyloos.trajectories.Trajectory.realIndex ( self)
The 'real' frame in the trajectory for this index

◆ reset()

loos.pyloos.trajectories.Trajectory.reset ( self)
Reset the iterator

◆ setSubset()

loos.pyloos.trajectories.Trajectory.setSubset ( self,
selection )
Set the subset used when iterating over a trajectory.
The selection is a LOOS selection string.

◆ skip()

loos.pyloos.trajectories.Trajectory.skip ( self,
n )
Skip this number of frames at the start of the trajectory

◆ stride()

loos.pyloos.trajectories.Trajectory.stride ( self,
n )
Step through the trajectory by this number of frames

◆ trajectory()

loos.pyloos.trajectories.Trajectory.trajectory ( self)
Access the wrapped loos.Trajectory

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