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 EnzymeModuleReactions
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.
MassMetabolites, EnzymeModuleForm, and
EnzymeModuleReactions). 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
EnzymeModuleReactions 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.MassModelClass 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 newEnzymeModuleobject 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 thematrixmodule documentation for more information on thearray_type.dtype (data-type) – The desired array data-type for the stoichiometric matrix. If
Nonethen the data-type will default tonumpy.float64.
- enzyme_module_ligands
A
DictListwhere the keys are the metabolite identifiers and the values are the associatedMassMetabolites.- Type
- enzyme_module_forms
A
DictListwhere the keys are theEnzymeModuleFormidentifiers and the values are the associatedEnzymeModuleForm.- Type
- enzyme_module_reactions
A
DictListwhere keys are the reaction identifiers and the values are the associatedEnzymeModuleReactions.- 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
EnzymeModuleFormthat have theirenzyme_module_idmatch theEnzymeModule.id.If no
EnzymeModuleFormare found to have anenzyme_module_idthat matches theEnzymeModule.id, allEnzymeModuleFormin the the model will be used.
- Returns
A
sympyexpression 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
EnzymeModuleas aMassMetabolitein order to set its category.If categories already exists, their existing contents are updated.
Setting an empty
listfor a category in the dict will cause that particular category group to be removed completely from the model.Setting an empty
dictwill cause ALL category groups to be removed completely from the model.
- Parameters
Either a
cobra.Groupto add to the categorized ligands, or adictwhere keys are strings representing categories for the ligands, and values arelistscontaining the correspondingMassMetabolites or their identifiers.An empty
listwill remove the corresponding category from the model and attribute.An empty
dictwill 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
EnzymeModuleas anEnzymeModuleFormin order to set its category.If categories already exists, their existing contents are updated.
Setting an empty
listfor a category in the dict will cause that particular category group to be removed completely from the model.Setting an empty
dictwill cause ALL category groups to be removed completely from the model.
- Parameters
Either a
cobra.Groupto add to the categorized enzyme module forms, or adictwhere keys are strings representing categories for the enzyme module forms, and values arelistscontaining the correspondingEnzymeModuleForms or their identifiers.An empty
listwill remove the corresponding category from the model and attribute.An empty
dictwill 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
EnzymeModuleas anEnzymeModuleReactionin order to set its category.If categories already exists, their existing contents are updated.
Setting an empty
listfor a category in the dict will cause that particular category group to be removed completely from the model.Setting an empty
dictwill cause ALL category groups to be removed completely from the model.
- Parameters
Either a
cobra.Groupto add to the categorized enzyme module reaction, or adictwhere keys are strings representing categories for the enzyme module reactions, and values arelistscontaining the correspondingEnzymeModuleReactionss or their identifiers.An empty
listwill remove the corresponding category from the model and attribute.An empty
dictwill 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
EnzymeModuleFormto the module.Notes
Upon creation, the
EnzymeModuleFormis added to theEnzymeModule.If
MassMetabolites in thebound_metabolitesargument 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
dictrepresenting the ligands bound to the enzyme, withMassMetabolites 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_nameAutomatic generation of the
namefor anEnzymeModuleForm.
- make_enzyme_module_reaction(id=None, name='', subsystem=None, reversible=True, categories=None, metabolites_to_add=None)[source]
Create and add an
EnzymeModuleReactionto 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 theEnzymeModuleFormand 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_Keqandirreversible_krattributes 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
dictwithMassMetabolites andEnzymeModuleFormor their identifiers as keys and stoichiometric coefficients as values. If keys are string identifiers then theMassMetabolites andEnzymeModuleFormmust already be a part of model.
- Returns
The newly created
EnzymeModuleReaction.- Return type
See also
EnzymeModuleReaction.generate_enzyme_module_reaction_nameAutomatic generation of the
namefor 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_parametersandcustom_ratesattributes, repsectively.- Parameters
reaction_list (list) – A
listcontainingEnzymeModuleReactions or their string identifiers.EnzymeModuleReactions 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_idin 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_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.enzyme_prefix (bool) – If
True, add theEnzymeModuleID as a prefix to thenew_parameter_idbefore using thenew_parameter_idin 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
EnzymeModuleReactions 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_strs.update_enzyme (bool) – If
True, update theenzyme_rate_equationattribute and, if necessary, theenzyme_module_reactionsattribute 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
sympyexpression 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
listcontaining theEnzymeModuleFormor 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 assympysymbols.
- Returns
The sum of the concentrations for the given enzyme module forms as a
floatifuse_valuesisTrueand all values are present. Otherwise returns asympyexpression 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
lista containing theEnzymeModuleReactionor 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 assympysymbols.
- Returns
The sum of the steady state fluxes for the given enzyme reaction as a
floatifuse_valuesisTrueand all values are present. Otherwise returns asympyexpression 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_totalvalue and the sum of allEnzymeModuleForminitial conditions in the model.Notes
Positive values indicate the value in the
enzyme_concentration_totalattribute is greater than the value calculated using the expression from theenzyme_concentration_total_equationattribute.- Parameters
use_values (bool) – If
True, then numerical values are substituted into the expression. Otherwise arguments in the expression are left assympysymbols.- Returns
The error between the set
enzyme_concentration_totaland the sum of theEnzymeModuleForminitial condition values in the model as afloatifuse_valuesisTrueand all values are present. Otherwise returns asympyexpression 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_ratevalue and the calculated value for theenzyme_rate_equation.Notes
Positive values indicate the value in
enzyme_rateattribute is greater than the value calculated using the expression from theenzyme_rate_equationattribute.- Parameters
use_values (bool) – If
True, then numerical values are substituted into the expression. Otherwise arguments in the expression are left assympysymbols.- Returns
The error between the set
enzyme_rateand the calculated value for theenzyme_rate_equationattribute as afloatifuse_valuesisTrueand all values are present in the model. Otherwise returns asympyexpression 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 eithertoporbottomto utilize the equation in the corresponding attribute (i.e.enzyme_concentration_total_equationfor'forms'andenzyme_rate_equationfor'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 assympysymbols.
- Returns
The fraction either calculated and returned as float if
use_valuesisTrueand all values are present in the model, or asympyexpression 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
EnzymeModuleas a context.Notes
Extends from
MassModel.add_metabolites().- Parameters
metabolite_list (list) – A list of
MassMetabolites andEnzymeModuleFormto 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
EnzymeModuleas a context.Notes
Extends from
MassModel.remove_metabolites().- Parameters
metabolite_list (list) – A list of
MassMetabolites andEnzymeModuleFormto remove from theEnzymeModule.destructive (bool) – If
False, the species are removed from all associatedEnzymeModuleReactions . IfTrue, also remove associatedEnzymeModuleReactions from theEnzymeModule.
- add_reactions(reaction_list)[source]
Add a list of reactions to the
EnzymeModule.MassReactions andEnzymeModuleReactions with identifiers identical to an existing reaction are ignored.The change is reverted upon exit when using the
EnzymeModuleas a context.Notes
Extends from
MassModel.add_reactions().- Parameters
reaction_list (list) – A list of
MassReactionandEnzymeModuleReactionto add.
- remove_reactions(reactions, remove_orphans=False)[source]
Remove reactions from the
EnzymeModule.The change is reverted upon exit when using the
EnzymeModuleas a context.Notes
Extends from
MassModel.remove_reactions().- Parameters
reactions (list) – A list of
MassReactionandEnzymeModuleReactionto remove from theEnzymeModule.remove_orphans (bool) – If
True, will also remove orphaned genes,MassMetabolites, andEnzymeModuleFormfrom 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_reactionsattribute 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
MassMetabolites,MassReactions,Genes,EnzymeModuleForm,EnzymeModuleReactions, andEnzymeModuleDicts, 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
EnzymeModuleinto aMassModel, the enzyme module is converted to anEnzymeModuleDictand stored in aDictListaccessible via theenzyme_modulesattribute. If anEnzymeModuleDictalready exists in the model, it will be replaced.If an
EnzymeModulealready exists in the model, it will be replaced.When merging an
EnzymeModulewith anotherEnzymeModule, a newEnzymeModulewill 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
MassModelthen the first model refers to therightmodel and the second model refers to theleftmodel. Otherwise the first model refers to theleftmodel and the second model refers to therightmodel.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
Truethen 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 aMassModelwith anEnzymeModule,"left"will refer to theMassModel.
- Returns
A new
MassModelorEnzymeModulerepresenting 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_listwill 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
listcontaining the objects to be categorized. Thelistmust contain ONLY one of the followingmassobject types:MassMetabolites representing enzyme ligands.EnzymeModuleForms representing enzymatic forms.EnzymeModuleReactions 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.