### Navigation

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

# 5.3. Common functions for coordinate reading — `MDAnalysis.coordinates.core`

Important base classes are collected in `MDAnalysis.coordinates.base`.

`MDAnalysis.coordinates.core.``reader`(filename, **kwargs)

  Provide a trajectory reader instance for filename.

  This function guesses the file format from the extension of filename and it will throw a `TypeError` if the extension is not recognized.

  In most cases, no special keyword arguments are necessary. For some readers (such as PDB) it might be useful to set the permissive = `True` flag to select a simpler but faster reader.

  All other keywords are passed on to the underlying Reader classes; see their documentation for details.

  See also

  For trajectory formats: `DCDReader`, `XTCReader`, `TRRReader`, `XYZReader`. For single frame formats: `CRDReader`, `PDBReader` and `PrimitivePDBReader`, `GROReader`,

  Arguments : | filename filename of the input trajectory or coordinate file permissive If set to `True`, a reader is selected that is more tolerant of the input (currently only implemented for PDB). [`False`] kwargs Keyword arguments for the selected Reader class.

`MDAnalysis.coordinates.core.``writer`(filename, numatoms=None, **kwargs)

  Initialize a trajectory writer instance for filename.

  Arguments : | filename Output filename of the trajectory; the extension determines the format. numatoms The number of atoms in the output trajectory; can be ommitted for single-frame writers. multiframe `True`: write a trajectory with multiple frames; `False` only write a single frame snapshot; `None` first try to get a multiframe writer and then fall back to single frame [`None`] kwargs Keyword arguments for the writer; all trajectory Writers accept at least start starting time [0] step step size in frames [1] delta length of time between two frames, in ps [1.0] Some readers accept additional arguments, which need to be looked up in the documentation of the reader. See also `DCDWriter` for DCD trajectories or `XTCWriter` and `TRRWriter` for Gromacs.

  Changed in version 0.7.6: Added multiframe keyword. See also `get_writer_for()`.

Helper functions:

`MDAnalysis.coordinates.core.``get_reader_for`(filename, permissive=False, format=None)

  Return the appropriate trajectory reader class for filename.

  Automatic detection is disabled when an explicit format is provided.

`MDAnalysis.coordinates.core.``get_writer_for`(filename=None, format='DCD', multiframe=None)

  Return an appropriate trajectory or frame writer class for filename.

  The format is determined by the format argument or the extension of filename. The default is to return a dcd writer (format = ‘dcd’).

  Arguments : | filename The filename for the trajectory is examined for its extension and the Writer is chosen accordingly. format If no filename is supplied then the format can be explicitly set; possible values are “DCD”, “XTC”, “TRR”; “PDB”, “CRD”, “GRO”. multiframe `True`: write multiple frames to the trajectory; `False`: only write a single coordinate frame; `None`: first try trajectory (multi frame writers), then the single frame ones. Default is `None`.

  Changed in version 0.7.6: Added multiframe keyword; the default `None` reflects the previous behaviour.

`MDAnalysis.coordinates.core.``guess_format`(filename, format=None)

  Returns the type of coordinate file filename.

  The current heuristic simply looks at the filename extension but more complicated probes could be implemented here or in the individual packages (e.g. as static methods).

  If format is supplied then it overrides the auto detection.

`MDAnalysis.coordinates.core.``triclinic_box`(x, y, z)

  Convert the three triclinic box vectors to [A,B,C,alpha,beta,gamma].

  Angles are in degrees.

  - alpha = angle(y,z)
  - beta = angle(x,z)
  - gamma = angle(x,y)

  See also

  Definition of angles: http://en.wikipedia.org/wiki/Lattice_constant

`MDAnalysis.coordinates.core.``triclinic_vectors`(dimensions)

  Convert [A,B,C,alpha,beta,gamma] to a triclinic box representation.

  Original code by Tsjerk Wassenaar posted on the Gromacs mailinglist.

  If dimensions indicates a non-periodic system (i.e. all lengths 0) then null-vectors are returned.

  Arguments : | dimensions list of box lengths and angles (in degrees) such as [A,B,C,alpha,beta,gamma]
  Returns : | numpy 3x3 array B, with B[0] = first box vector, B[1] = second vector, B[2] third box vector.

  Note

  The first vector is always pointing along the X-axis i.e. parallel to (1,0,0).

  Changed in version 0.7.6: Null-vectors are returned for non-periodic (or missing) unit cell.

`MDAnalysis.coordinates.core.``box_volume`(dimensions)

  Return the volume of the unitcell described by dimensions.

  The volume is computed as det(x1,x2,x2) where the xi are the triclinic box vectors from `triclinic_vectors()`.

  Arguments : | dimensions list of box lengths and angles (in degrees) such as [A,B,C,alpha,beta,gamma]
  Returns : | numpy 3x3 array B, with B[0] = first box vector, B[1] = second vector, B[2] third box vector.

### Navigation

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