Package schrodinger :: Package application :: Package desmond :: Package packages :: Module traj :: Class Frame
[hide private]
[frames] | no frames]

Class Frame

object --+
         |
        Frame


This class, as its name suggests, represents a single trajectory frame.
So far, we allow a frame to be mutated in the following ways:
- Assign a new chemical time
- Reduce to a subset of particles
- Coordinates of all particles are translated

We call changes generally as ``decorations''. They might not make into
the frame data, or at least not immediately. Why? This avoids making
multiple expensive copies of the data.

Instance Methods [hide private]
 
__init__(self, source, index)
x.__init__(...) initializes x; see help(type(x)) for signature
 
__str__(self)
str(x)
 
__deepcopy__(self, memo={})
 
_frame(self)
Return the raw frame object where decorations haven't be solidified.
 
_mapped_index(self, i)
 
_copy_and_decorate(self, obj, indices)
Makes a copy of the native trajectory-frame object and decorates the copied object if necessary.
 
_get_native_object(self, indices=None)
 
_make(self, force=False)
Solidifies decorations.
 
source(self)
 
copy(self)
Return a copy of this Frame object.
 
pos(self, i=None)
Return the position vector(s).
 
vel(self, i=None)
Return the velocity vector(s).
 
hijackPos(self, impos)
Tentatively replace the internal position array of this L{Frame} object with an external numpy array C{impos}.
 
_getTime(self)
 
_setTime(self, value)
 
reduce(self, indices, is_sorted=False, copy=True)
Keep only the atoms specified by indices, the other atoms will be deleted from this frame.
 
moveby(self, x, y, z)
Translate all positions by the given x, y, and z.
 
write(self, writer)
Write out this frame using the given writer.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Properties [hide private]
  natoms
  time
  box
  orig_index

Inherited from object: __class__

Method Details [hide private]

__init__(self, source, index)
(Constructor)

 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

__str__(self)
(Informal representation operator)

 

str(x)

Overrides: object.__str__
(inherited documentation)

_copy_and_decorate(self, obj, indices)

 

Makes a copy of the native trajectory-frame object and decorates the copied object if necessary.

Parameters:
  • obj (A native frame type, e.g., molfile.Frame) - A native frame

_make(self, force=False)

 

Solidifies decorations. If there are decorations or force == True, this function might make a copy of the frame data.

copy(self)

 

Return a copy of this Frame object. The position and velocity arrays will be copied.

pos(self, i=None)

 

Return the position vector(s).

@type i: Any of the following types:
         C{None}: Return the whole position-vector array;
         C{int} : C{i} should be a GID, and this function return
                  position vector of the particle C{i}.
         C{Iterable}: C{i} should be a "list" of GIDs, and this function
                  returns a NEW numpy array of position-vectors of the
                  specified particles.

vel(self, i=None)

 

Return the velocity vector(s).
This method may throw if this frame doesn't have velocity data.

@type i: Any of the following types:
         C{None}: Return the whole velocity-vector array;
         C{int} : C{i} should be a GID, and this function return
                  velocity vector of the particle C{i}.
         C{Iterable}: C{i} should be a "list" of GIDs, and this function
                  returns a NEW numpy array of position-vectors of the
                  specified particles.

hijackPos(self, impos)

 

Tentatively replace the internal position array of this L{Frame} object
with an external numpy array C{impos}. We can call the external array
"imposter". After calling this method, the L{pos} method will return
values from the imposter until the imposter is removed (by calling
C{hijackPos(None)}). The imposter should be a Nx3 numpy array, where N
can be of any size.
Note the impacts on other methods of this class:
- pos     Use C{impos}.
- copy    The entire C{impos} array will be copied into the copy of
          this C{Frame} object.
- reduce  Still function in the same way, but note that the C{impos}
          array will not be changed by these methods.
- moveby  The same as C{reduce}
- write   Still function in the same way, note that it's the internal
          position array, not C{impos}, that will be written out.

@type  impos: C{None}, or C{numpy.ndarray} of size Nx3, where N is
              arbitray number
@param impos: The position array to tentatively replac the internal
              position array in this L{Frame} object. If the value is
              C{None}, we remove the "imposter" and recover the internal
              position array.

reduce(self, indices, is_sorted=False, copy=True)

 

Keep only the atoms specified by indices, the other atoms will be deleted from this frame.

Parameters:
  • is_sorted - Is indices sorted? If so, this function will NOT have to sort it again.
  • copy - If true, this function will make a copy of this frame and reduce atoms in this copy, and finally return the copy.

Property Details [hide private]

natoms

Get Method:
unreachable.natoms(self)

time

Get Method:
_getTime(self)
Set Method:
_setTime(self, value)

box

Get Method:
unreachable.box(self)

orig_index

Get Method:
unreachable.orig_index(self)