pymatgen.io.xyz module

Module implementing an XYZ file object class.

class XYZ(mol: Molecule, coord_precision: int = 6)[source]

Bases: object

Basic class for importing and exporting Molecules or Structures in XYZ format.

Note

Exporting periodic structures in the XYZ format will lose information about the periodicity. Essentially, only Cartesian coordinates are written in this format and no information is retained about the lattice.

Parameters:
  • mol – Input molecule or list of molecules

  • coord_precision – Precision to be used for coordinates.

property all_molecules[source]

Returns all the frames of molecule associated with this XYZ.

as_dataframe()[source]

Generates a coordinates data frame with columns: atom, x, y, and z In case of multiple frame XYZ, returns the last frame.

Returns:

pandas.DataFrame

static from_file(filename)[source]

Creates XYZ object from a file.

Parameters:

filename – XYZ filename

Returns:

XYZ object

static from_string(contents)[source]

Creates XYZ object from a string.

Parameters:

contents – String representing an XYZ file.

Returns:

XYZ object

property molecule: Molecule[source]

Returns molecule associated with this XYZ. In case multiple frame XYZ, returns the last frame.

write_file(filename: str) None[source]

Writes XYZ to file.

Parameters:

filename (str) – File name of output file.