14.1.4. cobra.io package¶
14.1.4.1. Submodules¶
14.1.4.2. cobra.io.json module¶
-
cobra.io.json.
load_json_model
(file_name)[source]¶ Load a cobra model stored as a json file
file_name : str or file-like object
14.1.4.3. cobra.io.mat module¶
-
cobra.io.mat.
from_mat_struct
(mat_struct, model_id=None)[source]¶ create a model from the COBRA toolbox struct
The struct will be a dict read in by scipy.io.loadmat
-
cobra.io.mat.
load_matlab_model
(infile_path, variable_name=None)[source]¶ Load a cobra model stored as a .mat file
infile_path : str
- 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
-
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
- 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.
14.1.4.4. cobra.io.sbml module¶
-
cobra.io.sbml.
add_sbml_species
(sbml_model, cobra_metabolite, note_start_tag, note_end_tag, boundary_metabolite=False)[source]¶ A helper function for adding cobra metabolites to an sbml model.
sbml_model: sbml_model object
cobra_metabolite: a cobra.Metabolite object
note_start_tag: the start tag for parsing cobra notes. this will eventually be supplanted when COBRA is worked into sbml.
note_end_tag: the end tag for parsing cobra notes. this will eventually be supplanted when COBRA is worked into sbml.
-
cobra.io.sbml.
create_cobra_model_from_sbml_file
(sbml_filename, old_sbml=False, legacy_metabolite=False, print_time=False, use_hyphens=False)[source]¶ convert an SBML XML file into a cobra.Model object. Supports SBML Level 2 Versions 1 and 4. The function will detect if the SBML fbc package is used in the file and run the converter if the fbc package is used.
sbml_filename: String.
old_sbml: Boolean. Set to True if the XML file has metabolite formula appended to metabolite names. This was a poorly designed artifact that persists in some models.
legacy_metabolite: Boolean. If True then assume that the metabolite id has the compartment id appended after an underscore (e.g. _c for cytosol). This has not been implemented but will be soon.
print_time: deprecated
use_hyphens: Boolean. If True, double underscores (__) in an SBML ID will be converted to hyphens
-
cobra.io.sbml.
get_libsbml_document
(cobra_model, sbml_level=2, sbml_version=1, print_time=False, use_fbc_package=True)[source]¶ Return a libsbml document object for writing to a file. This function is used by write_cobra_model_to_sbml_file().
-
cobra.io.sbml.
parse_legacy_id
(the_id, the_compartment=None, the_type='metabolite', use_hyphens=False)[source]¶ Deals with a bunch of problems due to bigg.ucsd.edu not following SBML standards
the_id: String.
the_compartment: String.
the_type: String. Currently only ‘metabolite’ is supported
use_hyphens: Boolean. If True, double underscores (__) in an SBML ID will be converted to hyphens
-
cobra.io.sbml.
parse_legacy_sbml_notes
(note_string, note_delimiter=':')[source]¶ Deal with legacy SBML format issues arising from the COBRA Toolbox for MATLAB and BiGG.ucsd.edu developers.
-
cobra.io.sbml.
read_legacy_sbml
(filename, use_hyphens=False)[source]¶ read in an sbml file and fix the sbml id’s
-
cobra.io.sbml.
write_cobra_model_to_sbml_file
(cobra_model, sbml_filename, sbml_level=2, sbml_version=1, print_time=False, use_fbc_package=True)[source]¶ Write a cobra.Model object to an SBML XML file.
cobra_model:
Model
objectsbml_filename: The file to write the SBML XML to.
sbml_level: 2 is the only level supported at the moment.
sbml_version: 1 is the only version supported at the moment.
- use_fbc_package: Boolean.
- Convert the model to the FBC package format to improve portability. http://sbml.org/Documents/Specifications/SBML_Level_3/Packages/Flux_Balance_Constraints_(flux)
TODO: Update the NOTES to match the SBML standard and provide support for Level 2 Version 4
14.1.4.5. cobra.io.sbml3 module¶
-
cobra.io.sbml3.
clip
(string, prefix)[source]¶ clips a prefix from the beginning of a string if it exists
>>> clip("R_pgi", "R_") "pgi"