class chemlab.db.base.AbstractDB

Interface for a generic database.

A typical database can be used to retrieve molecules by calling the get method:

water = db.get("molecule", "example.water")

A database can also provide custom functionalities to store or search for entries. Those are implemented in custom methods.

See the other implementations for more relevant examples.

get(feature, key, *args, **kwargs)

Get a data entry from the database.

Subclasses are required to implement this method to provide access to the database.


  • feature: str

    An identifier that represents the kind of data that we want to extract. Examples of such identifier are “system”, “molecule”, “data” etc.

  • key: str

    The key associated with the database entry. By convention you can use dotted names to provide some kind of nested structure.

  • args, kwargs:

    Custom extra arguments.


class chemlab.db.ChemlabDB

Chemlab default database.

This database contains some example molecules and some atomic data.

get(self, 'molecule', key)

Retrieve a molecule from the database. The included molecule keys are:

  • example.water
  • example.norbornene
  • gromacs.spc
  • gromacs.spce
get(self, 'data', key)

Retrieve atomic data. The available data is:

  • vdwdict: Dictionary with per-element Van Der Waals radii.
  • massdict: Dictionary of masses.
  • symbols: Atomic symbols in a list.

Data was taken from the OpenBabel distribution.


class chemlab.db.CirDB

Get 3D structure of arbitrary molecules given a string identifier.

get(self, 'molecule', key)

Retrieve a molecule from the online CIR database by passing an identifier.

A key can be, for instance, the common name of a certain chemical, a SMILES string or an InChi identifier. This is just an adapter on the CirPy library.

Returns a Molecule instance.


class chemlab.db.LocalDB(directory)

Store serialized molecules and systems in a directory tree.

See Having your own molecular database for an example of usage.


Directory where the database is located.

get(self, 'molecule', key)

Get an entry from the database. Key is the filename without extension of the serialized molecule. Molecules are stored in the subdirectory.

get(self, 'molecule', key)

Get an entry from the database. Key is the filename without extension of the serialized system.

store(self, 'molecule', key, value)
store(self, 'system', key, value)

Store a Molecule or a System passed as value in the directory structure. The objects are dumped to disk after being serialized to json.

Project Versions

Table Of Contents

Previous topic


Next topic


This Page