Supported File Formats

cml: Chemical Markup Language

Extension:.cml
class chemlab.io.handlers.CmlIO(fd)

The CML format is described in http://www.xml-cml.org/.

Features

read("molecule")

Read the coordinates in a Molecule instance.

write("molecule", mol)

Writes a Molecule instance in the CML format.

edr: GROMACS energy file

Extension:.edr
class chemlab.io.handlers.EdrIO(fd)

EDR files store per-frame information for gromacs trajectories. Examples of properties obtainable from EDR files are:

- temperature
- pressure
- density
- potential energy
- total energy
- etc.

To know which quantities are available in a certain edr file you can access the feature ‘avail quantity’:

>>> datafile('ener.edr').read('avail quantities')
['Temperature', 'Pressure', 'Potential', ...]

To get the frame information for a certain quantity you may use the “quantity” property passing the quantity as additional argument, this will return two arrays, the first is an array of times in ps and the second are the corrisponding quantities:

>>> time, temp = datafile('ener.edr').read('quantity', 'Temperature')

Features

read("quantity", quant)

Return an array of times in ps and the corresponding quantities at that times.

read("avail quantities")

Return the available quantities in the file.

read("units")

Return a dictionary where the keys are the quantities and the value are the units in which that quantity is expressed.

read("frames")

Return a dictionary where the keys are the quantities and the value are the units in which that quantity is expressed.

gro: GROMACS coordinate files

Extension:.gro
class chemlab.io.handlers.GromacsIO(fd)

Handler for .gro file format. Example at http://manual.gromacs.org/online/gro.html.

Features

read("system")

Read the gro file and return a System instance. It also add the following exporting informations:

groname: The molecule names indicated in the gro file. This is
added to each entry of System.mol_export.
grotype: The atom names as indicated in the gro file. This is
added to each entry of System.atom_export_array.
write("system", syst)

Write the syst System instance to disk. The export arrays should have the groname and grotype entries as specified in the read("system") method.

Example

Export informations for water SPC:

Molecule([
          Atom('O', [0.0, 0.0, 0.0], export={'grotype': 'OW'}),
          Atom('H', [0.1, 0.0, 0.0], export={'grotype': 'HW1'}),
          Atom('H', [-0.033, 0.094, 0.0],export={'grotype':'HW2'})],
        export={'groname': 'SOL'})

mol: MDL Coordinate files

Extension:.mol
class chemlab.io.handlers.MolIO(fd)

Reader for MDL molfile http://en.wikipedia.org/wiki/Chemical_table_file.

Features

read("molecule")

Read the molecule in a Molecule instance.

pdb: Protein Data Bank format

Extension:.pdb
class chemlab.io.handlers.PdbIO(fd)

Starting implementation of a PDB file parser.

Note

This handler was developed as an example. If you like to contribute by implementing it you can write an email to the mailing list.

Features

read("molecule")

Read the pdb file as a huge Molecule.

read("system")

Read the pdb file as a System, where each residue is a molecule.

xtc: GROMACS compressed trajectory file

Extension:.xtc
class chemlab.io.handlers.XtcIO(fd)

Reader for GROMACS XTC trajectories.

Features

read("trajectory")

Read the frames from the file and returns the trajectory as an array of times and an array of atomic positions:

>>> times, positions = datafile('traj.xtc').read('trajectory')
[t1, t2, t3], [pos1, pos2, ...]

positions is a list of np.ndarray(n_atoms, 3).

read("boxes")

After reading the “trajectory” feature you can call read(“boxes”) that will return a list of box_vectors correspoiding to each frame.

xyz: XYZ coordinate format

Extension:.xyz
class chemlab.io.handlers.XyzIO(fd)

The XYZ format is described in this wikipedia article http://en.wikipedia.org/wiki/XYZ_file_format.

Features

read("molecule")

Read the coordinates in a Molecule instance.

write("molecule", mol)

Writes a Molecule instance in the XYZ format.

cclib integration

Those handlers are based on the cclib library. The feature names extracted match those of the one included in the cclib documentation.

Chemlab also extract a chemlab.core.Molecule instance from the file through the feature named molecule.

List of file formats:

  • gamess
  • gamessuk
  • gaussian
  • jaguar
  • molpro
  • orca

You can also use the method available_properties to get the available properties dynamically.