mdtraj.load

mdtraj.load(filename_or_filenames, discard_overlapping_frames=False, **kwargs)

Load a trajectory from one or more files on disk.

This function dispatches to one of the specialized trajectory loaders based on the extension on the filename. Because different trajectory formats save different information on disk, the specific keyword argument options supported depend on the specific loaded.

Parameters:

filename_or_filenames : {str, list of strings}

Filename or list of filenames containing trajectory files of a single format.

discard_overlapping_frames : bool, default=False

Look for overlapping frames between the last frame of one filename and the first frame of a subsequent filename and discard them

Returns:

trajectory : md.Trajectory

The resulting trajectory, as an md.Trajectory object.

Other Parameters:
 

top : {str, Trajectory, Topology}

Most trajectory formats do not contain topology information. Pass in either the path to a RCSB PDB file, a trajectory, or a topology to supply this information. This option is not required for the .h5, .lh5, and .pdb formats, which already contain topology information.

stride : int, default=None

Only read every stride-th frame

atom_indices : array_like, optional

If not none, then read only a subset of the atoms coordinates from the file. This may be slightly slower than the standard read because it requires an extra copy, but will save memory.

See also

load_frame, iterload

Examples

>>> import mdtraj as md
>>> traj = md.load('output.xtc', top='topology.pdb')
>>> print traj
<mdtraj.Trajectory with 500 frames, 423 atoms at 0x110740a90>
>>> traj2 = md.load('output.xtc', stride=2, top='topology.pdb')
>>> print traj2
<mdtraj.Trajectory with 250 frames, 423 atoms at 0x11136e410>
>>> traj3 = md.load_hdf5('output.xtc', atom_indices=[0,1] top='topology.pdb')
>>> print traj3
<mdtraj.Trajectory with 500 frames, 2 atoms at 0x18236e4a0>