17.1.1.3.1.2. cobra.io.json
¶
17.1.1.3.1.2.1. Module Contents¶
17.1.1.3.1.2.1.1. Functions¶
|
Return the model as a JSON document. |
|
Load a cobra model from a JSON document. |
|
Write the cobra model to a file in JSON format. |
|
Load a cobra model from a file in JSON format. |
-
cobra.io.json.
to_json
(model, sort=False, **kwargs)[source]¶ Return the model as a JSON document.
kwargs
are passed on tojson.dumps
.- 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 JSON document.
- Return type
See also
save_json_model()
Write directly to a file.
json.dumps()
Base function.
-
cobra.io.json.
from_json
(document)[source]¶ Load a cobra model from a JSON document.
- Parameters
document (str) – The JSON document representation of a cobra model.
- Returns
The cobra model as represented in the JSON document.
- Return type
See also
load_json_model()
Load directly from a file.
-
cobra.io.json.
save_json_model
(model, filename, sort=False, pretty=False, **kwargs)[source]¶ Write the cobra model to a file in JSON format.
kwargs
are passed on tojson.dump
.- Parameters
model (cobra.Model) – The cobra model to represent.
filename (str or file-like) – File path or descriptor that the JSON representation should be written to.
sort (bool, optional) – Whether to sort the metabolites, reactions, and genes or maintain the order defined in the model.
pretty (bool, optional) – Whether to format the JSON more compactly (default) or in a more verbose but easier to read fashion. Can be partially overwritten by the
kwargs
.
See also
to_json()
Return a string representation.
json.dump()
Base function.
-
cobra.io.json.
load_json_model
(filename)[source]¶ Load a cobra model from a file in JSON format.
- Parameters
filename (str or file-like) – File path or descriptor that contains the JSON document describing the cobra model.
- Returns
The cobra model as represented in the JSON document.
- Return type
See also
from_json()
Load from a string.