cobrapy_io

Cobrapy I/O function overrides and enhancements.

This module patches cobra I/O functions to fix bugs and add missing features for handling model serialisation (MATLAB, JSON formats).

Key enhancements: - Load/save MATLAB models with better error handling - Handle NaN and Na values during JSON serialisation - Support rxnECNumber field from MATLAB structs - Handle geneShortNames field as fallback - Load subsystems correctly from MATLAB arrays

Changes made: - 2025-01-22: Initial wrapper around load_mat; EC number support - 2025-02-11: Fixed subsystem loading from MATLAB arrays - 2025-06-20: Consolidated and documented all I/O fixes

Author: Jelle Bonthuis (MaCSBio)

Functions

from_mat_struct(mat_struct[, model_id, inf])

Convert MATLAB struct to cobra Model object.

load_matlab_model(infile_path[, ...])

Load cobrapy Model from MATLAB .mat file with error handling.

model_from_dict(obj)

Construct cobra Model from dictionary (inverse of model_to_dict).

model_to_dict(model[, sort])

Convert cobra Model to OrderedDict suitable for JSON serialisation.

save_json_model(model, filename[, sort, ...])

Serialise cobra Model to JSON file with NaN/Inf/int64 handling.