checkDuplicateRxn

PURPOSE ^

checkDuplicateRxn Checks model for duplicate reactions and removes them

SYNOPSIS ^

function [model,removed] = checkDuplicateRxn(model,method)

DESCRIPTION ^

checkDuplicateRxn Checks model for duplicate reactions and removes them

 [model,removed] = checkDuplicateRxn(model,method)

INPUTS
 model     Cobra model structure
 method    1 --> checks rxn abbreviations
           2 --> checks rxn S matrix

OUTPUTS
 model     Cobra model structure with duplicate reactions removed
 removed   reaction numbers that were removed

 Aarash Bordbar 02/11/08

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [model,removed] = checkDuplicateRxn(model,method)
0002 %checkDuplicateRxn Checks model for duplicate reactions and removes them
0003 %
0004 % [model,removed] = checkDuplicateRxn(model,method)
0005 %
0006 %INPUTS
0007 % model     Cobra model structure
0008 % method    1 --> checks rxn abbreviations
0009 %           2 --> checks rxn S matrix
0010 %
0011 %OUTPUTS
0012 % model     Cobra model structure with duplicate reactions removed
0013 % removed   reaction numbers that were removed
0014 %
0015 % Aarash Bordbar 02/11/08
0016 
0017 [nMets,nRxns] = size(model.S);
0018 cnt = 1;
0019 switch method
0020     case 1
0021         h = waitbar(0, 'Checking by Abbreviation ...');
0022         i = 1;
0023         while i <= nRxns
0024             model2 = model;
0025             model2.rxns{i} = '';
0026             if isempty(strmatch(model.rxns(i),model2.rxns,'exact')) == 0
0027                 matches = strmatch(model.rxns(i),model2.rxns,'exact');
0028                 nRxns = nRxns - length(matches);
0029                 model2 = removeRxns(model2,model.rxns(i));
0030                 model2.rxns{i} = model.rxns{i};
0031                 model = model2;
0032                 removed(cnt,1) = i;
0033                 cnt = cnt+1;
0034             end
0035             i = i+1;
0036             waitbar(i/nRxns,h);
0037         end
0038         close(h);
0039     case 2
0040         h = waitbar(0, 'Checking by reaction ...');
0041         for i = 1:nMets
0042             possibleMatches = find(model.S(i,:));
0043             for j = 1:length(possibleMatches)
0044                 for k = 1:length(possibleMatches)
0045                     if model.S(:,possibleMatches(j)) == model.S(:,possibleMatches(k)) & strcmp(model.rxns(possibleMatches(j)),model.rxns(possibleMatches(k))) == 0
0046                         model = removeRxns(model,model.rxns(possibleMatches(k)));
0047                     elseif model.S(:,possibleMatches(j)) == model.S(:,possibleMatches(k)) & strcmp(model.rxns(possibleMatches(j)),model.rxns(possibleMatches(k))) == 1
0048                         model2 = model;
0049                         model2.rxns{possibleMatches(j)} = '';
0050                         model2 = removeRxns(model2,model.rxns(possibleMatches(j)));
0051                         model2.rxns{possibleMatches(j)} = model.rxns{possibleMatches(j)};
0052                         model = model2;
0053                     end
0054                 end
0055             end
0056             waitbar(i/nMets,h);
0057         end
0058         close(h);
0059 end

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