Home > core > changeGrRules.m

changeGrRules

PURPOSE ^

changeGrRules

SYNOPSIS ^

function model = changeGrRules(model,rxns,grRules,replace)

DESCRIPTION ^

 changeGrRules
   Changes multiple grRules at the same time.

   model       a model structure to change the gene association
   rxns        string or cell array of reaction IDs
   grRules     string of additional or replacement gene association.
               Should be written with ' and ' to indicate subunits, ' or '
               to indicate isoenzymes, and brackets '()' to separate
               different instances
   replace     true if old gene association should be replaced with new
               association. False if new gene association should be
               concatenated to the old association (optional, default true)

   model       an updated model structure

 Usage: changeGrRules(model,rxns,grRules,replace)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function model = changeGrRules(model,rxns,grRules,replace)
0002 % changeGrRules
0003 %   Changes multiple grRules at the same time.
0004 %
0005 %   model       a model structure to change the gene association
0006 %   rxns        string or cell array of reaction IDs
0007 %   grRules     string of additional or replacement gene association.
0008 %               Should be written with ' and ' to indicate subunits, ' or '
0009 %               to indicate isoenzymes, and brackets '()' to separate
0010 %               different instances
0011 %   replace     true if old gene association should be replaced with new
0012 %               association. False if new gene association should be
0013 %               concatenated to the old association (optional, default true)
0014 %
0015 %   model       an updated model structure
0016 %
0017 % Usage: changeGrRules(model,rxns,grRules,replace)
0018 
0019 if nargin==3
0020     replace=true;
0021 end
0022 
0023 rxns=convertCharArray(rxns);
0024 grRules=convertCharArray(grRules);
0025 
0026 if isscalar(grRules) && ~isscalar(rxns)
0027     grRules = repmat(grRules,1,numel(rxns));
0028 end
0029 if ~(numel(grRules)==numel(rxns))
0030     error('Number of rxns and grRules should be identical')
0031 end
0032 
0033 % Add genes to model
0034 geneList = getGenesFromGrRules(grRules);
0035 genesToAdd.genes=setdiff(geneList,model.genes); % Only keep the genes that are not yet part of the model.genes.
0036 if ~isempty(genesToAdd.genes)
0037     model=addGenesRaven(model,genesToAdd); % Add genes
0038 end
0039     
0040 % Find reaction and gene indices
0041 idx=getIndexes(model,rxns,'rxns');
0042 
0043 % Change gene associations
0044 if replace==true % Replace old gene associations
0045     model.grRules(idx)=grRules;
0046 else % Add gene associations, add new gene rules after 'OR'.
0047     model.grRules(idx)=strcat('(',model.grRules(idx),') or (',grRules,')');
0048 end
0049 
0050 %Fix grRules and reconstruct rxnGeneMat
0051 [grRules,rxnGeneMat] = standardizeGrRules(model,true);
0052 model.grRules = grRules;
0053 model.rxnGeneMat = rxnGeneMat;
0054 end

Generated by m2html © 2005