Loading Files

To read a file, use something like this:

1from iodata import load_one
2
3mol = load_one("water.xyz")  # XYZ files contain atomic coordinates in Angstrom
4print(mol.atcoords)  # print coordinates in Bohr.

Note that IOData will automatically convert units from the file format’s official specification to atomic units (which is the format used throughout HORTON3).

The file format is inferred from the extension, but one can override the detection mechanism by manually specifying the format:

1from iodata import load_one
2
3mol = load_one("water.foo", fmt="xyz")  # XYZ file with unusual extension
4print(mol.atcoords)

IOData also has basic support for loading databases of molecules. For example, the following will iterate over all frames in an XYZ file:

1from iodata import load_many
2
3# print the title line from each frame in the trajectory.
4for mol in load_many("trajectory.xyz"):
5    print(mol.title)
6    print(mol.atcoords)

More details can be found in the API documentation of iodata.api.load_one() and iodata.api.load_many().