### Navigation

- index
- modules |
- next |
- previous |
- MDAnalysis 0.7.7 documentation »
- 5. Coordinates modules »

# 5.5. DCD trajectory I/O — `MDAnalysis.coordinates.DCD`

Classes to read and write CHARMM/LAMMPS DCD binary trajectories. Trajectories can be read regardless of system-endianness as this is auto-detected.

The classes in this module are the reference implementations for the Trajectory API.

class `MDAnalysis.coordinates.DCD.``DCDReader`(dcdfilename, **kwargs)

  Reads from a DCD file

  Data : | ts `Timestep` object containing coordinates of current frame
  Methods : | `dcd = DCD(dcdfilename)` open dcd file and read header `len(dcd)` return number of frames in dcd `for ts in dcd:` iterate through trajectory `for ts in dcd[start:stop:skip]:` iterate through a trajectory `dcd[i]` random access into the trajectory (i corresponds to frame number) `data = dcd.timeseries(...)` retrieve a subset of coordinate information for a group of atoms `data = dcd.correl(...)` populate a `MDAnalysis.core.Timeseries.Collection` object with computed timeseries

  `Writer`(filename, **kwargs)

    Returns a DCDWriter for filename with the same parameters as this DCD.

    All values can be changed through keyword arguments.

    Arguments : | filename filename of the output DCD trajectory
    Keywords : | numatoms number of atoms start number of the first recorded MD step step indicate that step MD steps (!) make up one trajectory frame delta MD integrator time step (!), in AKMA units remarks string that is stored in the DCD header [XXX – max length?]
    Returns : | `DCDWriter`

    Note

    The keyword arguments set the low-level attributes of the DCD according to the CHARMM format. The time between two frames would be delta * step !

  `correl`(timeseries, start=0, stop=-1, skip=1)

    Populate a TimeseriesCollection object with timeseries computed from the trajectory

    Arguments : | timeseries `MDAnalysis.core.Timeseries.TimeseriesCollection` start, stop, skip subset of trajectory to use, with start and stop being inclusive

  `timeseries`(asel, start=0, stop=-1, skip=1, format='afc')

    Return a subset of coordinate data for an AtomGroup

    Arguments : | asel `AtomGroup` object start, stop, skip range of trajectory to access, start and stop are inclusive format the order/shape of the return data array, corresponding to (a)tom, (f)rame, (c)oordinates all six combinations of ‘a’, ‘f’, ‘c’ are allowed ie “fac” - return array where the shape is (frame, number of atoms, coordinates)

class `MDAnalysis.coordinates.DCD.``DCDWriter`(filename, numatoms, start=0, step=1, delta=1.0, remarks='Created by DCDWriter', convert_units=None)

  Writes to a DCD file

  Methods : | `d = DCDWriter(dcdfilename, numatoms, start, step, delta, remarks)`

  Create a new DCDWriter

  Arguments : | filename name of output file numatoms number of atoms in dcd file start starting timestep step skip between subsequent timesteps delta timestep remarks comments to annotate dcd file convert_units units are converted to the MDAnalysis base format; `None` selects the value of `MDAnalysis.core.flags` [‘convert_gromacs_lengths’]. (see Flags)

  `close`()

    Close trajectory and flush buffers.

  `convert_dimensions_to_unitcell`(ts, _ts_order=[0, 3, 1, 4, 5, 2])

    Read dimensions from timestep ts and return appropriate unitcell as [A,alpha,B,beta,gamma,C]

  `write_next_timestep`(ts=None)

    write a new timestep to the dcd file

    ts - timestep object containing coordinates to be written to dcd file

    Changed in version 0.7.5: Raises `ValueError` instead of generic `Exception` if wrong number of atoms supplied and `NoDataError` if no coordinates to be written.

### Navigation

- index
- modules |
- next |
- previous |
- MDAnalysis 0.7.7 documentation »
- 5. Coordinates modules »