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'insympyexpressions.- Parameters
- Returns
The
sympyexpression(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'insympyexpressions.- Parameters
- Returns
The
sympyexpression(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
sympyexpressions.
- 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_constantand theequilibrium_constant.Type 2 will utilize the
forward_rate_constantand thereverse_rate_constant.Type 3 will utilize the
equilibrium_constantand thereverse_rate_constant.
Default is
1.
- Returns
The rate law as a
sympyexpression. If the reaction has no metabolites associated,Nonewill be returned.- Return type
Basic or None
- 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_constantand thereverse_rate_constant.
Default is 1.
- Returns
The forward rate as a
sympyexpression. If the reaction has no metabolites associated,Nonewill be returned.- Return type
Basic or None
- 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_constantand theequilibrium_constant.Type 2 and 3 will utilize the
reverse_rate_constant.
Default is 1.
- Returns
The reverse rate as a
sympyexpression. If the reaction has no metabolites associated,Nonewill be returned.- Return type
Basic or None
- 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
sympyexpression.- 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
sympyexpression.- Return type
- mass.util.expressions.create_custom_rate(reaction, custom_rate, custom_parameters=None)[source]
Create a
sympyexpression for a given custom rate law.Notes
Metabolites must already exist in the
MassModelorMassReaction.Default parameters of a
MassReactionare 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
sympyexpression. IfNonethen parameters are assumed to be one or more of the reaction rate or equilibrium constants.
- Returns
A
sympyexpression of the custom rate. If no metabolites are assoicated with the reaction,Nonewill be returned.- Return type
Basic or None
See also
MassReaction.all_parameter_idsList of default reaction parameters automatically accounted for.
- mass.util.expressions.generate_ode(metabolite)[source]
Generate the ODE for a given metabolite as a
sympyexpression.- Parameters
metabolite (MassMetabolite) – The metabolite to generate the ODE for.
- Returns
ode – A
sympyexpression of the metabolite ODE. If the metabolite is not associated with any reactions, thenNonewill be returned.- Return type
Basic or None