medusa.core
¶
Package Contents¶
-
class
medusa.core.
Ensemble
(list_of_models=[], identifier=None, name=None)¶ Bases:
cobra.core.object.Object
Ensemble of metabolic models
Parameters: - identifier (string) – The identifier to associate with the ensemble as a string.
- list_of_models (list of cobra.core.model.Model) – Either a list of existing Model objects in which case a new Model object is instantiated and an ensemble is constructed using the list of Models, or None/empty list, in which case an ensemble is created with empty attributes.
- name (string) – Human-readable name for the ensemble
-
base_model
¶ A cobra.core.Model that contains all variable and invariable components of an ensemble.
Type: Model
-
members
¶ A DictList where the key is the member identifier and the value is a medusa.core.member.Member object
Type: DictList
-
features
¶ A DictList where the key is the feature identifier and the value is a medusa.core.feature.Feature object
Type: DictList
-
_populate_features_base
(self, list_of_models)¶
-
_populate_members
(self, list_of_models)¶
-
set_state
(self, member)¶ Set the state of the base model to represent a single member.
Sets all features to the state for the provided member. Only reaction states are currently implemented (e.g. GPRs as features will not work)
Parameters: member (str or medusa.Member) – The Member.id, or the Member object itself, to set the state of the Ensemble.base_model to represent.
-
to_pickle
(self, filename)¶ Save an ensemble as a pickled object. Pickling is currently the only supported method for saving and loading ensembles.
Parameters: filename (String) – location to save the pickle.
-
extract_member
(self, member)¶ Extract an individual member as a cobrapy model (cobra.Model), removing any components associated with features that are inactive in member.
Provided as a more convenient option than medusa.Member.to_model(), but is the exact same.
Parameters: member (str or medusa.Member) – The Member.id, or the Member object itself, to be represented in the cobrapy model output. Returns: model – The extracted member as a cobrapy model. Return type: cobra.Model
-
class
medusa.core.
Feature
(identifier=None, name=None, ensemble=None, base_component=None, component_attribute=None, states=None)¶ Bases:
cobra.core.object.Object
Feature describing a network component that varies across an ensemble.
Parameters: - identifier (string) – The identifier to associate with the feature. Convention is to append the component_attribute to the base_component’s id.
- ensemble (medusa.core.ensemble.Ensemble object) – The ensemble that the feature is associated with.
- base_component (cobra.core.reaction.Reaction) – Reference to the Reaction object that the feature describes.
- component_attribute (string) – string indicating the attribute of base_component that the feature describes the modification of (e.g. “lb”, “ub”)
- states (dictionary of string:component_attribute value) – dictionary of model ids mapping to the value of the Feature’s component_attribute (value type depends on component_attribute type, e.g. float for “lb”, string for “_gene_reaction_rule”)
-
get_model_state
(self, member_id)¶ Get the state of the feature for a particular member
-
class
medusa.core.
Member
(ensemble=None, identifier=None, name=None, states=None)¶ Bases:
cobra.core.object.Object
Object representing an individual member (i.e. model) in an ensemble
Parameters: - identifier (string) – The identifier to associate with the member.
- ensemble (medusa.core.ensemble.Ensemble object) – The ensemble that the member belongs to.
- states (dictionary of medusa.core.feature.Feature:component_attribute value) – dictionary of Features mapping to the value of the Feature’s component_attribute (value type depends on component_attribute type, e.g. float for “lb”, string for “_gene_reaction_rule”) for the member.
-
to_model
(self)¶ Generate a cobra.Model object with the exact state of this member.
The resulting cobra.Model does not contain any Metabolites, Genes, or Reactions that were inactive in the member.
Returns: model – The extracted member as a cobrapy model. Return type: cobra.Model
-
_set_id_with_model
(self, value)¶