# mdtraj.formats.XYZTrajectoryFile¶

class mdtraj.formats.XYZTrajectoryFile(filename, mode='r', force_overwrite=True)

Interface for reading and writing to xyz files.

This is a file-like object, that both reading or writing depending on the mode flag. It implements the context manager protocol, so you can also use it with the python ‘with’ statement.

Parameters
filenamestr

The filename to open. A path to a file on disk.

mode{‘r’, ‘w’}

The mode in which to open the file, either ‘r’ for read or ‘w’ for write.

force_overwritebool

If opened in write mode, and a file by the name of filename already exists on disk, should we overwrite it?

Methods

 close(self) Close the xyz file. read(self[, n_frames, stride, atom_indices]) Read data from a xyz file. read_as_traj(self, topology[, n_frames, …]) Read a trajectory from a XYZ file seek(self, offset[, whence]) Move to a new file position. tell(self) Current file position. write(self, xyz[, types]) Write one or more frames of data to a xyz file.
__init__(self, filename, mode='r', force_overwrite=True)

Open a xyz file for reading/writing.

Methods

 __init__(self, filename[, mode, force_overwrite]) Open a xyz file for reading/writing. close(self) Close the xyz file. read(self[, n_frames, stride, atom_indices]) Read data from a xyz file. read_as_traj(self, topology[, n_frames, …]) Read a trajectory from a XYZ file seek(self, offset[, whence]) Move to a new file position. tell(self) Current file position. write(self, xyz[, types]) Write one or more frames of data to a xyz file.

Attributes

 distance_unit