Format conversion#

MATLAB functions in RAVEN/src/conversion of the RAVEN toolbox.

Functions#

Function

Summary

addIdentifierPrefix

Add identifier prefixes required by SBML.

ravenCobraWrapper

Convert between RAVEN and COBRA structures.

removeIdentifierPrefix

Remove SBML-required identifier prefixes.

standardizeModelFieldOrder

Order RAVEN model structure fields.

Reference#

addIdentifierPrefix#

function [model, hasChanged]=addIdentifierPrefix(model,varargin)

Add identifier prefixes required by SBML.

If any reaction, metabolite, compartment, gene or model identifier does not start with a letter or _, which conflicts with SBML specifications, a prefix is added to all identifiers in the respective model field. The prefixes are:

"R_" for model.rxns,
"M_" for model.mets and model.id,
"C_" for model.comps;
"G_" for model.genes (and also represented in model.grRules)

Parameters

model : struct

model whose identifiers should be modified.

Name-Value Arguments

fields : cell

cell array with the names of the model fields to check for the need of a prefix, possible values: 'rxns', 'mets', 'comps', 'genes', 'id' (default all of these fields).

Returns

model : struct

modified model.

hasChanged : cell

cell array of char with one entry per field that received a prefix, for example 'model.rxns (R_ prefix)'.

Examples

[model, hasChanged] = addIdentifierPrefix(model, fields);

ravenCobraWrapper#

function newModel=ravenCobraWrapper(model)

Convert between RAVEN and COBRA structures.

A structure with the field 'rules' is treated as a COBRA Toolbox structure and converted to RAVEN; a structure without it is treated as a RAVEN structure and converted to COBRA. If a COBRA structure also has a grRules field, that field is used and rules is not parsed.

Parameters

model : struct

a RAVEN or COBRA model structure.

Returns

newModel : struct

the model structure in the other format: COBRA for a RAVEN input and RAVEN for a COBRA input.

Examples

newModel = ravenCobraWrapper(model);

Notes

During the RAVEN -> COBRA -> RAVEN conversion cycle the following fields are lost: annotation, compOutside, compMiriams, rxnComps, geneComps, unconstrained. Boundary metabolites are lost, because the COBRA structure has no boundary metabolites, and are removed using simplifyModel before the RAVEN -> COBRA conversion. The field 'rev' is also partially lost; during the COBRA -> RAVEN conversion it is reconstructed from the lower bounds (a reaction is reversible if its lower bound is below zero).

During the COBRA -> RAVEN -> COBRA conversion cycle the following fields are lost: geneEntrezID, modelVersion, proteins.

The information about mandatory RAVEN fields was taken from the checkModelStruct function, whereas the corresponding information about COBRA fields was taken from the verifyModel function.

removeIdentifierPrefix#

function [model, hasChanged]=removeIdentifierPrefix(model,varargin)

Remove SBML-required identifier prefixes.

Removes identifier prefixes:

"R_" for model.rxns and model.rxnNames,
"M_" for model.mets, model.metNames and model.id,
"C_" for model.comps;
"G_" for model.genes (and also represented in model.grRules).

By default, the prefixes are only removed if all entries in a particular field have the prefix. The prefixes are required when one or more identifiers do not start with a letter or _, which conflicts with SBML specifications.

Parameters

model : struct

model whose identifiers should be modified.

Name-Value Arguments

fields : cell

cell array with the names of the model fields from which the prefix is removed, possible values: 'rxns', 'mets', 'comps', 'genes', 'metNames', 'rxnNames', 'id' (default all of these fields).

forceRemove : logical

true to remove the prefix from the entries that have it when not all entries in a model field have the prefix (default false).

Returns

model : struct

modified model.

hasChanged : cell

cell array of char with one entry per field from which a prefix is removed, for example 'model.rxns (R_ prefix)'.

Examples

model = removeIdentifierPrefix(model, fields, forceRemove);

standardizeModelFieldOrder#

function orderedModel=standardizeModelFieldOrder(model)

Order RAVEN model structure fields.

Orders the fields of a RAVEN or COBRA model structure. The RAVEN order is the one listed in orderRavenFields.csv, described at https://raven-docs.readthedocs.io/en/latest/guide/model-structure.html A structure with the field 'rules' is ordered as a COBRA structure, using COBRA_structure_fields.csv. Fields that are not listed in the file are placed last, in alphabetical order.

The content of the fields is unchanged. To convert model fields between RAVEN and COBRA format, use ravenCobraWrapper().

Parameters

model : struct

model structure, either RAVEN or COBRA format.

Returns

orderedModel : struct

model structure with ordered fields.

Examples

orderedModel = standardizeModelFieldOrder(model);

See also

ravenCobraWrapper