mass.enzyme_modules.enzyme_module
EnzymeModule is a class for handling reconstructions of enzymes.
The EnzymeModule
is a reconstruction an enzyme’s mechanism and
behavior in a context of a larger system. To aid in the reconstruction process,
the EnzymeModule
contains various methods to build and add associated
EnzymeModuleForm
and EnzymeModuleReaction
s
of the enzyme module (see make_enzyme_module_forms()
and
make_enzyme_module_reaction()
methods, respecitvely).
Given the wide variety of enzymes and the various interactions it can have with ligands (e.g. catalyzation, inhibition, activation, etc.), the enzyme module has the following “categorized dict” attributes:
These “categorized dict” attributes allow the user to define categories and
place various objects into one or more categories in the respective
“categorized dict” attribute (ligands a.k.a.
MassMetabolite
s, EnzymeModuleForm
, and
EnzymeModuleReaction
s). Utilizing categories with these attributes
can help with the management of complex enzymes, and are preserved upon
merging an EnzymeModule
into a MassModel
.
Because the EnzymeModule
is a subclass of the MassModel
, it
can be merged with a MassModel
representing the larger network in
which the enzyme is a part of. For best results, an EnzymeModule
should always be merged into the model as follows:
model.merge(enzyme_module, inplace=False)
# OR
new_model = model.merge(enzyme_module, inplace=True)
Once merged, the EnzymeModuleForm
and
EnzymeModuleReaction
s of the EnzymeModule
are treated
like any other MassMetabolite
or MassReaction
.
Therefore, to prevent the loss of the enzyme specific information that was
stored in the EnzymeModule
, the enzyme module is converted into an
ordered dictionary known as an EnzymeModuleDict
, which contains
most of the enzyme specific attribute information. Note that all enzyme
specific attribute names start with either "enzyme"
or "enzyme_module"
.
During the model merging process, the EnzymeModuleDict
is created,
then stored in the MassModel.enzyme_modules
attribute for access at
a later time. See the enzyme_module_dict
documentation for more
information about the EnzymeModuleDict
.
Module Contents
Classes
Class representation of an enzyme module reconstruction. |
- class mass.enzyme_modules.enzyme_module.EnzymeModule(id_or_model=None, name=None, subsystem='', array_type='dense', dtype=np.float64)[source]
Bases:
mass.core.mass_model.MassModel
Class representation of an enzyme module reconstruction.
- Parameters
id_or_model (str, MassModel, EnzymeModule) – A string identifier to associate with the
EnzymeModule
, or an existing model object. If an existing model object is provided, a newEnzymeModule
object is instantiated with the same properties as the original model.name (str) – A human readable name for the model.
subsystem (str) – The subsystem in which the enzyme module is a part of.
array_type (str) – A string identifiying the desired format for the returned matrix. Valid matrix types include
'dense'
,'dok'
,'lil'
,'DataFrame'
, and'symbolic'
Default is'DataFrame'
. See thematrix
module documentation for more information on thearray_type
.dtype (data-type) – The desired array data-type for the stoichiometric matrix. If
None
then the data-type will default tonumpy.float64
.
- enzyme_module_ligands
A
DictList
where the keys are the metabolite identifiers and the values are the associatedMassMetabolite
s.- Type
- enzyme_module_forms
A
DictList
where the keys are theEnzymeModuleForm
identifiers and the values are the associatedEnzymeModuleForm
.- Type
- enzyme_module_reactions
A
DictList
where keys are the reaction identifiers and the values are the associatedEnzymeModuleReaction
s.- Type
- property enzyme_total_symbol_str[source]
Get the symbol as a string for the total enzyme concentration.
- property enzyme_flux_symbol_str[source]
Get the symbol as a string for the net flux through the enzyme.
- property enzyme_concentration_total[source]
Get or set the total concentration value.
Notes
The total concentration of the enzyme cannot be negative.
- Parameters
concentration (float) – A non-negative number for the concentration of the enzyme.
- Raises
ValueError – Occurs when trying to set a negative value.
- property enzyme_rate[source]
Get or set the flux through the enzyme.
- Parameters
value (float) – The value of the net flux through the enzyme.
- property enzyme_concentration_total_equation[source]
Return the total concentration equation.
Notes
Will sum the
EnzymeModuleForm
that have theirenzyme_module_id
match theEnzymeModule.id
.If no
EnzymeModuleForm
are found to have anenzyme_module_id
that matches theEnzymeModule.id
, allEnzymeModuleForm
in the the model will be used.
- Returns
A
sympy
expression of the sum of theEnzymeModuleForm
.- Return type
- property enzyme_module_ligands_categorized[source]
Get or set categories for ligands.
Notes
A ligand must already exist in the
EnzymeModule
as aMassMetabolite
in order to set its category.If categories already exists, their existing contents are updated.
Setting an empty
list
for a category in the dict will cause that particular category group to be removed completely from the model.Setting an empty
dict
will cause ALL category groups to be removed completely from the model.
- Parameters
Either a
cobra.Group
to add to the categorized ligands, or adict
where keys are strings representing categories for the ligands, and values arelists
containing the correspondingMassMetabolite
s or their identifiers.An empty
list
will remove the corresponding category from the model and attribute.An empty
dict
will remove all categories from the attribute and the model.
- property enzyme_module_forms_categorized[source]
Get or set categories for enzyme module forms.
Notes
An enzyme module form must already exist in the
EnzymeModule
as anEnzymeModuleForm
in order to set its category.If categories already exists, their existing contents are updated.
Setting an empty
list
for a category in the dict will cause that particular category group to be removed completely from the model.Setting an empty
dict
will cause ALL category groups to be removed completely from the model.
- Parameters
Either a
cobra.Group
to add to the categorized enzyme module forms, or adict
where keys are strings representing categories for the enzyme module forms, and values arelists
containing the correspondingEnzymeModuleForm
s or their identifiers.An empty
list
will remove the corresponding category from the model and attribute.An empty
dict
will remove all categories from the attribute and the model.
- property enzyme_module_reactions_categorized[source]
Get or set categories for enzyme module reactions.
Notes
An enzyme module reaction must already exist in the
EnzymeModule
as anEnzymeModuleReaction
in order to set its category.If categories already exists, their existing contents are updated.
Setting an empty
list
for a category in the dict will cause that particular category group to be removed completely from the model.Setting an empty
dict
will cause ALL category groups to be removed completely from the model.
- Parameters
Either a
cobra.Group
to add to the categorized enzyme module reaction, or adict
where keys are strings representing categories for the enzyme module reactions, and values arelists
containing the correspondingEnzymeModuleReactions
s or their identifiers.An empty
list
will remove the corresponding category from the model and attribute.An empty
dict
will remove all categories from the attribute and the model.
- make_enzyme_module_form(id=None, name='automatic', categories=None, bound_metabolites=None, compartment=None)[source]
Create and add an
EnzymeModuleForm
to the module.Notes
Upon creation, the
EnzymeModuleForm
is added to theEnzymeModule
.If
MassMetabolite
s in thebound_metabolites
argument do not already exist in theEnzymeModule
, they will also be added.
- Parameters
id (str) – A string identifier to associate with the enzymatic forms.
name (str) – Either a human readable name for the enzyme module forms, or the string
"automatic"
. If set to"automatic"
, a name will be generated based on the identifier of the enzyme module forms and its bound ligands.categories (str or list) – A string representing the category, or a list of strings containing several categories for the enzyme module forms.
bound_metabolites (dict) – A
dict
representing the ligands bound to the enzyme, withMassMetabolite
s or their identifiers as keys and the number bound as values.compartment (str) – The compartment where the enzyme module forms is located.
- Returns
The newly created
EnzymeModuleForm
.- Return type
See also
EnzymeModuleForm.generate_enzyme_module_forms_name
Automatic generation of the
name
for anEnzymeModuleForm
.
- make_enzyme_module_reaction(id=None, name='', subsystem=None, reversible=True, categories=None, metabolites_to_add=None)[source]
Create and add an
EnzymeModuleReaction
to the module.Notes
When adding metabolites, a final coefficient of < 0 implies a reactant and a final coefficient of > 0 implies a product.
- Parameters
id (str) – The identifier associated with the enzyme module reaction.
name (str) – A human readable name for the enzyme module reaction. If name is set to match
"automatic"
, a name will be generated based on theEnzymeModuleForm
and their bound ligands.subsystem (str) – The subsystem where the reaction is meant to occur.
reversible (bool) – The kinetic reversibility of the reaction. Irreversible reactions have an equilibrium constant and a reverse rate constant as set in the
irreversible_Keq
andirreversible_kr
attributes of theMassConfiguration
. Default isTrue
.categories (str or list) – A string representing the category, or a list of strings containing several categories for the enzyme module reactions.
metabolites_to_add (dict) – A
dict
withMassMetabolite
s andEnzymeModuleForm
or their identifiers as keys and stoichiometric coefficients as values. If keys are string identifiers then theMassMetabolite
s andEnzymeModuleForm
must already be a part of model.
- Returns
The newly created
EnzymeModuleReaction
.- Return type
See also
EnzymeModuleReaction.generate_enzyme_module_reaction_name
Automatic generation of the
name
for anEnzymeModuleReaction
.
- unify_rate_parameters(reaction_list, new_parameter_id, rate_type=1, enzyme_prefix=False)[source]
Unify rate law parameters for a list of enzyme module reactions.
After unification, the new parameters and rate laws are placed into the
custom_parameters
andcustom_rates
attributes, repsectively.- Parameters
reaction_list (list) – A
list
containingEnzymeModuleReaction
s or their string identifiers.EnzymeModuleReaction
s must already exist in theEnzymeModule
.new_parameter_id (str) – The new parameter ID to use for the unified reaction parameters. The forward rate, reverse rate, and/or equilibrium constants in the current rate law will have the reaction ID component replaced with the
new_parameter_id
in the parameter ID.rate_type (int) –
The type of rate law to utilize in unification. 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
.enzyme_prefix (bool) – If
True
, add theEnzymeModule
ID as a prefix to thenew_parameter_id
before using thenew_parameter_id
in the rate parameter unification. Default isFalse
.
- make_enzyme_rate_equation(enzyme_module_reactions, use_rates=False, update_enzyme=False)[source]
Create an equation representing the net flux through the enzyme.
The left side of the rate equation will always be the flux symbol of the enzyme, accessible via
enzyme_flux_symbol_str
.- Parameters
enzyme_module_reactions (list) – A list containing the
EnzymeModuleReaction
s or their identifiers to be summed for the equation.use_rates (bool) – If
True
, then the rates of the provided reactions are used in creating the expression. Otherwise the arguments in the expression are left as theEnzymeModuleReaction.flux_symbol_str
s.update_enzyme (bool) – If
True
, update theenzyme_rate_equation
attribute and, if necessary, theenzyme_module_reactions
attribute of the module in addition to returning the generated equation. Otherwise just return the net flux equation without making any updates. Default isFalse
.
- Returns
A
sympy
expression of the net flux equation.- Return type
- sum_enzyme_module_form_concentrations(enzyme_module_forms, use_values=False)[source]
Sum the forms concentrations for a list of enzyme module forms.
- Parameters
enzyme_module_forms (list) – A
list
containing theEnzymeModuleForm
or their identifiers to be summed. Forms must already exist in theEnzymeModule
.use_values (bool) – If
True
, then numerical values are substituted into the expression. Otherwise arguments in the expression are left assympy
symbols.
- Returns
The sum of the concentrations for the given enzyme module forms as a
float
ifuse_values
isTrue
and all values are present. Otherwise returns asympy
expression representing the sum of the given enzyme module forms.- Return type
- sum_enzyme_module_reaction_fluxes(enzyme_module_reactions, use_values=False)[source]
Sum the enzyme reaction steady state fluxes for a list of reactions.
- Parameters
enzyme_module_reactions (list) – A
list
a containing theEnzymeModuleReaction
or their identifiers to be summed. Reactions must already exist in the module and must be considered an enzyme module reaction.use_values (bool) – If
True
, then numerical values are substituted into the expression. Otherwise arguments in the expression are left assympy
symbols.
- Returns
The sum of the steady state fluxes for the given enzyme reaction as a
float
ifuse_values
isTrue
and all values are present. Otherwise returns asympy
expression representing the sum of the enzyme module reaction fluxes.- Return type
- enzyme_concentration_total_error(use_values=False)[source]
Return the error for the total enzyme concentrations.
The error of the total enzyme concentration is defined to be the difference between the
enzyme_concentration_total
value and the sum of allEnzymeModuleForm
initial conditions in the model.Notes
Positive values indicate the value in the
enzyme_concentration_total
attribute is greater than the value calculated using the expression from theenzyme_concentration_total_equation
attribute.- Parameters
use_values (bool) – If
True
, then numerical values are substituted into the expression. Otherwise arguments in the expression are left assympy
symbols.- Returns
The error between the set
enzyme_concentration_total
and the sum of theEnzymeModuleForm
initial condition values in the model as afloat
ifuse_values
isTrue
and all values are present. Otherwise returns asympy
expression representing the error.- Return type
- enzyme_rate_error(use_values=False)[source]
Return the error for the net flux through the enzyme.
The error of the enzyme net flux is defined to be the difference between the
enzyme_rate
value and the calculated value for theenzyme_rate_equation
.Notes
Positive values indicate the value in
enzyme_rate
attribute is greater than the value calculated using the expression from theenzyme_rate_equation
attribute.- Parameters
use_values (bool) – If
True
, then numerical values are substituted into the expression. Otherwise arguments in the expression are left assympy
symbols.- Returns
The error between the set
enzyme_rate
and the calculated value for theenzyme_rate_equation
attribute as afloat
ifuse_values
isTrue
and all values are present in the model. Otherwise returns asympy
expression representing the error.- Return type
- make_enzyme_fraction(categorized_attr, top, bottom, use_values=False)[source]
Make the expression for a ratio of categorized enzyme objects.
Notes
The string
"Equation"
can be passed to eithertop
orbottom
to utilize the equation in the corresponding attribute (i.e.enzyme_concentration_total_equation
for'forms'
andenzyme_rate_equation
for'reactions'
).- Parameters
categorized_attr (str) – Either a string representing which categorized attribute to use or the attribute itself to use in making the enzyme ratio expression. Use the string
'forms'
forenzyme_module_forms_categorized
, or'reactions'
forenzyme_module_reactions_categorized
.top (str) – A string representing a category in the categorized attribute. The summation expression of the objects in the corresponding list is used as the top (numerator) of the fraction to be made. Alternatively, the string
"Equation"
can be provided to utilize an equation attribute.bottom (str) – A string representing a category in the categorized attribute. The summation expression of the objects in the corresponding list is used as the bottom (denominator) of the fraction to be made. Alternatively, the string
"Equation"
can be provided to utilize an equation attribute.use_values (bool) – If
True
, then numerical values are substituted into the expression. Otherwise arguments in the expression are left assympy
symbols.
- Returns
The fraction either calculated and returned as float if
use_values
isTrue
and all values are present in the model, or asympy
expression representing the formula for the fraction.- Return type
- add_metabolites(metabolite_list)[source]
Add a list of metabolites and enzyme forms to the module.
The change is reverted upon exit when using the
EnzymeModule
as a context.Notes
Extends from
MassModel.add_metabolites()
.- Parameters
metabolite_list (list) – A list of
MassMetabolite
s andEnzymeModuleForm
to add to theEnzymeModule
.add_initial_conditons (bool) – If
True
, the initial conditions associated with the species are also added to the model. Otherwise, the species are added without their initial conditions.
- remove_metabolites(metabolite_list, destructive=False)[source]
Remove a list of metabolites and enzyme forms from the module.
The species’ initial conditions will also be removed from the model.
The change is reverted upon exit when using the
EnzymeModule
as a context.Notes
Extends from
MassModel.remove_metabolites()
.- Parameters
metabolite_list (list) – A list of
MassMetabolite
s andEnzymeModuleForm
to remove from theEnzymeModule
.destructive (bool) – If
False
, the species are removed from all associatedEnzymeModuleReaction
s . IfTrue
, also remove associatedEnzymeModuleReaction
s from theEnzymeModule
.
- add_reactions(reaction_list)[source]
Add a list of reactions to the
EnzymeModule
.MassReaction
s andEnzymeModuleReaction
s with identifiers identical to an existing reaction are ignored.The change is reverted upon exit when using the
EnzymeModule
as a context.Notes
Extends from
MassModel.add_reactions()
.- Parameters
reaction_list (list) – A list of
MassReaction
andEnzymeModuleReaction
to add.
- remove_reactions(reactions, remove_orphans=False)[source]
Remove reactions from the
EnzymeModule
.The change is reverted upon exit when using the
EnzymeModule
as a context.Notes
Extends from
MassModel.remove_reactions()
.- Parameters
reactions (list) – A list of
MassReaction
andEnzymeModuleReaction
to remove from theEnzymeModule
.remove_orphans (bool) – If
True
, will also remove orphaned genes,MassMetabolite
s, andEnzymeModuleForm
from theEnzymeModule
.
- repair(rebuild_index=True, rebuild_relationships=True)[source]
Update all indicies and pointers in the model.
In addition to updating indicies and pointers, the
enzyme_module_reactions
attribute will be updated to ensure it contains all existing reactions involvingEnzymeModuleForm
.Notes
Extends from
MassModel.repair()
.
- copy()[source]
Create a partial “deepcopy” of the EnzymeModule.
All of the
MassMetabolite
s,MassReaction
s,Gene
s,EnzymeModuleForm
,EnzymeModuleReaction
s, andEnzymeModuleDict
s, the boundary conditions, custom rates, custom parameters, and the stoichiometric matrix are created anew, but in a faster fashion thandeepcopy
.Notes
Overrides
MassModel.copy()
in order to exclude more items to not copy by ref.
- merge(right, prefix_existing=None, inplace=True, objective='left')[source]
Merge two models into one model with the objects from both.
The reactions, metabolites, genes, enzyme modules, boundary conditions, custom rate expressions, rate parameters, compartments, units, notes, and annotations from the right model are also copied to left model. However, note that in cases where identifiers for objects are identical or a dict item has an identical key(s), priority will be given to what already exists in the left model.
Notes
When merging an
EnzymeModule
into aMassModel
, the enzyme module is converted to anEnzymeModuleDict
and stored in aDictList
accessible via theenzyme_modules
attribute. If anEnzymeModuleDict
already exists in the model, it will be replaced.If an
EnzymeModule
already exists in the model, it will be replaced.When merging an
EnzymeModule
with anotherEnzymeModule
, a newEnzymeModule
will be returned, where the EnzymeModule is a copy of the ‘left’ model (self
) with the'right'
model is contained within.Overrides
MassModel.merge()
.
- Parameters
right (MassModel) – The model to merge into the left model. If a
MassModel
then the first model refers to theright
model and the second model refers to theleft
model. Otherwise the first model refers to theleft
model and the second model refers to theright
model.prefix_existing (str) – If provided, the string is used to prefix the reaction identifier of a reaction in the second model if that reaction already exists within the first model. Will also apply prefix to identifiers of enzyme modules in the second model.
inplace (bool) – If
True
then add reactions from second model directly to the first model. Otherwise, create a new model leaving the first model untouched. When done within the model as context, changes to the models are reverted upon exit.objective (str) – One of
"left"
,"right"
or"sum"
for setting the objective of the resulting model to that of the corresponding model or the sum of both. Default is"left"
. Note that when merging aMassModel
with anEnzymeModule
,"left"
will refer to theMassModel
.
- Returns
A new
MassModel
orEnzymeModule
representing the merged model.- Return type
- _set_category_attribute(item, attr, to_filter)[source]
Set the categorized attribute after ensuring it is valid.
Warning
This method is intended for internal use only.
- _set_enzyme_object_category(attr, category, object_list)[source]
Add a list of objects to a new or existing category.
Notes
If a category already exists, the objects will be added to the corresponding
cobra.Group
.The objects to be categorized must already exist in the
EnzymeModule
.An empty
object_list
will cause the group representing the category to be removed.
- Parameters
category (str) – A string representing the category for the list of objects to be categorized.
object_list (list) –
A
list
containing the objects to be categorized. Thelist
must contain ONLY one of the followingmass
object types:MassMetabolite
s representing enzyme ligands.EnzymeModuleForm
s representing enzymatic forms.EnzymeModuleReaction
s representing enzymatic binding reactions ligands.
- _update_object_pointers()[source]
Update objects in the attributes to be the objects from the model.
Warning
This method is intended for internal use only.
- _get_current_enzyme_module_objs(attr, update_enzyme=True)[source]
Get the enzyme module objects for ‘attr’ that exist in the model.
- Parameters
attr (str {'ligands', 'forms', 'reactions'}) – A string representing which attribute to update.
update_enzyme (bool) – If True, update the enzyme_module_reactions attribute of the EnzymeModule.
Warning
This method is intended for internal use only.
- _make_summation_expr(items, object_type)[source]
Create a sympy expression of the summation of the given items.
Warning
This method is intended for internal use only.
- _sub_values_into_expr(expr, object_type, additional=None)[source]
Substitute values into an expression and try to return a float.
Warning
This method is intended for internal use only.