mdtraj.iterload

mdtraj.iterload(filename, chunk=100, \*\*kwargs)

An iterator over a trajectory from one or more files on disk, in fragments

This may be more memory efficient than loading an entire trajectory at once

Parameters
filenamestr

Path to the trajectory file on disk

chunkint

Number of frames to load at once from disk per iteration. If 0, load all.

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.

strideint, default=None

Only read every stride-th frame.

atom_indicesarray_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.

skipint, default=0

Skip first n frames.

See also

load, load_frame

Examples

>>> import mdtraj as md
>>> for chunk in md.iterload('output.xtc', top='topology.pdb')
...    print chunk
<mdtraj.Trajectory with 100 frames, 423 atoms at 0x110740a90>
<mdtraj.Trajectory with 100 frames, 423 atoms at 0x110740a90>
<mdtraj.Trajectory with 100 frames, 423 atoms at 0x110740a90>
<mdtraj.Trajectory with 100 frames, 423 atoms at 0x110740a90>
<mdtraj.Trajectory with 100 frames, 423 atoms at 0x110740a90>