3. Thermodynamic Databases

3.1. Converting a Matlab thermodynamic database

If you have a Matlab thermodynamic database, you can easily convert it to a Python database thanks to the script thermoDBconverter.py:

python thermoDBconverter.py database.mat converted_database.thermodb

3.2. Loading a thermodynamic database

Thermodynamic databases are compressed through zlib and binary-encoded with pickle. In order to load them, you need first to uncompress them with zlib.decompress then load the result into memory with pickle.loads:

import pickle
import zlib
with open('thermoDatabases/DB_AlbertyUpdate.thermodb', 'rb') as file:
    ReactionDB = pickle.loads(zlib.decompress(file.read()))

Warning

Since the file is compressed, you MUST load it as a binary file by calling open with the b flag, otherwise Python will try to decode it as unicode and raise an exception !

3.3. Structure of a thermodynamic database

A thermodynamic database is a dict with the following fields:

  • name : string The name of the database

  • units : string The unit of the energies in the database. Can be kcal/mol or kJ/mol.

  • metabolites : dict A dictionnary containing the metabolites’ thermodynamic data. See Metabolites for more information.

  • cues : dict A dictionnary containing the cues’ thermodynamic data. See Cues for more information.

3.3.1. Metabolites

This is a dictionnary storing various thermodynamic data about metabolites. It is stored as a dict where each key is a SeedID. The values are others dict with the following keys.

id

string SeedID of the metabolite

charge_std

float Charge of the metabolite (mV) in standard conditions

deltaGf_std

float Transformed Gibbs energy of formation of the metabolite, in standard conditions.

deltaGf_err

float Error on the transformed Gibbs energy of formation of the metabolite, in standard conditions

mass_std

float Mass of the metabolite (g.mol-1)

nH_std

int Number of protons of the metabolite, in standard conditions

error

string Error on the metabolite’s thermodynamic data. Thermodynamic values will be computed only if this equals to ‘Nil’.

formula

string Formula of the metabolite.

nH_std

int Number of protons in the metabolite’s formula

name

string Name of the metabolite

other_names

list (string) Other names of the metabolite

pKa

list (float) pKas of the metabolite

struct_cues

dict (int) cues of the metabolite

The keys of the array are the names of the cues, and the values the number of cues of this type that are part of the structure.

Here is an example:

ReactionDB['metabolites']['cpd00001'] = {
  'charge_std': 0,
  'deltaGf_err': 0.5,
  'deltaGf_std': -56.686999999999998,
  'error': 'Nil',
  'formula': 'H2O',
  'id': 'cpd00001',
  'mass_std': 18.0,
  'nH_std': 2,
  'name': 'H2O',
  'other_names': ['H2O', 'Water', 'HO-', 'OH-', 'h2o'],
  'pKa': [15.7],
  'struct_cues': {'H2O': 1}
}

3.3.2. Cues

This is a dictionnary storing various thermodynamic data about cues. It is stored as a dict where each key is the cue ID, as referrenced in the struct_cues attribute of Metabolites. The values are others dict with the following keys.

id

string ID of the cue

charge

float The charge (mV) of the cue in standard conditions

datfile

string The dat file from which the data was imported. Optional

energy

float Transformed Gibbs energy of formation of the cue, in standard conditions.

error

float The error on the transformed Gibbs energy of formation of the cue, in standard conditions.

formula

string Formula of the cue

names

list (string) Other names of the cue

small

bool Whether this is a small cue or not

Here is an example:

ReactionDB['cues']['H2O'] = {
  'charge': 0,
  'datfile': 'H2O.gds',
  'energy': -56.686999999999998,
  'error': 0.5,
  'formula': 'H2O',
  'id': 'H2O',
  'names': ['H2O', 'OH-', 'HO-'],
  'small': True
}