Trajectory References

class dask_traj.core.dask_traj.Trajectory(xyz, topology, time=None, delayed_objects=None, **kwargs)

Bases: mdtraj.core.trajectory.Trajectory

mdtraj.Trajectory with dask.array properties

n_frames
Type

int

n_atoms
Type

int

n_residues
Type

int

time
Type

np.ndarray, shape=(n_frames,)

timestep
Type

float

topology
Type

md.Topology

top
Type

md.Topology

xyz
Type

ndarray, shape=(n_frames, n_atoms, 3)

unitcell_vectors
Type

{ndarray, shape=(n_frames, 3, 3), None}

unitcell_lengths
Type

{ndarray, shape=(n_frames, 3), None}

unitcell_angles
Type

{ndarray, shape=(n_frames, 3), None}

__hash__()

Updated hash function to use the name of the dask arrays

_calc_length_and_angles(vectors)

Set the three vectors that define the shape of the unit cell

Parameters

vectors (tuple of three arrays, each of shape=(n_frames, 3)) – The semantics of this array are that the shape of the unit cell in frame i are given by the three vectors, value[i, 0, :], value[i, 1, :], and value[i, 2, :].

_calc_unitcell_vectors()

The vectors that define the shape of the unit cell in each frame

Returns

vectors (da.ndarray, shape(n_frames, 3, 3)) – Vectors defining the shape of the unit cell in each frame. The semantics of this array are that the shape of the unit cell in frame i are given by the three vectors, value[i, 0, :], value[i, 1, :], and value[i, 2, :].

join(other, check_topology=True, discard_overlapping_frames=False)

This is a daskified version of md.Trajectory.join()

Parameters
  • other (Trajectory or list of Trajectory) – One or more trajectories to join with this one. These trajectories are appended to the end of this trajectory.

  • check_topology (bool) – Ensure that the topology of self and other are identical before joining them. If false, the resulting trajectory will have the topology of self.

  • discard_overlapping_frames (bool, optional) – If True, compare coordinates at trajectory edges to discard overlapping frames. Default: False.

to_mdtraj()

Converts self to a mdtraj.Trajectory

property unitcell_angles

Angles that define the shape of the unit cell in each frame.

Returns

lengths (nd.array, shape=(n_frames, 3)) – The angles between the three unitcell vectors in each frame, alpha, beta, and gamma. alpha' gives the angle between vectors ``b and c, beta gives the angle between vectors c and a, and gamma gives the angle between vectors a and b. The angles are in degrees.

property unitcell_lengths

Lengths that define the shape of the unit cell in each frame.

Returns

lengths ({ndarray, shape=(n_frames, 3), None}) – Lengths of the unit cell in each frame, in nanometers, or None if the Trajectory contains no unitcell information.

property unitcell_vectors

vectors that define the shape of the unit cell in each frame.

Returns

vectors ({ndarray, shape=(n_frames, 3), None}) – Vecotors of the unit cell in each frame, in nanometers, or None if the Trajectory contains no unitcell information.

property xyz

Cartesian coordinates of each atom in each simulation frame

Returns

xyz (ndarray, shape=(n_frames, n_atoms, 3)) – A three dimensional dask array, with the cartesian coordinates of each atoms in each frame.

dask_traj.core.dask_traj.build_result_dict(results, extension, length, chunk_size, distance_unit)

Builds a result dict with py:class:dask.array for the properties of the trajectory

Parameters
  • results (list of dask.Delayed objects) – delayed objects to extract the trajectory properties from.

  • extension (string) – File extension of the file to load.

  • lenght (int) – Number of frames of the trajectory.

  • chunk_size (int) – Number of frames per chunk.

  • distance_unit (string) – Indication of the distance unit of the file for the xyz.

Returns

dict – A dictionary with the dask.array trajectory properties

dask_traj.core.dask_traj.get_time(result_dict, length, chunk_size)

Makes an py:class:dask.array for time if it can be loaded from the fileformat, otherwise returns None.

Parameters
  • result_dict (dict of dask.delayed objects) – dict of delayed objects where we make the time from into an dask array.

  • lenght (int) – total length of the final dask array.

  • chunk_size (int) – length of a single chunk.

Returns

dask.array or None – dask array from the delayed objects for time if it can be loaded, None otherwise.

dask_traj.core.dask_traj.get_unitcell(result_dict, length)

Makes an py:class:dask.array for the unitcell information if it can be loaded from the fileformat, otherwise returns None.

Parameters
  • result_dict (dict of dask.delayed objects) – dict of delayed objects where we make the time from grab into an dask array.

  • lenght (int) – total length of the final dask array.

Returns

(unitcell_lengths, unitcell_angles, unitcell_vectors) – dask array from the delayed objects for each term if it can be loaded, None otherwise.

dask_traj.core.dask_traj.get_xyz(result_dict, length, distance_unit)

Makes an py:class:dask.array for xyz if it can be loaded from the fileformat, otherwise returns None.

Parameters
  • result_dict (dict of dask.delayed objects) – dict of delayed objects where we make the xyz from into a dask array.

  • lenght (int) – total length of the final dask array.

  • distance_unit (string) – distance unit of the filetype to be loaded.

Returns

dask.array or None – dask array from the delayed objects for xyz if it can be loaded, None otherwise.

dask_traj.core.dask_traj.load(filename, chunks=10, **kwargs)

A loader that will mimic mdtraj.Trajectory.load(), but construct a dasktraj.Trajectory with a dask.array as xyz, time, and unitcell properties.

Parameters
  • filename (string) – Filename of the file to load.

  • chunks (int) – Number of frames per chunk.

Returns

trajectory – A dasktraj.Trajectory

dask_traj.core.dask_traj.load_chunks(filename, extension, chunk_size, chunks, **kwargs)

Uses dask.delayed() to lazy load the chunks of a trajectory and builds a result dict.

Parameters
  • filename (string) – Filename of the file to load.

  • extension (string) – File extension of the file to load.

  • chunk_size (int) – Number of frames per chunk.

  • chunks (list of int) – Which chunks to load

Returns

dict – A dictionary with the dask.array trajectory properties

dask_traj.core.dask_traj.make_da(delayed_list, length)

Makes an py:class:dask.array from a list of delayed objects.

Parameters
  • delayed_list (list of dask.delayed objects) – list of delayed objects to convert into an dask array

  • lenght (int) – total length of the final dask array.

Returns

dask.array – dask array from the delayed objects.

dask_traj.core.dask_traj.read_chunk(filename, chunk_size, start)

Read a chunk of the trajectory file.

Parameters
  • filename (string) – filename of the file to load

  • chunk_size (int) – size of the chunk to load

  • start (int) – frame to start the loading from

Returns

  • A tuple with the data for the read chunk (depending on what

  • filetype.read returns)

Geometry Computations

dask_traj.geometry.distance.compute_center_of_geometry(traj)

Daskified version of mdtraj.geometry.compute_center_of_geometry

This mimics py:method:mdtraj.compute_center_of_geometry() but returns the answer as a py:class:dask.array object

Parameters

traj (dask_traj.Trajectory) – The trajectory to compute the angles for.

Returns

com (dask.array, shape(n_frames, 3)) – Dask array with the delayed calculated Coordinates of center of geometry for each frame.

dask_traj.geometry.distance.compute_center_of_mass(traj)

Daskified version of mdtraj.geometry.compute_center_of_mass

This mimics py:method:mdtraj.compute_center_of_mass() but returns the answer as a py:class:dask.array object

Parameters

traj (dask_traj.Trajectory) – The trajectory to compute the angles for.

Returns

com (dask.array, shape(n_frames, 3)) – Dask array with the delayed calculated Coordinates of center of mass for each frame.

dask_traj.geometry.distance.compute_displacements(traj, atom_pairs, periodic=True, **kwargs)

Daskified version of mdtraj.geometry.compute_displacements

This mimics py:method:mdtraj.compute_displacements() but returns the answer as a py:class:dask.array object

Parameters
  • traj (dask_traj.Trajectory) – The trajectory to compute the angles for.

  • atom_pairs (array of shape(any, 2)) – The indices for which to compute an distances.

  • periodic (bool) – Wether to use the periodc boundary during the calculation.

  • opt (bool, default=True) – Use an optimized native library to calculate distances. MDTraj’s optimized SSE angle calculation implementation is 10-20x faster than the (itself optimized) numpy implementation.

Returns

displacements (dask.array, shape(n_frames, atom_pairs, 3)) – Dask array with the delayed calculated displacements for each item in atom_pairs for each frame.

dask_traj.geometry.distance.compute_distances(traj, atom_pairs, periodic=True, **kwargs)

Daskified version of mdtraj.compute_distances().

This mimics py:method:mdtraj.compute_distances() but returns the answer as a py:class:dask.array object

Parameters
  • traj (dask_traj.Trajectory) – The trajectory to compute the angles for.

  • atom_pairs (array of shape(any, 2)) – The indices for which to compute an distances.

  • periodic (bool) – Wether to use the periodc boundary during the calculation.

  • opt (bool, default=True) – Use an optimized native library to calculate distances. MDTraj’s optimized SSE angle calculation implementation is 10-20x faster than the (itself optimized) numpy implementation.

Returns

distances (dask.array, shape(n_frames, atom_pairs)) – Dask array with the delayed calculated distance for each item in atom_pairs for each frame.

dask_traj.geometry.distance.find_closest_contact(traj, group1, group2, frame=0, periodic=True)

Daskified version fo mdtraj.find_closest_contact()

Mimics mdtraj.find_closest_contact, but instead returns a delayed tuple

Parameters
  • traj (Trajectory) – An dask-traj trajectory.

  • group1 (ndarray, shape=(num_atoms), dtype=int) – The indices of atoms in the first group.

  • group2 (ndarray, shape=(num_atoms), dtype=int) – The indices of atoms in the second group.

  • frame (int, default=0) – The frame of the Trajectory to take positions from

  • periodic (bool, default=True) – If periodic is True and the trajectory contains unitcell information, we will compute distances under the minimum image convention.

Returns

result (delayed tuple (int, int, float)) – A delayed tuple with the indices of the two atoms forming the closest contact, and the distance between them.

dask_traj.geometry.angle._angle(xyz, triplets, periodic, out)

Delayed version of the _angle function of mdtraj

Parameters
  • xyz (ndarray of shape (any, any, 3)) – The xyz coordinates of the chunk

  • triplets (array of shape (any, 3)) – The indices for which to compute an angle

  • box (ndarray of shape (any, 3, 3)) – The box vectors of the chunk

  • periodic (bool) – Wether to use the periodc boundary during the calculation.

  • out (ndarray of zeros of shape (len(xyz), len(triplets))) – The output array

dask_traj.geometry.angle.compute_angles(traj, angle_indices, periodic=True, opt=True, **kwargs)

Daskified version of mdtraj.compute_angles().

This mimics py:method:mdtraj.compute_angles() but returns the answer as a py:class:dask.array object

Parameters
  • traj (dask_traj.Trajectory) – The trajectory to compute the angles for.

  • angle_indices (array of shape(any, 3)) – The indices for which to compute an angle.

  • periodic (bool) – Wether to use the periodc boundary during the calculation.

  • opt (bool, default=True) – Use an optimized native library to calculate distances. MDTraj’s optimized SSE angle calculation implementation is 10-20x faster than the (itself optimized) numpy implementation.

Returns

angles (dask.array, shape(n_frames, angle_indices)) – Dask array with the delayed calculated angle for each item in angle_indices for each frame.