detectDeadEnds

PURPOSE ^

findGaps returns a list(indices) of metabolites which either participate in only

SYNOPSIS ^

function outputMets = detectDeadEnds(model, removeExternalMets)

DESCRIPTION ^

findGaps returns a list(indices) of metabolites which either participate in only
one reaction or can only be produced or consumed (check if stoich
values are all -1 or all +1 and also check if lb is zero or not)

 outputMets = findGaps(model, removeExternalMets)

INPUT
 model                 COBRA model structure

OPTIONAL INPUT           
 removeExternalMets    Remove metabolites that participate in reactions
                       only with themselves (Default = false)

OUTPUT
 outputMets            List of indicies of metabolites which can ether
                       only be produced or consumed.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function outputMets = detectDeadEnds(model, removeExternalMets)
0002 %findGaps returns a list(indices) of metabolites which either participate in only
0003 %one reaction or can only be produced or consumed (check if stoich
0004 %values are all -1 or all +1 and also check if lb is zero or not)
0005 %
0006 % outputMets = findGaps(model, removeExternalMets)
0007 %
0008 %INPUT
0009 % model                 COBRA model structure
0010 %
0011 %OPTIONAL INPUT
0012 % removeExternalMets    Remove metabolites that participate in reactions
0013 %                       only with themselves (Default = false)
0014 %
0015 %OUTPUT
0016 % outputMets            List of indicies of metabolites which can ether
0017 %                       only be produced or consumed.
0018 
0019 if nargin < 2
0020     removeExternalMets = false;
0021 end
0022 mets = model.mets;
0023 S= model.S;
0024 [m,n] = size(S);
0025 
0026 num_outputMets = 0;
0027 outputMets = [];
0028 metNames = {};
0029 isOutputFlag = -1;
0030 
0031 j=1;
0032 i=1;
0033 
0034 
0035 %scrolls through rows.
0036 while(j<=m)
0037     %scrolls through cols.
0038     while(i<=n)
0039         %checks if there has already been an exception (either
0040         %metabolite participates in 2 reactions or participates in both
0041         %consumption and production)
0042         if(isOutputFlag==0)
0043             break
0044         end
0045         val = S(j,i);
0046         if(val~=0 && isOutputFlag~=1)
0047             %flag is raised and states that val is a possible output
0048             isOutputFlag=1;
0049             lowerBound = model.lb;
0050             valLB = lowerBound(i);
0051 %                 if(lowerBound(i)<0)
0052 %                     isOutputFlag=0;
0053 %                 end
0054             for w =i+1:n
0055                 %if there are exceptions than will not be output
0056                 if(~(S(j, w)==0 || (S(j, w)==val && lowerBound(w)>=0 && valLB >=0)))
0057                     isOutputFlag = 0;
0058                 end
0059             end
0060         end
0061         %there are no exceptions so val is output
0062         if(isOutputFlag==1)
0063             num_outputMets = num_outputMets+1;
0064             outputMets(num_outputMets,:) = j;
0065             metNames{num_outputMets} = mets(j);
0066             %terminates loop in row and moves onto next one
0067             i=n;
0068         end
0069         i=i+1;
0070         
0071     end
0072     
0073     i=1;
0074     isOutputFlag = -1;
0075     j=j+1;
0076 end
0077 
0078 %removeExternalMets gets rid of the external metabolites (metabolites thats
0079 %participate in reactions with only themselves)
0080 j=1;
0081 isExternalMet = 0;
0082 if(removeExternalMets == true)
0083     %go through all possible output mets
0084     while(j<=length(outputMets))
0085         %finds any reactions that the output met participates in
0086         outputRxns = find(S(outputMets(j),:));
0087         for(i=1:length(outputRxns))
0088             %find whether there any other mets in that reaction
0089             otherMets = find(S(:,outputRxns(i)));
0090             x = length(otherMets);
0091             %if there are no other mets than that met is removed from the
0092             %list of outputs
0093             if(x==1)
0094                 isExternalMet =1;
0095             end
0096         end
0097         if(isExternalMet == 1)
0098             outputMets(j,:) = [];
0099             %j
0100             j= j-1;
0101         end
0102         isExternalMet =0;
0103         j=j+1;
0104 
0105     end
0106 end

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