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 (opt, 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 (opt, 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 ~(numel(grRules)==numel(rxns))
0027     error('Number of rxns and grRules should be identical')
0028 end
0029 
0030 for i=1:length(rxns)
0031     % Add genes to model
0032     geneList=transpose(cell(unique(regexp(grRules{i},'[)(]*|( and )*|( or )*','split')))); % Extract individual, unique genes from the geneAssoc provided
0033     geneList=geneList(~cellfun(@isempty, geneList));
0034     genesToAdd.genes=setdiff(geneList,model.genes); % Only keep the genes that are not yet part of the model.genes.
0035     if ~isempty(genesToAdd.genes)
0036         model=addGenesRaven(model,genesToAdd); % Add genes
0037     end
0038     
0039     % Find reaction and gene indices
0040     idx=getIndexes(model,rxns,'rxns');
0041 end
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