psamm.datasource.reaction – Parser for reactions

Reaction parser.

exception psamm.datasource.reaction.ParseError(*args, **kwargs)

Error raised when parsing reaction fails.

class psamm.datasource.reaction.ReactionParser(arrows=None, parse_global=False)

Parser of reactions equations.

This parser recognizes:

  • Global compartment specification as a prefix (when parse_global is True)
  • Configurable reaction arrow tokens (arrows)
  • Compounds quoted by pipe (|) (required only if the compound name includes a space)
  • Compound counts that are affine expressions.

Parse reaction string.

psamm.datasource.reaction.parse_compound(s, global_compartment=None)

Parse a compound specification.

If no compartment is specified in the string, the global compartment will be used.


Parse a compound count (number of compounds).


Parse reaction string using the default parser.