XYZ (.xyz)

  • Import and Export fully support the XYZ format.
  • Background

      MIME type: chemical/x-xyz
      XMOL molecule model files.
      Used in cheminformatics applications and on the web for storing and exchanging 3D molecule models.
      Plain text tabular format.
      Represents a single chemical compound.
      Stores atomic coordinates and meta-information.
      Does not store chemical bond information.
      Developed in 1990 at the Minnesota Supercomputer Center.

    Import and Export

    • Import["file.xyz"] reads an XYZ molecule model and gives a visual representation of it.
    • Export["file.xyz",expr] exports elements of a molecule model to an XYZ file.
    • Import["file.xyz"] returns a Graphics3D object.
    • Import["file.xyz",elem] imports the specified element from an XYZ file.
    • Import["file.xyz",{elem,suba,subb,}] imports a subelement.
    • Import["file.xyz",{{elem1,elem2,}}] imports multiple elements.
    • The import format can be specified with Import["file","XYZ"] or Import["file",{"XYZ",elem,}].
    • Export["file.xyz",expr,elem] creates an XYZ file by treating expr as specifying element elem.
    • Export["file.xyz",{expr1,expr2,},{{elem1,elem2,}}] treats each expri as specifying the corresponding elemi.
    • Export["file.xyz",expr,opt1->val1, ] exports expr with the specified option elements taken to have the specified values.
    • Export["file.xyz",{elem1->expr1,elem2->expr2,},"Rules"] uses rules to specify the elements to be exported.
    • See the reference pages for full general information on Import and Export.
    • ImportString and ExportString support the XYZ format.

    Elements

    • General Import elements:
    • "Elements"list of elements and options available in this file
      "Rules"full list of rules for each element and option
      "Options"list of rules for options, properties, and settings
    • "Graphics3D"XYZ file rendered as a Graphics3D object
    • Import uses the "Graphics3D" element by default for the XYZ format.
    • Data representation elements:
    • "VertexCoordinates"atomic coordinates, typically given in picometers
      "VertexTypes"all atoms or groups constituting the molecule, typically given as a list of chemical element abbreviations
    • Export["file.xyz",{vert,coord},{{"VertexTypes","VertexCoordinates"}}] creates an XYZ model from a specification of atom types and their 3D coordinates.

    Options

    • General Import options:
    • ImageSizeAutomaticspecifies the overall size of the graphics to display
      BackgroundWhitespecifies what background color to use
      ViewPointAutomaticpoint in space from which the 3D model is to be viewed
    • With the default setting "ViewPoint"->Automatic, the Wolfram Language automatically calculates the optimal viewing angle for the imported molecule model.
    • Selecting a 3D rendering style:
    • "Rendering""BallAndStick"specifies the visualization method
    • Possible settings for "Rendering" are:
    • "BallAndStick"displays atoms and bonds as a ball-and-stick model
      "Spacefilling"atoms shown as overlapping spheres
      "Wireframe"bonds rendered as lines

    Examples

    Basic Examples  (1)

    Import an XYZ example file, rendering it as a ball-and-stick model:

    In[1]:=
    Click for copyable input
    Out[1]=

    Show the same molecule as space-filling atoms:

    In[2]:=
    Click for copyable input
    Out[2]=

    Read the atom types and atom coordinates:

    In[3]:=
    Click for copyable input
    Out[3]=

    Export this data to XYZ:

    In[4]:=
    Click for copyable input
    Out[4]=

    See Also

    "MOL"  "PDB"  "FASTQ"  "HIN"  "JCAMP-DX"  "SFF"  "FCS"

    Introduced in 2007
    (6.0)