psamm.database – Reaction database

Representation of metabolic network databases.

class psamm.database.ChainedDatabase(*databases)

Links a number of databases so they can be treated a single database

This is a subclass of MetabolicDatabase.

class psamm.database.DictDatabase

Metabolic database backed by in-memory dictionaries

This is a subclass of MetabolicDatabase.

set_reaction(reaction_id, reaction)

Set the reaction ID to a reaction given by a Reaction

If an existing reaction exists with the given reaction ID it will be overwritten.

class psamm.database.MetabolicDatabase

Database of metabolic reactions.


Iterator of compartment IDs in the database.


Itertor of Compounds in the database.


Return an iterator of reactions containing the compound.

Reactions are returned as IDs.


Return reaction as a Reaction.


Return an iterator of reaction compounds and stoichiometric values.

The returned iterator contains (Compound, value)-tuples. The value is negative for left-hand side compounds and positive for right-hand side.


Whether the given reaction exists in the database.


Whether the given reaction is reversible.


Mapping from compound, reaction to stoichiometric value.

This is an instance of StoichiometricMatrixView.


Iterator of reactions IDs in the database.


The set of reversible reactions.

class psamm.database.StoichiometricMatrixView(database)

Provides a sparse matrix view on the stoichiometry of a database.

This object is used internally in the database to expose a sparse matrix view of the model stoichiometry. This class should not be instantied, instead use the MetabolicDatabase.matrix property. Any compound, reaction-pair can be looked up to obtain the corresponding stoichiometric value. If the value is not defined (implicitly zero) a KeyError will be raised.

In addition, instances also support the NumPy __array__ protocol which means that a numpy.array can by created directly from the matrix.

>>> model = MetabolicModel()
>>> matrix = numpy.array(model.matrix)