alphabetizeModel

PURPOSE ^

alphabetizeModel Sort the rxns, metabolites, and genes in a model into alphabetical

SYNOPSIS ^

function abcModel = alphabetizeModel(model)

DESCRIPTION ^

alphabetizeModel Sort 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)

 abcModel = alphabetizeModel(model)

INPUT
 model         COBRA model structure

OUTPUT
 abcModel      the alphabetized model

 Jeff Orth  11/21/07
 Modified to work on basic COBRA model. Richard Que (2/1/10)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function abcModel = alphabetizeModel(model)
0002 %alphabetizeModel Sort the rxns, metabolites, and genes in a model into alphabetical
0003 %order, useful after adding new reactions to a model. This function needs
0004 %to be modified to work on models with different fields than these
0005 %(currently set for iAF1260c)
0006 %
0007 % abcModel = alphabetizeModel(model)
0008 %
0009 %INPUT
0010 % model         COBRA model structure
0011 %
0012 %OUTPUT
0013 % abcModel      the alphabetized model
0014 %
0015 % Jeff Orth  11/21/07
0016 % Modified to work on basic COBRA model. Richard Que (2/1/10)
0017 
0018 abcModel = model;
0019 
0020 [abcModel.rxns,iRxns] = sort(abcModel.rxns);
0021 [abcModel.mets,iMets] = sort(abcModel.mets);
0022 S = abcModel.S(:,iRxns);
0023 abcModel.S = S(iMets,:);
0024 abcModel.lb = abcModel.lb(iRxns);
0025 abcModel.ub = abcModel.ub(iRxns);
0026 abcModel.c = abcModel.c(iRxns);
0027 abcModel.b = abcModel.b(iMets);
0028 
0029 if isfield(model,'rev'), abcModel.rev = abcModel.rev(iRxns); end
0030 if isfield(model,'charges'), abcModel.charges = abcModel.charges(iMets); end
0031 if isfield(model,'metCharge'), abcModel.metCharge = abcModel.metCharge(iMets); end
0032 if isfield(model,'subSystems'), abcModel.subSystems = abcModel.subSystems(iRxns); end
0033 if isfield(model,'rxnNames'), abcModel.rxnNames = abcModel.rxnNames(iRxns); end
0034 if isfield(model,'metNames'), abcModel.metNames = abcModel.metNames(iMets); end
0035 if isfield(model,'metFormulas'), abcModel.metFormulas = abcModel.metFormulas(iMets); end
0036 if isfield(model,'genes')
0037     [abcModel.genes,iGenes] = sort(abcModel.genes);
0038     if isfield(model,'rxnGeneMat')
0039         rxnGeneMat = abcModel.rxnGeneMat(:,iGenes);
0040         abcModel.rxnGeneMat = rxnGeneMat(iRxns,:);
0041     end
0042 end
0043 if isfield(model,'grRules')
0044     abcModel.grRules = abcModel.grRules(iRxns);
0045     if isfield(model,'rules')
0046         for i=1:length(model.grRules)
0047             [genes, rules] = parseBoolean(abcModel.grRules{i});
0048             [tmp geneInd] = ismember(genes,abcModel.genes);
0049             if ~isempty(geneInd)
0050                 for j = 1:length(geneInd)
0051                     rules = strrep(rules,['x(' num2str(j) ')'],['x(' num2str(geneInd(j)) '_TMP_)']);
0052                 end
0053                 abcModel.rules{i} = strrep(rules,'_TMP_','');
0054             else
0055                 abcModel.rules{i} = '';
0056             end
0057         end
0058     end
0059 end

Generated on Thu 21-Jun-2012 15:39:23 by m2html © 2003