Refinement¶
- addCOBRAConstraints(model, idList, d, varargin)¶
Add a constraint to the model in the form c1 * v(id1) + c2 * v(id2) * … cj * v(idj) dsense d where c is a vector with coefficients for each element in idList (default 1 for each reaction), dsense is one of lower than (‘L’, default), greater than (‘G’), or equal (‘E’), and d is a value. USAGE:
model = addCOBRAConstraints(model, idList, d, varargin)
- INPUTS:
model: model structure idList: cell array of ids either from either the rxns, or the
evars vectors. Can also be a a double vector of indices (in which case indices in evars have to be set off by numel(rxns).
- d: The right hand side of the C*v <= d constraint (or a
vector, for multiple simultaneous addition;
- varargin:
- c: the coefficients to use with one entry per
reaction of a constraint for multiple constraints, a matrix (default: 1 for each element indicated in idList)
- dsense: the constraint sense (‘L’: <= ,
‘G’: >=, ‘E’: =), or a vector for multiple constraints (default: (‘L’))
- ConstraintID: the Name of the constraint. by
(default: ‘ConstraintXYZ’ with XYZ being the initial position in the ctrs vector) or a cell array of Strings for multiple Constraints
- checkDuplicates: check whether the constraint already
exists, and if it does, don’t add it (default: false)
- OUTPUT:
- modelConstrained: The constrained model containing the added
- constraints in the respective fields:
.C - The constraint matrix containing coefficients for reactions
.ctrs - The constraint IDs
.dsense - The constraint senses
.d the constraint right hand side values
Optional: D, the matrix conatining coefficients for additional variables.
Example
Add a constraint that leads to EX_glc and EX_fru not carrying a combined flux higher than 5 model = addCOBRAConstraints(model, {‘EX_glc’,’EX_fru’}, 5) Assume Reaction 4 to be 2 A -> D and reaction 5 being A -> F. Create a constraint that requires that the two reactions remove at least 4 units of A: model = addCOBRAConstraints(model, model.rxns(4:5), 4, ‘c’, [2 1], ‘dsense’, ‘G’)
Note
This function will, if not present create the C, ctrs, dsense, d and, if additional variables (i.e. the E matrix) is present, the D field as defined in the model field definitions. The C field containts the constraint coefficients referring to reactions, while the D field contains the Constraint coefficients referring to additional variables. d represents the right hand side of constraints and dsense the sense (lower -‘L’ , equal - ‘E’ or greater than - ‘G’) of the constraint. ctrs stores unique IDs for the constraints.
Author: Thomas Pfau, Nov 2017
- addCOBRAVariables(model, idList, varargin)¶
Add a Variable to the COBRA model provided. These variables can be referred to by additional constraints added via addCOBRAConstraint. Their IDs have to be mutually exclusive with the IDs in model.rxns USAGE:
model = addCOBRAVariables(model, idList, varargin)
- INPUTS:
model: model structure idList: cell array of ids
- varargin:
- lb: The lower bounds of the variables
Has to be of the same size as idlist (default: -1000)
- ub: The upper bounds of the variables.
Has to be of the same size as idlist (default: 1000)
- c: The objective coefficient of the variables
Has to be of the same size as idlist (default: 0)
- Names: Descriptive names of the variables.
(default: idList)
- OUTPUT:
- model: constrained model containing the new variables in the
- respective fields (E,`evars`,`evarub`,`evarlb`,`evarc`)
.E - The coefficient matrix for coefficients of metabolites for the variables
.evars - The variable IDs
.evarlb - The variable lower bounds
.evarub - The variable upper bounds
.evarc - The variable objective coefficient
Optional: D, the matrix conatining coefficients for additional variables.
Note
This function will, if not present create the E, evars, evarlb, evarub, evarc and, if additional Constraints (i.e. the C matrix) is present, the D field as defined in the model field definitions. The E matrix containts the Variable coefficients referring to metabolites, while the D field contains the variable coefficients referring to additional Constraints from C. evars contains the IDs of the additional variables, with one entrey per column of E. evarlb and evarub represent the lower and upper bounds of the variables respectively. evarc are objective coefficients of the variables.
Author: Thomas Pfau, Oct 2018
- addDemandReaction(model, metaboliteNameList, printLevel)¶
Adds demand reactions for a set of metabolites The reaction names for the demand reactions will be DM_[metaboliteName]`
USAGE:
model = addDemandReaction(model, metaboliteNameList)
- INPUTS:
model: COBRA model structure metaboliteNameList: List of metabolite names (cell array) addMissingMetabolites adds missing metabolites to model (default:
true)
- OPTIONAL INPUT:
printLevel: If > 0 will print out the reaction formulas (Default: 1).
- OUTPUTS:
model: COBRA model structure with added demand reactions rxnNames: List of added reactions
- addExchangeRxn(model, metList, lb, ub)¶
Adds exchange reactions
USAGE:
newModel = addExchangeRxn(model, metList, lb, ub)
- INPUTS:
model: Cobra model structure metList: List of metabolites
- OPTIONAL INPUTS:
lb: Array of lower bounds ub: Array of upper bounds
- OUTPUT:
newModel: COBRA model with added exchange reactions
- addGenes(model, geneIDs, varargin)¶
Add Genes (or a single gene) to the model
- USAGE:
model = addGenes(model,geneIDs,varargin)
- INPUT:
model: The model to add the Metabolite batch to. geneIDs: The IDs of the genes that shall be added. varargin: fieldName, Value pairs. The given fields will be set
according to the values. Only defined COBRA fields may be used. The following fields will be ignored (as they are dependent on the existing model structure):
rxnGeneMat - The size will be extended, but no associations will be set.
- OUTPUT:
newmodel: The model structure with the additional reactions.
Example
%To add genes with specific fields use: model = addGenes(model, {‘G1’, ‘Gene2’, ‘InterestingGene’}, ‘proteins’, {‘Protein1’,’Protein B’,’Protein Alpha’}, ‘geneField2’, {‘D’,’E’,’F’})
Note
All fields (geneField1/geneField2) have to be present in the model, or defined in the field definitions, otherwise they are ignored.
- addMIRIAMAnnotations(model, elementIDs, databases, ids, varargin)¶
Add a MIRIAM style annotation to the model
- USAGE:
model = addMIRIAMAnnotation(model, elementID, database, id, …)
- INPUTS:
model: A COBRA Style model struct elementID: The element IDs to annotate (either a single ID as a
char array, or a cell array of model IDs. Must be present in one of the basic fields of the model.
- databases: The databases for which annotations are added. Either a
single char array if it is the same database for all annotated elements, or a cell array of strings with one element for each added element. The databases have to be registered with identifiers.org and must match either the identifiers.org prefix or the exact name!
- ids: The IDs to set for each element. Either a char array if
only a single element is annotated, or a cell array of chars if multiple elements are annotated.
- OPTIONAL INPUTS:
- varargin: Additional parameters either as parameter/value pairs
or as a parameter struct with the following options/fieldnames:
referenceField - the field in which to look up the ids (e.g. rxns, mets, comps etc…) If this is ‘model’, than the annotation will be assumed to be a model annotation, and the ID will be ignored. If empty, the whole model will be checked, and all matching ids will be annotated.
annotationTypes - The type of the annotation. either ‘bio’ or ‘model’. Default(‘bio’)
annotationQualifiers - The qualifier of the annotation ( see http://co.mbine.org/standards/qualifiers ) for possible qualifiers (Default: ‘is’)
replaceAnnotation - Replace existing annotations with those supplied now (Default: false)
printLevel - How much output to produce - 0, silent ; 1, verbose - (Default: 0)
- OUTPUT:
model: The COBRA model with the added annotations
- addMetabolite(model, metID, varargin)¶
Adds a Metabolite to the Current Reconstruction
USAGE:
newModel = addMetabolite(model, metID, metName, formula, ChEBIID, KEGGId, PubChemID, InChi, Charge, b)
- INPUTS:
model: Cobra model structure metID: The ID(s) of the metabolite(s) (will be the identifier in model.mets)
- OPTIONAL INPUTS:
- varargin: Optional Inputs provided as ‘ParameterName’, Value
pairs. the following parameternames are available:
metName: Human readable name(s) (default metID, String)
metFormula: The chemical formula(s) (default ‘’, String)
ChEBIID: The CHEBI Id(s) (default ‘’, String)
KEGGId: The KEGG Compound ID(s) (default ‘’, String)
PubChemID: The PubChemID(s) (default ‘’, String)
InChi: The InChi description(s) (default ‘’, String)
Charge: The Charge(s) (default NaN, int)
b: The accumulation(s) or release(s) (default 0, double)
csense: The sense of this metabolite (default ‘E’, char)
- OUTPUT:
newModel: COBRA model with added metabolite(s)
Examples
1) add a Metabolite which should be accumulated model = addMetabolite(model,’MetToAcc’,’b’,5); 2) Add a Metabolite with a given Formula and a given Charge model = addMetabolite(model,’MetWithForm’,’metFormula’,’H3O’,’metCharge’,1);
Note
metID and all optional arguments either have to be a single value or cell arrays. Charge and b have to be double arrays.
- addMultipleMetabolites(model, metIDs, varargin)¶
Simultaneously add multiple metabolites. Allows the use of the field names of the model struct to specify additional properties of the metabolites added.
USAGE:
newmodel = addMultipleMetabolites(model, metIDs, varargin)
- INPUTS:
model: The model to add the Metabolite batch to. metIDs: The metabolite IDs to add. No duplicate IDs may be provided
and no ID may be present in the supplied model.
- OPTIONAL INPUTS:
- varargin: fieldName, Value pairs with additional properties for the
added metabolites. In addition, a ‘printLevel’ flag can be used (default: 0). The given values fields will be set according to the values. Only fields associated with mets defined in the COBRA definitions (except S) or fields already in the model may be used. Examples for this use would be:
‘metNames’,{‘Glucose’;’Pyruvate’}
‘metCharges’,[0;-2]
OUTPUTS:
newmodel: The model structure with the additional metabolites.
Example
% To add metabolites, with charges, formulas and KEGG ids: model = addMultipleMetabolites(model,{‘A’,’b’,’c’},’metCharges’, [ -1 1 0], ‘metFormulas’, {‘C’,’CO2’,’H2OKOPF’}, ‘metKEGGID’,{‘C000012’,’C000023’,’C000055’})
- addMultipleReactions(model, rxnIDs, metList, Stoichiometries, varargin)¶
Add multiple Reactions to the model. In contrast to addReaction, this function allows the addition of multiple reactions at once but requires all used metabolites to be already present in the model.
USAGE:
newmodel = addMultipleReactions(model,rxnIDs,metList,Stoichiometries,varargin)
- INPUTS:
model: The model to add the Metabolite batch to. rxnIDs: The IDs of the reactions that shall be added (cell Array). metList: A list of metabolites for which stoichiometric coefficients are given Stoichiometries: A Stoichiometric matrix of dimension
numel(metList) x numel(rxnID).
- OPTIONAL INPUTS:
- varargin: fieldName, Value pairs. The given fields will be set
according to the values. Only defined COBRA fields may be used. The following fields will be ignored (as they are dependent on the existing model structure)
S: this is being resolved by the metList/Stoichiometries combination
rxnGeneMat: This depends on the original model structure, and is thus nor considered.
You can provide GPR rules in different ways to this function:
By providing a grRules array in the varargin
By providing a genes field in the varargin and a corresponding rules field
By providing a rules field, that directly refers to the genes in the model.
Examples of parameters are:
‘rxnNames’,{‘RuBisCo’,’Transketloase’}
‘rxnKEGGID,{‘R00024’,’R01641’}
‘lb’,[0,-1000]
or any field name associated with reactions (except for S and rxnGeneMat) as defined in the COBRA Model field definitions.
It is also possible to add a printout to the function by using the ‘printLevel’, 1 argument.
OUTPUTS:
newmodel: The model structure with the additional reactions.
Example
% To add the following reactions, with lower and upper bounds: % ExA: A <-> ; ATob: A <-> B ; BToC: B <-> C model = addMultipleReactions(model, {‘ExA’,’ATob’,’BToC’}, {‘A’,’b’,’c’}, [1 -1 0; 0,1,-1;0,0,1], ‘lb’, [-50,30,1], ‘ub’, [0,60,15]) % To add them with GPRs in text form: % ExA: A <-> ; ATob: A <-> B ; BToC: B <-> C model = addMultipleReactions(model, {‘ExA’,’ATob’,’BToC’}, {‘A’,’b’,’c’}, [1 -1 0; 0,1,-1;0,0,1], ‘grRules’, {‘G1 or G2’, ‘G3 and G4’,’’})
% To add them with the same GPRs in logical format assuming that model.genes is {‘G1’;’G2’;’G3’;’G4’}: % ExA: A <-> ; ATob: A <-> B ; BToC: B <-> C model = addMultipleReactions(model, {‘ExA’,’ATob’,’BToC’}, {‘A’,’b’,’c’}, [1 -1 0; 0,1,-1;0,0,1], ‘rules’, {‘x(1) | x(2)’, ‘x(3) and x(4)’,’’}) % To add them with the same GPRs in logical format without assuming anything for the model: % ExA: A <-> ; ATob: A <-> B ; BToC: B <-> C model = addMultipleReactions(model, {‘ExA’,’ATob’,’BToC’}, {‘A’,’b’,’c’}, [1 -1 0; 0,1,-1;0,0,1], ‘rules’, {‘x(3) | x(2)’, ‘x(4) & x(1)’,’’}, ‘genes’, {‘G4’;’G2’;’G1’;’G3’})
% Print the above: model = addMultipleReactions(model, {‘ExA’,’ATob’,’BToC’}, {‘A’,’b’,’c’}, [1 -1 0; 0,1,-1;0,0,1], ‘printLevel’, 1, ‘rules’, {‘x(3) | x(2)’, ‘x(4) & x(1)’,’’}, ‘genes’, {‘G4’;’G2’;’G1’;’G3’})
- addMultipleReactionsIT(model, rxnIDs, metList, Stoichiometries, varargin)¶
Add multiple Reactions to the model. In contrast to addReaction, this function allows the addition of multiple reactions at once but requires all used metabolites to be already present in the model.
USAGE:
newmodel = addMultipleReactions(model,rxnIDs,metList,Stoichiometries,varargin)
- INPUTS:
model: The model to add the Metabolite batch to. rxnIDs: The IDs of the reactions that shall be added (cell Array). metList: A list of metabolites for which stoichiometric coefficients are given Stoichiometries: A Stoichiometric matrix of dimension
numel(metList) x numel(rxnID).
- OPTIONAL INPUTS:
- varargin: fieldName, Value pairs. The given fields will be set
according to the values. Only defined COBRA fields may be used. The following fields will be ignored (as they are dependent on the existing model structure)
S: this is being resolved by the metList/Stoichiometries combination
rxnGeneMat: This depends on the original model structure, and is thus nor considered.
You can provide GPR rules in different ways to this function:
By providing a grRules array in the varargin
By providing a genes field in the varargin and a corresponding rules field
By providing a rules field, that directly refers to the genes in the model.
Examples of parameters are:
‘rxnNames’,{‘RuBisCo’,’Transketloase’}
‘rxnKEGGID,{‘R00024’,’R01641’}
‘lb’,[0,-1000]
or any field name associated with reactions (except for S and rxnGeneMat) as defined in the COBRA Model field definitions.
It is also possible to add a printout to the function by using the ‘printLevel’, 1 argument.
OUTPUTS:
newmodel: The model structure with the additional reactions.
Example
% To add the following reactions, with lower and upper bounds: % ExA: A <-> ; ATob: A <-> B ; BToC: B <-> C model = addMultipleReactions(model, {‘ExA’,’ATob’,’BToC’}, {‘A’,’b’,’c’}, [1 -1 0; 0,1,-1;0,0,1], ‘lb’, [-50,30,1], ‘ub’, [0,60,15]) % To add them with GPRs in text form: % ExA: A <-> ; ATob: A <-> B ; BToC: B <-> C model = addMultipleReactions(model, {‘ExA’,’ATob’,’BToC’}, {‘A’,’b’,’c’}, [1 -1 0; 0,1,-1;0,0,1], ‘grRules’, {‘G1 or G2’, ‘G3 and G4’,’’})
% To add them with the same GPRs in logical format assuming that model.genes is {‘G1’;’G2’;’G3’;’G4’}: % ExA: A <-> ; ATob: A <-> B ; BToC: B <-> C model = addMultipleReactions(model, {‘ExA’,’ATob’,’BToC’}, {‘A’,’b’,’c’}, [1 -1 0; 0,1,-1;0,0,1], ‘rules’, {‘x(1) | x(2)’, ‘x(3) and x(4)’,’’}) % To add them with the same GPRs in logical format without assuming anything for the model: % ExA: A <-> ; ATob: A <-> B ; BToC: B <-> C model = addMultipleReactions(model, {‘ExA’,’ATob’,’BToC’}, {‘A’,’b’,’c’}, [1 -1 0; 0,1,-1;0,0,1], ‘rules’, {‘x(3) | x(2)’, ‘x(4) & x(1)’,’’}, ‘genes’, {‘G4’;’G2’;’G1’;’G3’})
% Print the above: model = addMultipleReactions(model, {‘ExA’,’ATob’,’BToC’}, {‘A’,’b’,’c’}, [1 -1 0; 0,1,-1;0,0,1], ‘printLevel’, 1, ‘rules’, {‘x(3) | x(2)’, ‘x(4) & x(1)’,’’}, ‘genes’, {‘G4’;’G2’;’G1’;’G3’})
- addReaction(model, rxnID, varargin)¶
Adds a reaction to the model or modify an existing reaction
USAGE:
[model, rxnIDexists] = addReaction(model, rxnID, varargin)
- INPUTS:
model: COBRA model structure rxnID: Reaction name abbreviation (i.e. ‘ACALD’)
- OPTIONAL INPUTS:
varargin: Input of additional information as parameter/Value pairs
reactionName - a Descriptive name of the reaction (default ID)
metaboliteList - Cell array of metabolite names. Either this parameter or reactionFormula are required.
stoichCoeffList - List of stoichiometric coefficients (reactants -ve, products +ve), if not provided, all stoichiometries are assumed to be -1 (Exchange, or consumption).
reactionFormula - A Reaction formula in string format (‘A + B -> C’). If this parameter is provided metaboliteList MUST be empty, and vice versa.
reversible - Reversibility flag (Default = true)
lowerBound - Lower bound (Default = 0 or -vMax`)
upperBound - Upper bound (Default = vMax)
objectiveCoef - Objective coefficient (Default = 0)
subSystem - Subsystem (Default = {‘’})
geneRule - Gene-reaction rule in boolean format (and/or allowed) (Default = ‘’);
geneNameList - List of gene names (used only for translation from common gene names to systematic gene names) (Default empty)
systNameList - List of systematic names (Default empty)
checkDuplicate - Check S matrix too see if a duplicate reaction is already in the model (Deafult false)
printLevel - default = 0
- OUTPUTS:
model: COBRA model structure with new reaction rxnIDexists: Empty if the reaction did not exist previously, or if
checkDuplicate is false. Otherwise it contains the ID of an identical reaction already present in the model.
Examples
%1) Add a new irreversible reaction using the formula approach model = addReaction(model,’newRxn1’,’reactionFormula’,’A -> B + 2 C’) %2) Add a the same reaction using the list approach model = addReaction(model,’newRxn1’,’metaboliteList’,{‘A’,’B’,’C’},’stoichCoeffList’,[-1 1 2], ‘reversible’,false); %3) Add a new irreversible reaction using the formula approach with a given GPR Rule model = addReaction(model,’newRxn1’,’reactionFormula’,’A -> B + 2 C’,…
‘geneRule’, ‘Gene1 or Gene2’);
%4) Add a the same reaction but also mark it as being in the Glycolysis subSystem model = addReaction(model,’newRxn1’,’reactionFormula’,’A -> B + 2 C’, …
‘subSystem’, ‘Glycolysis’, ‘geneRule’, ‘Gene1 or Gene2’);
Note
Using addReaction to add several reactions iteratively is a very inefficient procedure, as it extends all reaction related fields one at a time, leading to a large memory reallocation overhead. There are also many checks performed which allow for a more flexible use of the function, but which simultaneously lead to a slower computation time. This function is mainly intended to be used when adding individual reactions during analysis. When adding multiple reactions, in particular when coding for a more compex methodology, please use the addMultipleReactions function which only performs very basic checks, but is much more efficient.
- addReactionGEM(model, rxns, rxnNames, rxnFormulas, rev, lb, ub, nRxn, subSystems, grRules, rules, genes, HTABLE)¶
Manually adds reactions to a specified model, may add one or more reactions at a time
USAGE:
[newmodel, HTABLE] = addReactionGEM(model, rxns, rxnNames, rxnFormulas, rev, lb, ub, nRxn, subSystems, grRules, rules, genes, HTABLE)
- INPUTS:
model: COBRA model structure rxns: Identifiers for the reactions rxnNames: List of reactions rxnFormulas: reactions’ formulas rev: 0 = irrev, 1 = rev lb: The lower bounds for fluxes ub: The upper bounds for fluxes subSystems: subSystem assignment for each reaction, default = ‘’ grRules: A string representation of the GPR rules defined in a readable format, default = ‘’ rules: GPR rules in evaluateable format for each reaction, default = ‘’ genes: Identifiers of the genes in the model, default = ‘’ HTABLE: hash table
- OUTPUTS:
newmodel: changed model HTABLE: hash table
Example
[modelLB_NH3] = addReactionSmiley(modelLB, ‘NH3r’, ‘NH3 protonization’, cellstr(‘1 NH3[c] + 1 H[c] <==> 1 NH4[c]’), 1, -1000, 1000, ‘Others’);
Note
Manually add reactions to a specified model, can either add one or multiple reactions at a time
All syntax standards must comply with the specified model
For reaction formulas, use: ‘–>’ for irreversible or ‘<==>’ for reversible
- addSinkReactions(model, metabolites, lb, ub)¶
Adds a sink reaction for the list of metabolites
USAGE:
[model] = addSinkReactions(model, metabolites, lb, ub)
- INPUTS:
model: COBRA model structure metabolites: Cell array of metabolite abreviations as they appear in model.mets
- OPTIONAL INPUTS:
lb: Lower bounds of reactions ub: Upper bounds of reactions
- OUTPUTS:
model: COBRA model structure containing sink reactions rxnsInModel: Vector, contains -1 if the reaction did not exist
previously, otherwise it contains the reaction ID of an identical reaction already present in the model
- addSubSystemsToReactions(model, reactions, subSystems)¶
Adds the subSystems to the specified reactions
USAGE:
[model] = addSubSystemToReaction(model,reaction,subSystem)
- INPUT:
- model: A COBRA model struct with at least rxns and
subSystems fields
- reactions: Either a string identifying a reaction, or a
cell array of strings identifying multiple reactions, or a double vector or boolean vector identifying positions.
- subSystems: A String identifying a subsystem, or a cell
array of strings to add multiple subSystems. An empty string will be filtered. All subSystems will be added to all identified reactions.
- OUTPUT:
- model: The model with the subSystems added to the
respective reactions (old, non empty, values are retained).
Example
% Add TCA to a set of reactions [model] = addSubSystemsToReactions(model,{‘ACONTa’;’ACONTb’;’AKGDH’;’CS’;’FUM’;’ICDHyr’;’MDH’;’SUCOAS’},’TCA’) % Add Glycolysis/Gluconeogenesis to a the reaction 18 of the model [model] = addSubSystemsToReactions(model,18,{‘Glycolysis’,’Gluconeogenesis’})
- alphabetizeModel(model)¶
Sorts the rxns, metabolites, and genes in a model into alphabetical order, useful after adding new reactions to a model. This function needs to be modified to work on models with different fields than these (currently set for iAF1260c)
USAGE:
abcModel = alphabetizeModel(model)
- INPUT:
model: COBRA model structure
- OUTPUT:
abcModel: the alphabetized model
- annotateSBOTerms(model)¶
Add SBO terms to model entities
INPUT model model structure
OUTPUT model updated model structure
Ines Thiele June 2022
- assignGPRA(model, gpraFile)¶
Assigns each reaction a Gene-protein-reaction association
USAGE:
model = assignGPRA(model, gpraFile)
- INPUTS:
model: COBRA model structure gpraFile: SimPheny GPRA file
- OUTPUT:
model: COBRA model with gene-protein-reaction assoction
- assignSubSystems(model, gpraFile)¶
Assigns each reaction a subsystem in the model structure
USAGE:
model = assignSubSystems(model, gpraFile)
- INPUTS:
model: COBRA model structure gpraFile: SimPheny GPRA file
- OUTPUT:
model: COBRA model structure with subsystem assignment
- changeCOBRAConstraints(model, constraintID, varargin)¶
Modify an existing COBRA constraint by providing new settings for the constraint to update existing settings. USAGE:
model = changeCOBRAConstraints(model, constraintID, varargin)
- INPUTS:
model: model structure constraintID: The ID of the constraint (or the index in the
ctrs field)
- OPTIONAL INPUTS:
- varargin: all elements (name, d, dsense and c can be modified as indicated below.
idList: cell array of ids either from either the rxns, or the evars vectors. Can also be a a double vector of indices (in which case indices in evars have to be set off by numel(rxns).
c: the elements of the C matrix. If idList is empty, this has to be a vector of length #rxns + #evars
dsense: the constraint sense (‘L’: <= ,’G’: >=, ‘E’: =), or a vector for multiple constraints
d: The right hand side of the C*v <= d constraint (or a vector, for multiple simultaneous addition)
name: The new, descriptive name of the constraint.
- OUTPUT:
model: constrained model
Example
Modify the constraint ‘A_and_B_Lower_10’ to read A + B + C <= 10 model = addCOBRAConstraints(model, ‘A_and_B_Lower_10’, ‘idList’, {‘A’,’B’,’C’}, ‘c’, [1,1,1]);
Note
If c is provided, the whole constraint coefficients will be reset and existing coefficients will be removed!
Author: Thomas Pfau, Oct 2018
- changeCOBRAVariable(model, variableID, varargin)¶
Modify an existing COBRA variable by providing new settings for the variable to update existing settings. USAGE:
model = changeCOBRAVariable(model, variableID, varargin)
- INPUTS:
model: model structure variableID: The ID of the variable (or the index in the
evars field)
- OPTIONAL INPUTS:
- varargin:
lb: the lower bound of the variable
ub: the upper bound of the variable
c: the objective coefficient of the variable
Name: The new, descriptive name of the variable.
- OUTPUT:
model: model with modified variable
Author: Thomas Pfau, Oct 2018
- changeGeneAssociation(model, rxnName, grRule, geneNameList, systNameList, addRxnGeneMat)¶
Change gene associations in a model
USAGE:
model = changeGeneAssociation(model, rxnName, grRule, geneNameList, systNameList, addRxnGeneMat)
- INPUTS:
model: COBRA Toolbox model structure rxnName: Name of the new reaction grRule: Gene-reaction rule in boolean format (and/or allowed)
- OPTIONAL INPUTS:
- geneNameList: List of gene names (used only for translation from
common gene names to systematic gene names)
systNameList: List of systematic names addRxnGeneMat: adds rxnGeneMat to model structure (default = true)
- OUTPUT:
model: COBRA Toolbox model structure with new gene reaction associations
- changeRxnMets(model, Mets2change, NewMets, Rxn, NewStoich)¶
Changes metabolites in a specified reaction, or randomly chosen reactions.
USAGE:
[model ModifiedRxns] = changeRxnMets(model, Mets2change, NewMets, Rxn, NewStoich)
- INPUTS:
model: COBRA model structure Mets2change: Cell array of metabolites to change NewMets: Cell array of replacement metabolites (must be in
order of those that will be replaced
- Rxn: reaction to change (string) or cell array, or if a number is put
here, that number of reactions (with Mets2change) will be randomly chosen and the metabolites will be swapped
- OPTIONAL INPUT:
- NewStoich: Stoichiometry of new metabs (conserved from old mets by default).
If multiple reactions are being changed, this must be a mets x rxns matrix,
e.g. for 2 new reactions: Rxn = {‘r1’, ‘r2’},
r1: 2 A + 3 B -> 1 C
r2: 4 A + 3 B -> 3 C
where A and C are the new metabolites, NewMets = {‘A’, ‘C’} NewStoich = [ 2 4; 1 3]
- OUTPUTS:
model: COBRA model structure with changed reaction ModifiedRxns: Rxns which were modified
- checkIDsForTypeExist(model, ids, basefield)¶
Check whether the given IDs exist for the given type of base field. Base fields include rxns, mets, genes, comps, proteins, ctrs, evars. ctrs/mets as well as rxns/evars will be considered as a combined field.
USAGE:
[bool,existing] = checkIDsForTypeExist(model,ids,basefield)
- INPUTS:
model: model structure ids: cell array of identifiers basefield: Any base field defined.
- OUTPUT:
bool: Boolean vector true if any of the IDs exist. existing: Unique set of pre-existing IDs for this base field.
Example
[bool,existing] = checkIDsForTypeExist(model,’atp[c]’,’mets’)
- convertIrrevFluxDistribution(vIrrev, matchRev)¶
Converts irreversible flux distribution to reversible
USAGE:
vRev = covertIrrevFluxDistribution(vIrrev, matchRev)
- INPUTS:
vIrrev: Irreversible flux distribution matchRev: Vector mapping irreversible fluxes to reversible fluxes
(Generated by convertToIrreversible)
- OUTPUT:
vRev: Reversible flux distribution
- convertToIrreversible(model, varargin)¶
Converts model to irreversible format, either for the entire model or for a defined list of reversible reactions.
- USAGE:
[modelIrrev, matchRev, rev2irrev, irrev2rev] = convertToIrreversible(model, varargin)
- INPUT:
model: COBRA model structure
- OPTIONAL INPUTS:
- varargin: Additional Options as ParameterName/Value pairs.
Allowed Parameters are:
sRxns: List of specific reversible reactions to convert to irreversible (Default = model.rxns)
flipOrientation: Alter reactions that can only carry negative flux by flipping and marking them with ‘_r’ (Default = true)
orderReactions: Order Reactions such that reverse reactions directly follow their forward reaction.
- OUTPUTS:
modelIrrev: Model in irreversible format matchRev: Matching of forward and backward reactions of a reversible reaction rev2irrev: Matching from reversible to irreversible reactions irrev2rev: Matching from irreversible to reversible reactions
Example
% To convert a whole model to an irreversible model: [modelIrrev, matchRev, rev2irrev, irrev2rev] = convertToIrreversible(model)
% To Convert only Reactions R1, R2 and R15: reactionsToRevert = {‘R1’, ‘R2’, ‘R15’}; [modelIrrev, matchRev, rev2irrev, irrev2rev] = convertToIrreversible(model, ‘sRxns’, reactionsToRevert)
% To order the reactions such that backward follows forward reaction: [modelIrrev, matchRev, rev2irrev, irrev2rev] = convertToIrreversible(model, ‘orderReactions’, true)
Note
Uses the reversible list to construct a new model with reversible reactions separated into forward and backward reactions. Separated reactions are appended with ‘_f’ and ‘_b’ and the reversible list tracks these changes with a ‘1’ corresponding to separated forward reactions. Reactions entirely in the negative direction will be reversed and appended with ‘_r’.
- convertToReversible(model)¶
Converts a model structure from irreversible format to reversible format
USAGE:
modelRev = convertToReversible(model)
- INPUT:
- model: COBRA model in irreversible format (forward/backward reactions separated)
forward reactions have to be marked with an _f in the id, backward with an _b. reverse reactions (i.e. reactions which were originally only allowed to carry negative flux must have a _r tag at the end of the reaction id. It is further assumed, that there is an exact 1:1 match between _f and _b reactions.
- OUTPUT:
modelRev: Model in reversible format
- createModel(varargin)¶
Create a COBRA model from inputs or an empty model structure if no inputs are provided.
USAGE:
model = createModel(rxnAbrList, rxnNameList, rxnList, revFlagList, lowerBoundList, upperBoundList, subSystemList, grRuleList, geneNameList, systNameList)
- INPUTS:
rxnAbrList: List of names of the new reactions rxnNameList: List of descriptive names of the new reactions rxnList: List of reactions: format: {A -> B + 2 C}
If the compartment of a metabolite is not specified, it is assumed to be cytoplasmic, i.e. [c]
- OPTIONAL INPUTS:
revFlagList: List of reversibility flag (opt, default = 1) lowerBoundList: List of lower bound (Default = 0 or -vMax) upperBoundList: List of upper bound (Default = vMax) subSystemList: List of subsystem (Default = {‘’}) grRuleList: List of gene-reaction rule in boolean format (and/or allowed)
(Default = ‘’);
- geneNameList: List of gene names (used only for translation
from common gene names to systematic gene names)
systNameList: List of systematic names printLevel: Verbosity (0 - no outputs, except warnings, 1- normal printout (default))
- OUTPUT:
model: COBRA model structure
Examples
1) Create A model with two Reactions (R1 : ‘A -> B + C’, R2: ‘C -> D’) model = createModel({‘R1’,’R2’},{‘Reaction 1’,’Reaction 2’},{‘A -> B + C’, ‘C -> D’}); 2) Also set the subSystems of the two Reactions (R1: Sub1, R2: Sub2): model = createModel({‘R1’,’R2’},{‘Reaction 1’,’Reaction 2’},{‘A -> B + C’, ‘C -> D’},… ‘subSystemList’, {‘Sub1’,’Sub2’}); 3) Also set upper and lower bounds: model = createModel({‘R1’,’R2’},{‘Reaction 1’,’Reaction 2’},{‘A -> B + C’, ‘C -> D’},… ‘subSystemList’, {‘Sub1’,’Sub2’}, ‘lowerBoundList’,[-3 -1000],’upperBoundList’,[120 17]);
- createXMatrix(compoundsIn, transport, compartment)¶
Creates a matrix full of exchange reactions based on the input list (creates an exchange reaction for each of the metabolites present in the model)
USAGE:
ExchangeRxnMatrix = createXMatrix(compoundsIn, transport, compartment)
- INPUTS:
compoundsIn: SU matrix transport: if 1, transport reactions will be defined as well for
every compound (default: 0, which corresponds to only exchange reactions (from the specified compartment)
- compartment: (default = ‘[c]’) –> transport from cytoplasm [c] to
extracellular space [e] (or sink) any other compartment (except ‘[e]’ creates transport from [c] to the compartment, from the compartment to the external compartment and an exchanger in the external compartment.
- OUTPUT:
- ExchangeRxnMatrix: model containing all exchange reactions for all
compounds in compoundsIn
- dispStoichAsTable(model, printLevel)¶
display stoichiometric matrix as a table
- INPUT
model
- OUTPUT
Table
- extendModelFieldsForType(model, type, varargin)¶
Extend all existing fields relevant for the given type to the size of the field of the given type, or a specified size. USAGE:
model = extendModelFieldsForType(model, type, varargin)
INPUTS:
model: the model to update type: the Type of field to update one of
(‘rxns’,’mets’,’comps’,’genes’,’evars’,’ctrs’)
- OPTIONAL INPUTS:
varargin: Additional Options as ‘ParameterName’, Value pairs. Options are:
‘originalSize’, the original size of the field, this is used to determine fields which have to be adjusted (default length of field type - 1).
‘targetSize’, the target size to which the field should be extended. Default values will be used as defined in the ModelFieldDefinitions to fill empty entries (default length of field type).
‘excludeFields’, fields that should be ignored during update.
OUTPUT:
- model: A model with the requested fields associated to the
given type updated. Associated fields are determined by size, and if multiple base fields have the same size, the Model Field definition along with checks for field Names (e.g. rxnXYZ is associated with rxns) is used. Added values are either default values (if defined in the ModelFieldDefinitions), or {‘’} for cell arrays, NaN for numeric arrays and false for logical arrays. Char Arrays will be ignored.
- extractCompModel(model, compSymbol, intOnlyFlag, updateGenes)¶
Creates model for a cellular compartment
USAGE:
compModel = extractCompModel(model, compSymbol, intOnlyFlag)
- INPUTS:
model: COBRA model structure compSymbol: Compartment symbol
- OPTIONAL INPUT:
intOnlyFlag: Include only non-transport reactions (Default = true) updateGenes: Update the GPR rules removing all unassociated genes.
This can take some time on larger models.(default false)
- OUTPUT:
compModel: COBRA model for a cellular compartment
- extractMetModel(model, metabNames, nLayers, allCompFlag, nRxnsMetThr)¶
Creates a subnetwork model around one or more metabolites
USAGE:
metabModel = extractMetModel(model, metabNames, nLayers, allCompFlag, nRxnsMetThr)
- INPUTS:
model: COBRA model structure metabNames: Metabolites to build subnetwork model around nLayers: Number of layers allCompFlag: Use all metabolites regardless of compartment
- OPTIONAL INPUT:
nRxnsMetThr: Ignore metabolites which appear in more than nRxnMetThr (Default = 100)
- OUTPUT:
metabModel: COBRA model around one or more metabolites
- extractSubNetwork(model, rxnList, metList, updateGenes)¶
Extract subnetwork model USAGE:
subModel = extractSubNetwork(model, rxnList, metList)
- INPUTS:
model: COBRA model structure rxnList: Reaction list for the subnetwork to be extracted
- OPTIONAL INPUTS:
metNames: Metabolite list for the subnetwork to be extracted updateGenes: Also remove unused genes (can take some time on large
networks)
- OUTPUT:
subModel: COBRA model of subnetwork
- extractSubSysModel(model, subSysNames)¶
Creates model for one of more model subsystems
USAGE:
subSysModel = extractSubSysModel(model, subSysNames)
- INPUTS:
model: COBRA model structure subSysNames: List of subsystems to extract
- OUTPUT:
subSysModel: COBRA model of selected subsystems
- flipRxnOrientation(model, rxnList)¶
flips the directionality of the given reactions and adjusts the bounds and objective coefficients accordingly.
USAGE:
model = flipRxnDirectionality(model, rxnList)
INPUTS:
model: A COBRA Style model structure rxnList: A List of reactions or a single reaction
OUTPUTS:
model: The model with the specified reactions flipped.
- generateRules(model, printLevel)¶
If a model does not have a model.rules field but has a model.grRules field, can be regenerated using this script
USAGE:
[model] = generateRules(model)
- INPUT:
model: COBRA model with model.grRules printLevel: optional variable to print out all new genes
(default = TRUE), can be zero if not needed
- OUTPUT:
model: same model but with model.rules added
- getEmptyConstraints(model)¶
Get a list of empty constraints (i.e. constraints that have no non-zero values. USAGE:
emptyConstraints = getEmptyConstraints(model)
- INPUTS:
model: model structure
- OUTPUT:
emptyConstraints: A list of IDs of empty constraints.
- Author:
Thomas Pfau - Sep 2018
- getIDPositions(model, ids, basefield)¶
Get the positions of the IDs for the given basefield. This function will currently only work for rxns and mets and also checks the associated ctrs (for mets) and evars (for rxns) fields for the given IDs. elements from evars / ctrs will have positions nRxns/nMets + position respectively.
USAGE:
[pos,pres] = getIDPositions(model,ids,basefield)
- INPUTS:
model: model structure ids: cell array of reaction names basefield: Either ‘rxns’, or ‘mets’
- OUTPUT:
- pos: The positions of the given ids in the
[rxns;evars] or [mets;ctrs] vectors for rxns and mets , respectively.
- getMetAbbr(mets)¶
Gets the abbreviation for each metabolite, and the unique abbreviations, from metabolite abbreviation(s), each of which must have compartment symbol concatentated on the right hand side (i.e. metAbbr[*]).
USAGE:
[metAbbr, uniqueMetAbbrs] = getMetComp(mets)
- INPUT:
- metAbbr: char array with a single metabolite abbreviation
or m x 1 cell array of metabolite abbreviations
- OUTPUTS:
- compartments: char array with a single compartment identifier
or m x 1 cell array of compartment identifiers
- uniqueCompartments: char array with a single compartment identifier
or cell array of unique compartment identifiers
- getModelFieldsForType(model, type, varargin)¶
Get the fields in the model which are associated with the given type. USAGE:
matchingFields = getModelFieldsForType(model, type, varargin)
INPUTS:
model: the model to update type: the Type of field to update one of
(‘rxns’,’mets’,’comps’,’genes’,’ctrs’,’evars’,’rxnName’,’specName’)
- OPTIONAL INPUTS:
varargin: Additional Options as ‘ParameterName’, Value pairs. Options are:
‘fieldSize’, the original size of the field (if mets was already adjusted, this size will be used to determine matching fields.
OUTPUT:
- matchingfields: A cell array of fields associated with the
given type. The initial check is for the size of the field, if multiple base fields have the same size, it is assumed, that fields named e.g. rxnXYZ are associated with rxns, and only those fields are adapted along with fields which are specified in the Model FieldDefinitions.
- dimensions: The dimension associated with the given type in the
given field. matchingField(X) is matching to type in dimenion(X)
- isSameCobraModel(model1, model2, printLevel)¶
Checks if two COBRA models are the same
USAGE:
[isSame, nDiff, commonFields] = isSameCobraModel(model1, model2, printLevel)
- INPUTS:
model1: COBRA model structure 1 model2: COBRA model structure 2
- OPTIONAL INPUTS:
printLevel: Whether to provide additional output (0 - no output (default), 1 - output).
- OUTPUTS:
isSame: True if all common fields are identical, else false nDiff: Number of differences between the two models for each field commonFields: List of common fields
- keepCompartment(model, compartments)¶
This function removes reactions in all compartments except those specified by the cell array “compartments”
USAGE:
model = keepCompartment(model, compartments)
- INPUTS:
model: COBRA model structure compartments: cell array of strings (e.g., to discard all
reactions except those in the mitochondria and cytosol, compartments = {‘[m]’, ‘[c]’};
- OUTPUT:
model: COBRA model with reactions in the specified compartmetns
- mergeModelFieldPositions(model, type, positions, mergeFunctions)¶
- USAGE:
[modelNew] = mergeModelFieldPositions(model,type,positions)
- INPUTS:
model: The model with the fields to merge type: the field type to merge ( rxns, mets, comps or genes) positions: The positions in the given field type to merge either as indices or as logical array.
- OPTIONAL INPUTS:
- mergeFunctions: A cell array of fieldNames and functions that can be
called on a larger array of the type used for the field. e.g.
{‘metCharges’,@(x) x(1); ‘grRules’, @(x) strjoin(x,’ or ‘);
by default, all numeric fields are added up, all unique entries in cell arrays are concatenated with ‘;’,
grRules and rules are assumed to be merged with and (i.e. a batch reaction is assumed to need all associated GPRs)
OUTPUT:
- modelNew: merged model with the positions merged into one.
Unique entries in Related String fields will be concatenated with ‘;’ matrices will be summed up.
- mergeTwoModels(model1, model2, objrxnmodel, mergeGenes, rmDuplRxns)¶
Merge two models. If fields conflict, the data from fields in model1 will be used. USAGE:
[modelNew] = mergeTwoModels(model1,model2,objrxnmodel, mergeGenes, rmDuplRxns)
INPUTS:
model1: model 1 model2: model 2
- OPTIONAL INPUTS:
- objrxnmodel: Set as 1 or 2 to set objective reaction from
desired model
- mergeGenes: Do merge the gene associated data, if false the genes
field and the rules field will be cleared and other fields associated with genes will not be merged. GPR rules can be reconstructed using the grRules field.(Default = true)
- rmDuplRxns: Boolean indicating whether duplicate reactions should
be removed (default=true)
OUTPUT:
modelNew: merged model
- moveRxn(model, startspot, endspot)¶
The function moves a reaction from one spot in the network to another, useful for placing important reactions at the beginning of the network to easier follow certain reactions.
USAGE:
[model] = moveRxn(model, startspot, endspot)
- INPUTS:
model: COBRA model structure startspot: The reaction number to move endspot: The spot where the reaction is moving to
- OUTPUTS:
model: COBRA toolbox model structure with moved reaction
- orderModelFields(model)¶
Orders the fields in a model according to the field definitions. Defined first, Remaining fields in alphabetical order.
USAGE:
orderedModel = orderModelFields(model)
- INPUT:
model: a model structure in COBRA format
- OUTPUT:
orderedModel: a model with fields ordered according to the field definitions.
- reassignFwBwMatch(match, selVec)¶
Reassings forward-backward matches when modifying an irreversible model
USAGE:
matchNew = reassignFwBwMatch(match, selVec)
- INPUTS:
match: Forward-backwards mapping vector selVec: Selection vector marking reactions to remap
- OUTPUT:
matchNew: Modified forward-backwards mapping vector
- reduceModel(model, tol, irrevFlag, verbFlag, negFluxAllowedFlag, checkConsistencyFlag, changeBoundsFlag)¶
Removes from the model all of the reactions that are never used (max and min are < tol). Finds the minimal bounds for the flux through each reaction. Also returns the results for flux variability analysis (maxes, mins).
USAGE
[modelRed, hasFlux, maxes, mins] = reduceModel(model, tol, irrevFlag, verbFlag, negFluxAllowedFlag, checkConsistencyFlag, changeBoundsFlag)
- INPUT:
model: COBRA model structure
- OPTIONAL INPUTS:
- tol: Tolerance for non-zero bounds - bounds smaller in absolute
value than this value will be set to zero (Default = 1e-6)
- irrevFlag: Determines if the models should be treated using
the irreversible form. (Default = false)
verbFlag: Verbose output (Default = false) negFluxAllowedFlag: Allow negative fluxes through irrev reactions
(Default = false)
- checkConsistencyFlag: Do a consistency check of the optimal solution
(Default = true)
- changeBoundsFlag: Change upper/lower bounds to the minimal bounds
(Default = true)
- OUTPUTS:
modelRed: Reduced model hasFlux: The indexes of the reactions that are not blocked
in the model
maxes: Maximum fluxes mins: Minimum fluxes
- removeCOBRAConstraints(model, constraintsToRemove)¶
Remove the specified Non Metabolic Constraints. USAGE:
model = removeCOBRAConstraint(model, constraintsToRemove)
- INPUTS:
model: model structure constraintsToRemove: cell array of Constraint IDs, or Constraint
Positions to remove, or a boolean vector of positions to remove.
- OUTPUT:
model: the model with the constraints removed.
- Author:
Thomas Pfau - Nov 2017
- removeFieldEntriesForType(model, indicesToRemove, type, fieldSize, varargin)¶
Remove field entries at the specified indices from all fields associated with the given type USAGE:
model = removeFieldEntriesForType(model, indicesToRemove, type, varargin)
- INPUTS:
model: the model to update indicesToRemove: indices which should be removed (either a logical array or double indices) type: the Type of field to update. one of
(‘rxns’,’mets’,’comps’,’genes’,’ctrs’,’evars’,’rxnName’,’specName’,’molAlias’)
- fieldSize: The size of the original field before
modification. This is necessary to identify fields from which entries have to be removed.
- OPTIONAL INPUTS:
- varargin: Additional Options as ‘ParameterName’, Value pairs. Options are:
‘excludeFields’, fields which should not be adjusted but kept how they are.
- OUTPUT:
- modelNew: the model in which all fields associated with the
given type have the entries indicated removed. The initial check is for the size of the field, if multiple base fields have the same size, it is assumed, that fields named e.g. rxnXYZ are associated with rxns, and only those fields are adapted along with fields which are specified in the Model FieldDefinitions.
- removeGenesFromModel(model, geneList, varargin)¶
Removes the given genes from the model. GPR rules will be adjusted to reflect the removal. By default, the rules are converted to DNF and all clauses containing any of the given genes are removed. Note, that this function is not supposed to be used to model single gene deletions. Instead, use deleteModelGenes.m for that.
USAGE:
[model, affectedRxns, originalGPRs, deletedReactions] = removeGenesFromModel(model, geneList)
- INPUT:
- model: COBRA model with the appropriate constrains for a
particular condition
- geneList: List of genes to be deleted as cell array, or a
single gene as char
- OPTIONAL INPUTS:
- varargin: Additional Parameter/value pairs or a parameter
- struct with the following parameter names:
keepReactions - Whether to keep reactions if its GPR is hanged to an empty GPR, i.e. all complexes catalyzing it are removed. (default: true)
keepClauses - Do not remove clauses containing the gene, but instead just remove the gene from the clause (default: false).
- OUTPUTS:
model: COBRA model with the selected genes deleted affectedRxns: A list of reactions which have their rules altered originalGPRs: The original GPR rules for the affected reactions
in grRules format.
- deletedReactions: The list of reactions removed from the model (if
keepReaction was false).
- removeMetabolites(model, metRemoveList, removeRxnFlag, rxnRemoveMethod)¶
Removes metabolites from a model
USAGE:
[model, rxnRemoveList] = removeMetabolites(model, metRemoveList, removeRxnFlag)
- INPUTS:
model: COBRA model structure metRemoveList: List of metabolites to be removed
- OPTIONAL INPUT:
removeRxnFlag: Remove reactions with no metabolites (Default = true) rxnRemoveMethod: {(‘inclusive’),’exclusive’,’legacy’}, to remove reactions in a
stoichiometrically consistent manner, or possibly not consistently if either of the last options are chosen.
- OUTPUT:
model: COBRA model with removed metabolites
- removeRxns(model, rxnRemoveList, varargin)¶
Removes reactions from a model
USAGE:
model = removeRxns(model, rxnRemoveList, varargin)
- INPUTS:
model: COBRA model structure rxnRemoveList: Cell array of reaction abbreviations to be removed
- OPTIONAL INPUTS:
- varargin: Parameters in ParameterName, Value pair representation.
Available parameters are: * metRemoveMethod
‘exclusive’ = remove metabolites exclusively involved in removed reactions (default) ‘inclusive’ = remove any metabolite involved in one or more removed reactions (can cause stoichiometric inconsistency)
ctrsRemoveMethod ‘exclusive’ = only remove constraints exclusively involved in removed reactions (default) ‘inclusive’ = any constraint involved in a removed reaction is to be removed ‘infeasible’ = if a removed reaction involves any constraint then remove that constraint, unless the constraint is still feasible. ‘legacy’ = remove empty constraints, it seems equivalent to ‘exclusive’, but kept for completeness
irrevFlag: Irreverseble (true) or reversible (false) reaction format (Default = false)
metFlag: Remove unused metabolites (Default = true)
- OUTPUT:
model: COBRA model w/o selected reactions metRemoveList: Cell array of metabolite abbreviations that were removed ctrsRemoveList: Cell array of model.ctrs that were removed
Alternatively, if model.ctrs did not exist, then a boolean vector displaying the rows of C*v <=d that were removed.
Optional inputs are used as parameter value pairs
Examples
1) Remove the reactions ‘ATPM’ and ‘TKT1’ from the given model model = removeRxns(model,{‘ATPM’,’TKT1’}); 2) Remove the same reactions but keep any metabolites which would now be not present in any reaction: model = removeRxns(model,{‘ATPM’,’TKT1’}, ‘metFlag’, false);
- removeSubSystemsFromRxns(model, reactions, subSystems)¶
Adds the subSystem to the specified reaction
USAGE:
[model] = addSubSystemToReaction(model,reaction,subSystem)
- INPUT:
- model: A COBRA model struct with at least rxns and
subSystems fields
- reactions: Either a string identifying a reaction, or a
cell array of strings identifying multiple reactions, or a double vector or boolean vector identifying positions.
- subSystems: A String identifying a subsystem, or a cell
array of strings to assign multiple subSystems. If multiple strings are present, an empty string will be removed
- OUTPUT:
- model: The model with the subSystems set to the
respective reactions (old values will be removed).
Example
%Remove TCA as subSystem from a set of reactions [model] = removeSubSystemsFromRxns(model,{‘ACONTa’;’ACONTb’;’AKGDH’;’CS’;’FUM’;’ICDHyr’;’MDH’;’SUCOAS’},’TCA’) %Remove Glycolysis/Gluconeogenesis from reaction 18 of the model [model] = removeSubSystemsFromRxns(model,18,{‘Glycolysis’,’Gluconeogenesis’})
- removeTrivialStoichiometry(model)¶
Removes metabolites and reactions corresponding to zero rows and columns
USAGE:
modelOut=removeTrivialStoichiometry(model)
- INPUT:
model: Model with metabolites and reactions to remove
- OUTPUT:
modelOut: Obtained model with removed metabolites and reactions
- removeUnusedGenes(model)¶
Updates the rules, genes, and rxnGeneMat fields based on the grRules field for reactions in the model.
USAGE:
modelNew = removeUnusedGenes(model)
- INPUTS:
model: COBRA structure
- OUTPUT:
- modelNew: COBRA model structure with updated gene field reflecting only
content present in the model
- setRxnSubSystems(model, reactions, subSystems)¶
Sets the subSystems of the specified reactions to the specified subSystems
USAGE:
[model] = addSubSystemToReaction(model,reaction,subSystem)
- INPUT:
- model: A COBRA model struct with at least rxns and
subSystems fields
- reactions: Either a string identifying a reaction, or a
cell array of strings identifying multiple reactions, or a double vector or boolean vector identifying positions.
- subSystems: A String identifying a subsystem, or a cell
array of strings to assign multiple subSystems. If multiple strings are present, an empty string will be removed
- OUTPUT:
- model: The model with the subSystems set to the
respective reactions (old values will be removed).
Example
% Set TCA as subSystem for a set of reactions [model] = setRxnSubSystems(model, {‘ACONTa’;’ACONTb’;’AKGDH’;’CS’;’FUM’;’ICDHyr’;’MDH’;’SUCOAS’}, ‘TCA’) % Set Glycolysis/Gluconeogenesis to reaction 18 of the model [model] = setRxnSubSystems(model, 18, {‘Glycolysis’,’Gluconeogenesis’})
- updateFieldOrderForType(model, type, newOrder)¶
Reorder the fields associated with the provided type to the new order. USAGE:
matchingFields = updateFieldOrderForType(model, type, newOrder)
INPUTS:
model: the model to update type: the Type of field to update one of
(‘rxns’,’mets’,’comps’,’genes’)
- newOrder: The new Order. must be of the same size as the
requested model.(type) field.
OUTPUT:
- model: The model with all field associated with type
reordered
- updateGenes(model)¶
Update the model genes field (if it does not exist, generate it from the grRules field, if it exists, remove Unused genes and remove duplicate genes.
USAGE:
[modelNew] = updateGenes(model);
- INPUT:
model: COBRA model structure
- OUTPUT:
modelNew: COBRA model structure with corrected genes
Note
The gene order will be changed to sorted. You should probably use buildRxnGeneMat to make sure the order matches in all relevant fields.
- updateMetNames(referenceModel, modelToUpdate, wipeExisting)¶
Updates model.metNames in a new model, using metNames of a reference model.
USAGE:
[updatedModel] = updateMetNames(referenceModel, modelToUpdate, wipeExisting);
- INPUTS:
referenceModel: COBRA model structure with correct model.metNames modelToUpdate: COBRA model structure that needs to have its
model.metNames updated
- OPTIONAL INPUTS:
- wipeExisting: true: remove all existing model.metNames in
modelToUpdate, especially when model.metNames is wrong.
- OUTPUT:
updatedModel: COBRA model structure with corrected metNames