pyemma.coordinates.save_traj

pyemma.coordinates.save_traj(traj_inp, indexes, outfile, top=None, stride=1, chunksize=None, image_molecules=False, verbose=True)

Saves a sequence of frames as a single trajectory.

Extracts the specified sequence of time/trajectory indexes from traj_inp and saves it to one single molecular dynamics trajectory file. The output format will be determined by the outfile name.

Parameters:
  • traj_inp

    traj_inp can be of two types.

    1. a python list of strings containing the filenames associated with the indices in indexes. With this type of input, a topfile is mandatory.

    2. a pyemma.coordinates.data.feature_reader.FeatureReader() object containing the filename list in traj_inp.trajfiles. Please use pyemma.coordinates.source() to construct it. With this type of input, the input topfile will be ignored. and traj_inp.topfile will be used instead

  • indexes (ndarray(T, 2) or list of ndarray(T_i, 2)) – A (T x 2) array for writing a trajectory of T time steps. Each row contains two indexes (i, t), where i is the index of the trajectory from the input and t is the index of the time step within the trajectory. If a list of index arrays is given, these will be simply concatenated, i.e. they will be written subsequently in the same trajectory file.
  • outfile (str.) – The name of the output file. Its extension will determine the file type written. Example: “out.dcd” If set to None, the trajectory object is returned to memory
  • top (str, mdtraj.Trajectory, or mdtraj.Topology) – The topology needed to read the files in the list traj_inp. If traj_inp is not a list, this parameter is ignored.
  • stride (integer, default is 1) – This parameter informs save_traj() about the stride used in indexes. Typically, indexes contains frame-indexes that match exactly the frames of the files contained in traj_inp.trajfiles. However, in certain situations, that might not be the case. Examples are cases in which a stride value != 1 was used when reading/featurizing/transforming/discretizing the files contained in traj_inp.trajfiles.
  • chunksize (int. Default=None.) – The chunksize for reading input trajectory files. If traj_inp is a pyemma.coordinates.data.feature_reader.FeatureReader() object, this input variable will be ignored and traj_inp.chunksize will be used instead.
  • image_molecules (boolean, default is False) – If set to true, save_traj will call the method traj.image_molecules and try to correct for broken molecules accross periodic boundary conditions. (http://mdtraj.org/1.7.2/api/generated/mdtraj.Trajectory.html#mdtraj.Trajectory.image_molecules)
  • verbose (boolean, default is True) – Inform about created filenames
Returns:

traj – Will only return this object if outfile is None

Return type:

mdtraj.Trajectory object