schrodinger.application.desmond.packages.traj module

Molecular dynamics trajectory handling module Define common APIs for various trajectory formats. Basic trajectory handling algorithms are also implemented here.

Copyright Schrodinger, LLC. All rights reserved.

class schrodinger.application.desmond.packages.traj.DtrSource(reader, name='sometraj')

Bases: schrodinger.application.desmond.packages.traj.Source

nframes()
class schrodinger.application.desmond.packages.traj.Fmt

Bases: enum.Enum

Trajectory format enum

AUTO = 0
DTR = 1
XTC = 2
class schrodinger.application.desmond.packages.traj.Frame(source, index)

Bases: object

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.

box
copy()

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

hijackPos(impos)

Tentatively replace the internal position array of this Frame object with an external numpy array impos. We can call the external array “imposter”. After calling this method, the pos method will return values from the imposter until the imposter is removed (by calling 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 impos. - copy The entire impos array will be copied into the copy of

this Frame object.
  • reduce Still function in the same way, but note that the impos
    array will not be changed by these methods.
  • moveby The same as reduce
  • write Still function in the same way, note that it’s the internal
    position array, not impos, that will be written out.
Parameters:impos (None, or numpy.ndarray of size Nx3, where N is arbitray number) – The position array to tentatively replac the internal position array in this Frame object. If the value is None, we remove the “imposter” and recover the internal position array.
moveby(x, y, z)

Translate all positions by the given x, y, and z.

natoms
orig_index
pos(i=None)

Return the position vector(s).

reduce(indices, copy=True)

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

Parameters:copy – If true, this function will make a copy of this frame and reduce atoms in this copy, and finally return the copy.
source()
time
vel(i=None)

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

write(writer)

Write out this frame using the given writer.

class schrodinger.application.desmond.packages.traj.Source(reader, name='sometraj')

Bases: object

Pool = {}
clear_cache()
id
name
nframes()

Returns the total number of frames in this trajectory source.

retrieve_frame(index)

Retrieves the index-th frame from the source. index is zero-based. This method assumes the source allows random access to frames.

:raise IndexError, if index is out of range.

used_space()
class schrodinger.application.desmond.packages.traj.XtcSource(reader, name='sometraj')

Bases: schrodinger.application.desmond.packages.traj.Source

nframes()
schrodinger.application.desmond.packages.traj.concat(first_time, delta_time, *arg)

Concatenate a list of trajectories and reassign the chemical time for each frame. :type first_time: float :param first_time: Chemical time of the first frame. :type delta_time: float :param delta_time: The chemical time interval between two successive frames.

schrodinger.application.desmond.packages.traj.dehydrate(tr, solute_gids, water_gids_per_frame)

This function retains the GIDs of the solute atoms and the specified waters atoms, effectively removing the majority of the bulk waters from the trajectory.

Parameters:
  • tr (list of Frame) – Input trajectory
  • solute_gids (list of `int`s) – A list of gids that specifies the subsystem.
  • water_gids_per_frame (list of `list`s of `int`s) – A list of gids that specifies the subsystem.
Return type:

list of frame

Returns:

A new, ‘dehydrated’ trajectory

schrodinger.application.desmond.packages.traj.extract_subsystem(tr, gids)

Extract the subsystem as specified by the gids for each frame in the given trajectory tr, and return a new trajectory for the subsystem. The original trajectory is not mutated in any way by this function.

Parameters:
  • tr (list of Frame) – Original trajectory
  • gids (list of `int`s) – A list of gids that specifies the subsystem.
Return type:

list

Returns:

A new trajectory for the subsystem

schrodinger.application.desmond.packages.traj.get_fmt(fname, format=<Fmt.AUTO: 0>)

Returns the format based on the given trajectory file name (fname) and the format specification (format). If the format specification is definite (i.e., not Fmt.AUTO), this function will trivially return the value of format, otherwise it will check the fname’s value, determining the format, and return the result.

Parameters:
  • fname (str) – Trajectory file name
  • format (Fmt) – Trajectory format specification

:rtype : Fmt :return: The format of the given trajectory fname

schrodinger.application.desmond.packages.traj.merge(*arg)

Merge a list of trajectories. If there is any overlapped frames among these trajectories, the ones from the latter trajectory (higher index in the arg list) will be kept.

schrodinger.application.desmond.packages.traj.read_traj(inp, format=<Fmt.AUTO: 0>)
Parameters:
  • inp (str) – Input trajectory’s file name
  • format (Fmt) – Trajectory file format
schrodinger.application.desmond.packages.traj.write_traj(tr, fname, format=<Fmt.AUTO: 0>)
Parameters:
  • fname (str) – Output file name
  • format (Fmt) – Trajectory file format