Model
Here the metabolic model class is defined, along with Metabolite, Reaction, and Compartment. Also a reaction string parser is defined.
Model
This module defines base classes for metabolic modeling. Adapted from https://github.com/cdanielmachado/framed
Author: Daniel Machado
- class set_up_grasp_models.model.model.AttrOrderedDict(*args, **nargs)
- class set_up_grasp_models.model.model.Compartment(elem_id, name=None, size=1.0)
Base class for modeling compartments.
- class set_up_grasp_models.model.model.Metabolite(elem_id, name=None, compartment=None, boundary=False, constant=False)
Base class for modeling metabolites.
- class set_up_grasp_models.model.model.Model(model_id)
Base class for all metabolic models implemented as a bipartite network. Contains the list of metabolites, reactions, compartments, and stoichiometry.
- add_compartment(compartment)
Add a single compartment to the model. If a compartment with the same id exists, it will be replaced.
- Parameters
compartment (Compartment) – compartment to add
- add_metabolite(metabolite, clear_tmp=True)
Add a single metabolite to the model. If a metabolite with the same id exists, it will be replaced. If the metabolite compartment is defined, then it must exist in the model.
- Parameters
metabolite (Metabolite) – metabolite to add
- add_reaction(reaction, clear_tmp=True)
Add a single reaction to the model. If a reaction with the same id exists, it will be replaced.
- Parameters
reaction (Reaction) – reaction to add
- add_reaction_from_str(reaction_str, default_compartment=None, clear_tmp=True)
Parse a reaction from a string and add it to the model.
- Parameters
reaction_str (str) – string representation a the reaction
default_compartment (str) – default compartment id (optional)
Notes
If the metabolites specified in the reaction are not yet in the model, they will be automatically added. You can specify the compartment for new metabolites using the optional argument. However, if you want to use multiple compartments you will have to change them manually afterwards.
- get_boundary_metabolites()
Get list of boundary metabolites in this model
- Returns
boundary metabolites
- Return type
list
- get_exchange_reactions(include_sink=False)
Get list of exchange reactions
- Parameters
include_sink – Include sink reactions in the list
Returns: list
- get_metabolite_consumers(m_id, reversible=False)
Return the list of reactions consuming a given metabolite
- Parameters
m_id (str) – metabolite id
reversible (bool) – also include reversible producers
- Returns
consuming reactions
- Return type
list
- get_metabolite_producers(m_id, reversible=False)
Return the list of reactions producing a given metabolite
- Parameters
m_id (str) – metabolite id
reversible (bool) – also include reversible consumers
- Returns
producing reactions
- Return type
list
- get_metabolite_reactions(m_id)
Return the list of reactions associated with a given metabolite
- Parameters
m_id (str) – metabolite id
- Returns
associated reactions
- Return type
list
- get_metabolites_by_compartment(c_id)
Get list of metabolites in a given compartment.
- Parameters
c_id (str) – compartment id
- Returns
metabolites in given compartment
- Return type
list
- get_sink_reactions()
Get list of sink reactions
Returns: list
- metabolite_reaction_lookup(force_recalculate=False)
Return the network topology as a nested map from metabolite to reaction to coefficient
- Returns
lookup table
- Return type
dict
- print_reaction(r_id, use_metabolite_names=False)
Print a reaction to a text based representation.
- Parameters
r_id (str) – reaction id
use_metabolite_names (bool) – print metabolite names instead of ids (default: False)
- Returns
reaction string
- Return type
str
- remove_compartment(c_id, delete_metabolites=True, delete_reactions=False)
Remove a compartment from the model.
- Parameters
c_id (str) – compartment id
delete_metabolites (bool) – delete metabolites inside this compartment (default: True)
delete_reactions (bool) – delete reactions that occur (totally or partially) in this compartment (default: False)
- remove_compartments(c_ids, delete_metabolites=True, delete_reactions=False)
Remove a compartment from the model.
- Parameters
c_ids (list) – compartment ids
delete_metabolites (bool) – delete metabolites inside this compartment (default: True)
delete_reactions (bool) – delete reactions that occur (totally or partially) in this compartment (default: False)
- remove_metabolite(m_id)
Remove a single metabolite from the model.
- Parameters
m_id (str) – metabolite id
- remove_metabolites(id_list, safe_delete=True)
Remove a list of metabolites from the model.
- Parameters
id_list (list) – metabolite ids
safe_delete (bool) – also remove from reactions (default: True)
- remove_reaction(r_id)
Remove a single reaction from the model.
- Parameters
r_id (str) – reaction id
- remove_reactions(id_list)
Remove a list of reactions from the model.
- Parameters
id_list (list of str) – reaction ids
- stoichiometric_matrix()
Return a stoichiometric matrix (as a list of lists)
- Returns
stoichiometric matrix
- Return type
list
- to_string(use_metabolite_names=False)
Print the model to a text based representation.
- Parameters
use_metabolite_names (bool) – print metabolite names instead of ids (default: False)
- Returns
model as a string
- Return type
str
- class set_up_grasp_models.model.model.Reaction(elem_id, name=None, reversible=True, stoichiometry=None, regulators=None, is_exchange=None, is_sink=None)
Base class for modeling reactions.
- get_activators()
Get list of reaction activators
- Returns
reaction activators
- Return type
list
- get_inhibitors()
Get list of reaction inhibitors
- Returns
reaction inhibitors
- Return type
list
- get_products()
Get list of reaction products
- Returns
reaction products
- Return type
list
- get_substrates()
Get list of reaction substrates
- Returns
reaction substrates
- Return type
list
- to_equation_string(metabolite_names=None)
Returns reaction equation string
- Parameters
metabolite_names (dict) – replace metabolite id’s with names (optional)
- Returns
reaction string
- Return type
str
- to_string(metabolite_names=None)
Returns reaction as a string
- Parameters
metabolite_names (dict) – replace metabolite id’s with names (optional)
- Returns
reaction string
- Return type
str
Parser
This module parses reaction strings. Adapted from https://github.com/cdanielmachado/framed
Author: Daniel Machado