checkCobraModelUnique

PURPOSE ^

checkCobraModelUnique Check uniqueness of reaction and metabolite names

SYNOPSIS ^

function model = checkCobraModelUnique(model,renameFlag)

DESCRIPTION ^

checkCobraModelUnique Check uniqueness of reaction and metabolite names

 model = checkCobraModelUnique(model,renameFlag)

INPUT
 model         COBRA model structure

OPTIONAL INPUT
 renameFlag    Renames non-unique reaction names and metabolites
               (Default = false)

OUTPUT
 model         COBRA model structure

 Markus Herrgard 10/17/07

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function model = checkCobraModelUnique(model,renameFlag)
0002 %checkCobraModelUnique Check uniqueness of reaction and metabolite names
0003 %
0004 % model = checkCobraModelUnique(model,renameFlag)
0005 %
0006 %INPUT
0007 % model         COBRA model structure
0008 %
0009 %OPTIONAL INPUT
0010 % renameFlag    Renames non-unique reaction names and metabolites
0011 %               (Default = false)
0012 %
0013 %OUTPUT
0014 % model         COBRA model structure
0015 %
0016 % Markus Herrgard 10/17/07
0017 
0018 if (nargin < 2)
0019     renameFlag = false;
0020 end
0021 
0022 [rxnName,rxnCnt] = countUnique(model.rxns);
0023 rxnInd = find(rxnCnt > 1);
0024 if ~isempty(rxnInd)
0025     fprintf('Model contains non-unique reaction names - consider renaming reactions using checkCobraModelUnique\n');
0026     for i = 1:length(rxnInd)
0027         thisRxnName = rxnName{rxnInd(i)};
0028         fprintf('%s\t%d\n',thisRxnName,rxnCnt(rxnInd(i)));
0029         if (renameFlag)
0030             fprintf('Renaming non-unique reactions\n');
0031             rxnIDs = findRxnIDs(model,thisRxnName);
0032             for j = 1:length(rxnIDs)
0033                 model.rxns{rxnIDs(j)} = [thisRxnName '_' num2str(j)];
0034                 fprintf('%s\n',model.rxns{rxnIDs(j)});
0035             end
0036         end
0037     end
0038 end
0039 
0040 [metName,metCnt] = countUnique(model.mets);
0041 metInd = find(metCnt > 1);
0042 if ~isempty(metInd)
0043     fprintf('Model contains non-unique metabolite names - consider renaming metabolites using checkCobraModelUnique\n');
0044     for i = 1:length(metInd)
0045         thisMetName = metName{metInd(i)};
0046         fprintf('%s\n',thisMetName);
0047         if (renameFlag)
0048             fprintf('Renaming non-unique metabolites\n');
0049             rxnIDs = findRxnIDs(model,thisMetName);
0050             for j = 1:length(rxnIDs)
0051                 model.rxns{rxnIDs(j)} = [thisMetName '_' num2str(j)];
0052                 fprintf('%s\n',model.mets{rxnIDs(j)});
0053             end
0054         end
0055     end
0056 end

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