mass.util.expressions
Handles generation and manipulation of sympy
expressions.
Module Contents
Functions
|
Replace |
|
Replace |
|
Strip the time dependency in |
|
Generate the mass action rate law for the reaction. |
|
Generate the forward mass action rate expression for the reaction. |
|
Generate the reverse mass action rate expression for the reaction. |
|
Generate the mass action ratio for a given reaction. |
|
Generate the disequilibrium ratio for a given reaction. |
|
Create a |
|
Generate the ODE for a given metabolite as a |
- mass.util.expressions.Keq2k(sympy_expr, simplify=False)[source]
Replace
'Keq'
symbols with'kf/kr'
insympy
expressions.- Parameters
- Returns
The
sympy
expression(s) with the substitution made, returned as the same type as the original input.- Return type
- mass.util.expressions.k2Keq(sympy_expr, simplify=False)[source]
Replace
'kr'
symbols with'kf/Keq'
insympy
expressions.- Parameters
- Returns
The
sympy
expression(s) with the substitution made, returned as the same type as the original input.- Return type
- mass.util.expressions.strip_time(sympy_expr)[source]
Strip the time dependency in
sympy
expressions.
- mass.util.expressions.generate_mass_action_rate_expression(reaction, rate_type=1)[source]
Generate the mass action rate law for the reaction.
- Parameters
reaction (MassReaction) – The reaction to generate the rate expression for.
rate_type (int) –
The type of rate law to return. Must be 1, 2, or 3.
Type 1 will utilize the
forward_rate_constant
and theequilibrium_constant
.Type 2 will utilize the
forward_rate_constant
and thereverse_rate_constant
.Type 3 will utilize the
equilibrium_constant
and thereverse_rate_constant
.
Default is
1
.
- Returns
The rate law as a
sympy
expression. If the reaction has no metabolites associated,None
will be returned.- Return type
- mass.util.expressions.generate_forward_mass_action_rate_expression(reaction, rate_type=1)[source]
Generate the forward mass action rate expression for the reaction.
- Parameters
reaction (MassReaction) – The reaction to generate the rate expression for.
rate_type (int) –
The type of rate law to return. Must be 1, 2, or 3.
Type 1 and 2 will utilize the
forward_rate_constant
.Type 3 will utilize the
equilibrium_constant
and thereverse_rate_constant
.
Default is 1.
- Returns
The forward rate as a
sympy
expression. If the reaction has no metabolites associated,None
will be returned.- Return type
- mass.util.expressions.generate_reverse_mass_action_rate_expression(reaction, rate_type=1)[source]
Generate the reverse mass action rate expression for the reaction.
- Parameters
reaction (MassReaction) – The reaction to generate the rate expression for.
rate_type (int) –
The type of rate law to return. Must be 1, 2, or 3.
Type 1 will utilize the
forward_rate_constant
and theequilibrium_constant
.Type 2 and 3 will utilize the
reverse_rate_constant
.
Default is 1.
- Returns
The reverse rate as a
sympy
expression. If the reaction has no metabolites associated,None
will be returned.- Return type
- mass.util.expressions.generate_mass_action_ratio(reaction)[source]
Generate the mass action ratio for a given reaction.
- Parameters
reaction (MassReaction) – The reaction to generate the mass action ratio for.
- Returns
The mass action ratio as a
sympy
expression.- Return type
- mass.util.expressions.generate_disequilibrium_ratio(reaction)[source]
Generate the disequilibrium ratio for a given reaction.
- Parameters
reaction (MassReaction) – The reaction to generate the disequilibrium ratio for.
- Returns
The disequilibrium ratio as a
sympy
expression.- Return type
- mass.util.expressions.create_custom_rate(reaction, custom_rate, custom_parameters=None)[source]
Create a
sympy
expression for a given custom rate law.Notes
Metabolites must already exist in the
MassModel
orMassReaction
.Default parameters of a
MassReaction
are automatically taken into account and do not need to be defined as additional custom parameters.
- Parameters
reaction (MassReaction) – The reaction associated with the custom rate.
custom_rate (str) – The custom rate law as a str. The string representation of the custom rate law will be used to create the expression through the
sympify()
function.custom_parameters (list of str) – The custom parameter(s) of the custom rate law as a list of strings. The string representation of the custom parameters will be used for creation and recognition of the custom parameter symbols in the
sympy
expression. IfNone
then parameters are assumed to be one or more of the reaction rate or equilibrium constants.
- Returns
A
sympy
expression of the custom rate. If no metabolites are assoicated with the reaction,None
will be returned.- Return type
See also
MassReaction.all_parameter_ids
List of default reaction parameters automatically accounted for.
- mass.util.expressions.generate_ode(metabolite)[source]
Generate the ODE for a given metabolite as a
sympy
expression.- Parameters
metabolite (MassMetabolite) – The metabolite to generate the ODE for.
- Returns
ode – A
sympy
expression of the metabolite ODE. If the metabolite is not associated with any reactions, thenNone
will be returned.- Return type