mass.io.dict

Module to convert or create mass objects into or from dictionaries.

Converting objects into dictionaries allow for the exportation of MassModels in various formats. These formats include:

  • JSON format using the functions in json.

Module Contents

Functions

model_to_dict(model[, sort])

Convert a MassModel into a serializable dictionary.

model_from_dict(obj)

Create a MassModel from a dictionary.

metabolite_to_dict(metabolite)

Convert a MassMetabolite into a serializable dictionary.

metabolite_from_dict(metabolite)

Create a MassMetabolite from a dictionary.

reaction_to_dict(reaction)

Convert a MassReaction into a serializable dictionary.

reaction_from_dict(reaction, model)

Create a MassReaction from a dictionary.

enzyme_to_dict(enzyme)

Convert an EnzymeModuleDict into a serializable dictionary.

enzyme_from_dict(enzyme, model)

Create an EnzymeModuleDict from a dictionary.

unit_to_dict(unit_definition)

Convert an UnitDefintion into a serializable dictionary.

unit_from_dict(unit_definition)

Create an UnitDefintion from a dictionary.

mass.io.dict.model_to_dict(model, sort=False)[source]

Convert a MassModel into a serializable dictionary.

Parameters
Returns

A dictionary with elements corresponding to the model attributes as which are in turn lists containing dictionaries holding all attribute information to form the corresponding object.

Return type

OrderedDict

See also

model_from_dict

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

Create a MassModel from a dictionary.

Notes

The enzyme_module_ligands, enzyme_module_forms, and enzyme_module_reactions attributes are used to determine whether the model should be initialized as an EnzymeModule or as a MassModel. At least one of these three attributes must be present in order for an EnzymeModule to be created.

Parameters

obj (dict) – A dictionary with elements corresponding to the model attributes as which are in turn lists containing dictionaries holding all attribute information to form the corresponding object.

Returns

The generated model or enzyme module.

Return type

MassModel or EnzymeModule

See also

model_to_dict

mass.io.dict.metabolite_to_dict(metabolite)[source]

Convert a MassMetabolite into a serializable dictionary.

Parameters

metabolite (MassMetabolite) – The metabolite to represent as a dictionary.

Returns

A dictionary with elements corresponding to metabolite attributes.

Return type

OrderedDict

mass.io.dict.metabolite_from_dict(metabolite)[source]

Create a MassMetabolite from a dictionary.

Notes

The presence of the enzyme_module_id attribute is used to determine whether the dictionary should be initialized as an EnzymeModuleForm or as a MassMetabolite.

Parameters

metabolite (dict) – A dictionary with elements corresponding to the metabolite attributes.

Returns

The generated metabolite.

Return type

MassMetabolite or EnzymeModuleForm

mass.io.dict.reaction_to_dict(reaction)[source]

Convert a MassReaction into a serializable dictionary.

Parameters

reaction (MassReaction) – The reaction to represent as a dictionary.

Returns

A dictionary with elements corresponding to reaction attributes.

Return type

OrderedDict

mass.io.dict.reaction_from_dict(reaction, model)[source]

Create a MassReaction from a dictionary.

Notes

The presence of the EnzymeModuleReaction.enzyme_module_id attribute is used to determine whether the dictionary should be initialized as an EnzymeModuleReaction or as a MassReaction.

Parameters
  • reaction (dict) – A dictionary with elements corresponding to the reaction attributes.

  • model (MassModel) – The model to assoicate with the reaction.

Returns

The generated reaction.

Return type

MassReaction or EnzymeModuleReaction

See also

reaction_to_dict

mass.io.dict.enzyme_to_dict(enzyme)[source]

Convert an EnzymeModuleDict into a serializable dictionary.

Parameters

enzyme (EnzymeModuleDict) – The enzyme module to represent as a dictionary.

Returns

A dictionary with elements corresponding to the enzyme module attributes.

Return type

OrderedDict

See also

enzyme_from_dict

mass.io.dict.enzyme_from_dict(enzyme, model)[source]

Create an EnzymeModuleDict from a dictionary.

Parameters
  • enzyme (dict) – A dictionary with elements corresponding to the enzyme module dictionary attributes.

  • model (MassModel) – The model to assoicate with the enzyme module dictionary.

Returns

The generated enzyme module dictionary.

Return type

EnzymeModuleDict

See also

enzyme_to_dict

mass.io.dict.unit_to_dict(unit_definition)[source]

Convert an UnitDefintion into a serializable dictionary.

Parameters

unit_definition (UnitDefintion) – The unit definition to represent as a dictionary.

Returns

A dictionary with elements corresponding to the unit definition attributes.

Return type

OrderedDict

See also

unit_from_dict

mass.io.dict.unit_from_dict(unit_definition)[source]

Create an UnitDefintion from a dictionary.

Parameters

unit_definition (dict) – A dictionary with elements corresponding to the unit definition attributes.

Returns

The generated unit definition.

Return type

UnitDefintion

See also

unit_to_dict