# mdtraj.formats.HDF5TrajectoryFile

class mdtraj.formats.HDF5TrajectoryFile(filename, mode='r', force_overwrite=True, compression='zlib', bond_metadata=True)

  Interface for reading and writing to a MDTraj HDF5 molecular dynamics trajectory file, whose format is described here.

  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.

  The format is extremely flexible and high performance. It can hold a wide variety of information about a trajectory, including fields like the temperature and energies. Because it’s built on the fantastic HDF5 library, it’s easily extensible too.

  Parameters:

    - filename (path-like) – Path to the file to open

    - mode ({'r, 'w'}) – Mode in which to open the file. ‘r’ is for reading and ‘w’ is for writing

    - force_overwrite (bool) – In mode=’w’, how do you want to behave if a file by the name of filename already exists? if force_overwrite=True, it will be overwritten.

    - compression ({'zlib', None}) – Apply compression to the file? This will save space, and does not cost too many cpu cycles, so it’s recommended.

    - bond_metadata (bool, optional) – If True, include bond metadata (order and type) when writing the topology.

  root
  title
  application
  topology
  randomState
  forcefield
  reference
  constraints

  See also

  `mdtraj.load_hdf5`

    High-level wrapper that returns a `md.Trajectory`

  Attributes:
    `application`

      Suite of programs that created the file

    `constraints`

      Constraints applied to the bond lengths

    `forcefield`

      Description of the hamiltonian used.

    `randomState`

      State of the creators internal random number generator at the start of the simulation

    `reference`

      A published reference that documents the program or parameters used to generate the data

    `root`

      Direct access to the root group of the underlying Tables HDF5 file handle.

    `title`

      User-defined title for the data represented in the file

    `topology`

      Get the topology out from the file

  Methods

  `close`() | Close the HDF5 file handle
  `convert_topology_to_dict`(topology_object[, ...]) | Method for converting mdtraj.topology to a dictionary
  `flush`() | Write all buffered data in the to the disk file.
  `read`([n_frames, stride, atom_indices]) | Read one or more frames of data from the file
  `read_as_traj`([n_frames, stride, atom_indices]) | Read a trajectory from the HDF5 file
  `seek`(offset[, whence]) | Move to a new file position
  `tell`() | Current file position
  `write`(coordinates[, time, cell_lengths, ...]) | Write one or more frames of data to the file

  __init__(filename, mode='r', force_overwrite=True, compression='zlib', bond_metadata=True)

  Methods

  `__init__`(filename[, mode, force_overwrite, ...]) |
  `close`() | Close the HDF5 file handle
  `convert_topology_to_dict`(topology_object[, ...]) | Method for converting mdtraj.topology to a dictionary
  `flush`() | Write all buffered data in the to the disk file.
  `read`([n_frames, stride, atom_indices]) | Read one or more frames of data from the file
  `read_as_traj`([n_frames, stride, atom_indices]) | Read a trajectory from the HDF5 file
  `seek`(offset[, whence]) | Move to a new file position
  `tell`() | Current file position
  `write`(coordinates[, time, cell_lengths, ...]) | Write one or more frames of data to the file

  Attributes

  `application` | Suite of programs that created the file
  `constraints` | Constraints applied to the bond lengths
  `distance_unit` |
  `forcefield` | Description of the hamiltonian used.
  `randomState` | State of the creators internal random number generator at the start of the simulation
  `reference` | A published reference that documents the program or parameters used to generate the data
  `root` | Direct access to the root group of the underlying Tables HDF5 file handle.
  `title` | User-defined title for the data represented in the file
  `topology` | Get the topology out from the file