17.1.1.3.1.1. cobra.io.dict

17.1.1.3.1.1.1. Module Contents

17.1.1.3.1.1.1.1. Functions

_fix_type(value)

convert possible types to str, float, and bool

_update_optional(cobra_object, new_dict, optional_attribute_dict, ordered_keys)

update new_dict with optional attributes from cobra_object

metabolite_to_dict(metabolite)

metabolite_from_dict(metabolite)

gene_to_dict(gene)

gene_from_dict(gene)

reaction_to_dict(reaction)

reaction_from_dict(reaction, model)

model_to_dict(model, sort=False)

Convert model to a dict.

model_from_dict(obj)

Build a model from a dict.

cobra.io.dict._REQUIRED_REACTION_ATTRIBUTES = ['id', 'name', 'metabolites', 'lower_bound', 'upper_bound', 'gene_reaction_rule'][source]
cobra.io.dict._ORDERED_OPTIONAL_REACTION_KEYS = ['objective_coefficient', 'subsystem', 'notes', 'annotation'][source]
cobra.io.dict._OPTIONAL_REACTION_ATTRIBUTES[source]
cobra.io.dict._REQUIRED_METABOLITE_ATTRIBUTES = ['id', 'name', 'compartment'][source]
cobra.io.dict._ORDERED_OPTIONAL_METABOLITE_KEYS = ['charge', 'formula', '_bound', 'notes', 'annotation'][source]
cobra.io.dict._OPTIONAL_METABOLITE_ATTRIBUTES[source]
cobra.io.dict._REQUIRED_GENE_ATTRIBUTES = ['id', 'name'][source]
cobra.io.dict._ORDERED_OPTIONAL_GENE_KEYS = ['notes', 'annotation'][source]
cobra.io.dict._OPTIONAL_GENE_ATTRIBUTES[source]
cobra.io.dict._ORDERED_OPTIONAL_MODEL_KEYS = ['name', 'compartments', 'notes', 'annotation'][source]
cobra.io.dict._OPTIONAL_MODEL_ATTRIBUTES[source]
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

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