15.1.1.3.1.3. cobra.io.mat

15.1.1.3.1.3.1. Module Contents

cobra.io.mat._get_id_compartment(id)[source]

extract the compartment from the id string

cobra.io.mat._cell(x)[source]

translate an array x into a MATLAB cell array

cobra.io.mat.load_matlab_model(infile_path, variable_name=None, inf=inf)[source]

Load a cobra model stored as a .mat file

Parameters:
  • infile_path (str) – path to the file to to read
  • variable_name (str, optional) – The variable name of the model in the .mat file. If this is not specified, then the first MATLAB variable which looks like a COBRA model will be used
  • inf (value) – The value to use for infinite bounds. Some solvers do not handle infinite values so for using those, set this to a high numeric value.
Returns:

The resulting cobra model

Return type:

cobra.core.Model.Model

cobra.io.mat.save_matlab_model(model, file_name, varname=None)[source]

Save the cobra model as a .mat file.

This .mat file can be used directly in the MATLAB version of COBRA.

Parameters:
  • model (cobra.core.Model.Model object) – The model to save
  • file_name (str or file-like object) – The file to save to
  • varname (string) – The name of the variable within the workspace
cobra.io.mat.create_mat_metabolite_id(model)[source]
cobra.io.mat.create_mat_dict(model)[source]

create a dict mapping model attributes to arrays

cobra.io.mat.from_mat_struct(mat_struct, model_id=None, inf=inf)[source]

create a model from the COBRA toolbox struct

The struct will be a dict read in by scipy.io.loadmat

cobra.io.mat._check(result)[source]

ensure success of a pymatbridge operation

cobra.io.mat.model_to_pymatbridge(model, variable_name="model", matlab=None)[source]

send the model to a MATLAB workspace through pymatbridge

This model can then be manipulated through the COBRA toolbox

Parameters:
  • variable_name (str) – The variable name to which the model will be assigned in the MATLAB workspace
  • matlab (None or pymatbridge.Matlab instance) – The MATLAB workspace to which the variable will be sent. If this is None, then this will be sent to the same environment used in IPython magics.