15.1.1.3.1.1. cobra.io.dict

15.1.1.3.1.1.1. Module Contents

cobra.io.dict._fix_type(value)[source]

convert possible types to str, float, and bool

cobra.io.dict._update_optional(cobra_object, new_dict, optional_attribute_dict, ordered_keys)[source]

update new_dict with optional attributes from cobra_object

cobra.io.dict.metabolite_to_dict(metabolite)[source]
cobra.io.dict.metabolite_from_dict(metabolite)[source]
cobra.io.dict.gene_to_dict(gene)[source]
cobra.io.dict.gene_from_dict(gene)[source]
cobra.io.dict.reaction_to_dict(reaction)[source]
cobra.io.dict.reaction_from_dict(reaction, model)[source]
cobra.io.dict.model_to_dict(model, sort=False)[source]

Convert model to a dict.

Parameters:
  • model (cobra.Model) – The model to reformulate as a dict.
  • sort (bool, optional) – Whether to sort the metabolites, reactions, and genes or maintain the order defined in the model.
Returns:

A dictionary with elements, ‘genes’, ‘compartments’, ‘id’, ‘metabolites’, ‘notes’ and ‘reactions’; where ‘metabolites’, ‘genes’ and ‘metabolites’ are in turn lists with dictionaries holding all attributes to form the corresponding object.

Return type:

OrderedDict

See also

cobra.io.model_from_dict()

cobra.io.dict.model_from_dict(obj)[source]

Build a model from a dict.

Models stored in json are first formulated as a dict that can be read to cobra model using this function.

Parameters:obj (dict) – A dictionary with elements, ‘genes’, ‘compartments’, ‘id’, ‘metabolites’, ‘notes’ and ‘reactions’; where ‘metabolites’, ‘genes’ and ‘metabolites’ are in turn lists with dictionaries holding all attributes to form the corresponding object.
Returns:The generated model.
Return type:cora.core.Model

See also

cobra.io.model_to_dict()