17.1.1.3.2.5. cobra.io.yaml

17.1.1.3.2.5.1. Module Contents

17.1.1.3.2.5.1.1. Classes

MyYAML

17.1.1.3.2.5.1.2. Functions

to_yaml(model, sort=False, **kwargs)

Return the model as a YAML document.

from_yaml(document)

Load a cobra model from a YAML document.

save_yaml_model(model, filename, sort=False, **kwargs)

Write the cobra model to a file in YAML format.

load_yaml_model(filename)

Load a cobra model from a file in YAML format.

cobra.io.yaml.YAML_SPEC = 1.2[source]
class cobra.io.yaml.MyYAML(: Any, _kw: Optional[Text] = enforce, typ: Any = None, pure: Any = False, output: Any = None, plug_ins=None)[source]

Bases: ruamel.yaml.main.YAML

dump(self, data, stream=None, **kwargs)[source]
cobra.io.yaml.yaml[source]
cobra.io.yaml.to_yaml(model, sort=False, **kwargs)[source]

Return the model as a YAML document.

kwargs are passed on to yaml.dump.

Parameters
  • model (cobra.Model) – The cobra model to represent.

  • sort (bool, optional) – Whether to sort the metabolites, reactions, and genes or maintain the order defined in the model.

Returns

String representation of the cobra model as a YAML document.

Return type

str

See also

save_yaml_model()

Write directly to a file.

ruamel.yaml.dump()

Base function.

cobra.io.yaml.from_yaml(document)[source]

Load a cobra model from a YAML document.

Parameters

document (str) – The YAML document representation of a cobra model.

Returns

The cobra model as represented in the YAML document.

Return type

cobra.Model

See also

load_yaml_model()

Load directly from a file.

cobra.io.yaml.save_yaml_model(model, filename, sort=False, **kwargs)[source]

Write the cobra model to a file in YAML format.

kwargs are passed on to yaml.dump.

Parameters
  • model (cobra.Model) – The cobra model to represent.

  • filename (str or file-like) – File path or descriptor that the YAML representation should be written to.

  • sort (bool, optional) – Whether to sort the metabolites, reactions, and genes or maintain the order defined in the model.

See also

to_yaml()

Return a string representation.

ruamel.yaml.dump()

Base function.

cobra.io.yaml.load_yaml_model(filename)[source]

Load a cobra model from a file in YAML format.

Parameters

filename (str or file-like) – File path or descriptor that contains the YAML document describing the cobra model.

Returns

The cobra model as represented in the YAML document.

Return type

cobra.Model

See also

from_yaml()

Load from a string.