mdtraj.open

mdtraj.open(filename, mode='r', force_overwrite=True, **kwargs)[source]

Open a trajectory file-like object

This factor function returns an instance of an open file-like object capable of reading/writing the trajectory (depending on ‘mode’). It does not actually load the trajectory from disk or write anything.

Parameters:
  • filename (path-like) – Path to the trajectory file on disk

  • mode ({'r', 'w'}) – The mode in which to open the file, either ‘r’ for read or ‘w’ for write.

  • force_overwrite (bool) – If opened in write mode, and a file by the name of filename already exists on disk, should we overwrite it?

  • kwargs (dict) – Other keyword parameters are passed directly to the file object

Returns:

fileobject – Open trajectory file, whose type is determined by the filename extension

Return type:

object

See also

load, ArcTrajectoryFile, DCDTrajectoryFile, HDF5TrajectoryFile, LH5TrajectoryFile, MDCRDTrajectoryFile, NetCDFTrajectoryFile, PDBTrajectoryFile, TRRTrajectoryFile, XTCTrajectoryFile