Metabolism : The Reaction Class

class PyFBA.metabolism.Reaction(name)

A reaction is the central concept of metabolism and is the conversion of substrates to products.

The reaction describes what we know. At a bare minimum we need a a name for the reaction. The name can either be the reaction id (e.g. modelSEED or KEGG id), or another name for this reaction.

A reaction is an object that describes how to get from one compound to another. We need to know what the compound(s) on the left of the equation are, what the compounds on the right of the reaction are, and the probability that the reaction proceeds in either direction. If the reaction is truly reversible the probability can be 1 in both cases. If it is unidirectional the probability can be 0 in one direction.

The likelihood that a reaction completes will be some product of its delta G and its p. We could also do something simpler, e.g. if there is a -ve delta G (favorable reaction) we can increase p and if there is a +ve delta G (unfavorable reaction) we can decrease p.

The direction and reversible is the direction that the equation can run.

Acceptable values are: ====== =========================== Value Meaning ====== =========================== None We don’t know the direction > Left to right < Right to left = Bidirectional ====== ===========================

Variables:
  • name – The name of the reaction
  • description – A description of the reaction
  • equation – The reaction equation
  • direction – The direction of the reaction (<, =, >, or ?)
  • left_compounds – A set of compounds on the left side of the reaction
  • left_abundance – A dict of the compounds on the left and their abundance
  • right_compounds – The set of compounds on the right side of the equation
  • right_abundance – A dict of the compounds on the right and their abundance
  • lower_bound – The lower bound for the reaction
  • upper_bound – The upper bound for the reaction
  • pLR – The probability the reaction proceeds left to right
  • pRL – The probability the reaction proceeds right to left
  • enzymes – The enzyme complex IDs involved in the reaction
  • pegs – The protein-encoding genes involved in the reaction
  • deltaG – The delta G
  • deltaG_error – The error in the delta G
  • inp – Whether the reaction is an input reaction
  • outp – Whether the reaction is an output reaction
  • is_transport – Whether the reaction is a transport reaction (imports or exports something)
  • ran – Boolean to note whether the reaction ran
  • is_biomass_reaction – Boolean to note whether this is a biomass reaction
  • biomass_direction – If it is a biomass reaction, what is the direction
  • is_gapfilled – Boolean to note whether the reaction was gapfilled
  • gapfill_method – If the reaction was gapfilled, how was it gapfilled
  • is_uptake_secretion – Is the reaction involved in uptake of compounds or secretion of compounds.
add_enzymes(enz)

Add one or more enzymes that completes this reaction.

Parameters:enz (set) – A set of enzymes that you want to add
add_left_compounds(cmpds)

The compounds on the left are a set of compounds that the reaction typically uses as substrates.

Parameters:cmpds (set) – The compounds that should be added
add_pegs(pegs)

Add one or more pegs to this reaction. Pegs must be a set.

Parameters:pegs (set) – The pegs to add to the reaction
add_right_compounds(cmpds)

The compounds on the right are a set of compounds that the reaction typically uses as substrates.

Parameters:cmpds (set) – The compounds that should be added
all_compounds()

Get all the compounds involved in this reaction.

Returns:A set of all the compounds
Return type:set
all_enzymes()

Get all the enzymes involved in this reaction. Returns a set of complex IDs.

Return type:set
check_input_output()

Check whether this reaction is an input or output reaction.

This is called when we ask is_input_reaction / is_output_reaction and both inp and outp are False

get_deltaG()

Get the value for delta G (Gibbs free energy) for this reaction.

Return type:float
get_left_compound_abundance(cmpd)

Get the abundance of the compound on the left side of the equation.

Parameters:cmpd (Compound) – The compound to get the abundance of
Returns:The compounds abundance
Return type:float
get_probability_left_to_right()

Get the probability of the reaction running left to right. Note you can also access this as reaction.pLR

Returns:The probablity
Rtype p:float
get_probability_right_to_left()

Get the probability of the reaction running right to left. Note you can also access this as reaction.pRL

Returns:The probablity
Rtype p:float
get_right_compound_abundance(cmpd)

Get the abundance of the compound on the right side of the equation.

Parameters:cmpd (Compound) – The compound to get the abundance of
Returns:The compounds abundance
Return type:float
has(cmpd)

Does this reaction have a compound? Just returns true if the compound is present somewhere in the reaction.

Parameters:cmpd (Compound) – The compound to test for
Return type:bool
has_enzyme(enz)

Check whether an enzyme is involved in this reaction.

Parameters:enz (Enzyme) – An Enzyme object
Returns:Whether we have this enzyme
Return type:bool
has_peg(peg)

Check whether a peg is involved in this reaction.

Parameters:peg (str) – The peg to check for
Return type:bool
is_input_reaction()

Is this an input reaction?

Return type:bool
is_output_reaction()

Is this an output reaction?

Return type:bool
number_of_compounds()

Get the total number of compounds involved in this reaction.

Return type:int
number_of_enzymes()

Gets the number of enzymes involved in this reaction.

Return type:int
number_of_left_compounds()

The number of compounds on the left side of the equation.

Return type:int
number_of_right_compounds()

The number of compounds on the right side of the equation.

Return type:int
opposite_sides(cmpd1, cmpd2)

Are these two compounds on opposite sides of the reaction?

Parameters:
  • cmpd1 (Compound) – The first compound
  • cmpd2 (Compound) – The second compound
Returns:

Whether the compounds are on opposite sides

Return type:

bool

reverse_reaction()

Reverse the reaction - move the left compounds to the right, and vice versa. We also switch the abundances and the pLR and pRL.

We also negate the deltaG, since that should be the other way around now.

At the moment we don’t switch input/output, not sure if we need to do that.

set_deltaG(dg)

Set the value for delta G (Gibbs free energy) for this reaction. Recall -ve deltaG means the reaction is favorable.

Parameters:dg (float) – The delta G of the reaction
set_direction(direction)

Set the direction of the reaction.

Parameters:direction (str) – The direction of the reaction
Return type:str
Returns:The current direction
set_left_compound_abundance(cmpd, abundance)

Set the abundance of a compound on the left side of the equation.

Parameters:
  • cmpd (Compound) – The compound to set the abundance for
  • abundance (float) – The amount of that abundance
set_probability_left_to_right(p)

Set the probability of the reaction running left to right. Note you can also access this as reaction.pLR

Parameters:p (float) – The probablity
set_probability_right_to_left(p)

Set the probability of the reaction running right to left Note you can also access this as reaction.pRL

Parameters:p (float) – The probablity
set_right_compound_abundance(cmpd, abundance)

Set the abundance of a compound on the right side of the equation

Parameters:
  • cmpd (Compound) – The compound to set the abundance for
  • abundance (float) – The amount of that abundance
toggle_input_reaction()

Set this reaction as an input reaction. This only applies to this reaction, so if it is true we set it false, else we set it true

toggle_output_reaction()

Set this reaction as an output reaction. This only applies to this reaction, so if it is true we set it false, else we set it true