0001 function pathway=trimPathway(pathway, rxnsToKeep, deleteUnconnectedMets)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 if nargin<3
0017 deleteUnconnectedMets=true;
0018 end
0019
0020
0021 indexesToDelete=false(numel(pathway.listOfSpecies),1);
0022 aliasesToDelete={};
0023
0024 for i=1:numel(pathway.listOfSpecies)
0025 if strcmpi(pathway.listOfSpecies(i).type,'PROTEIN')
0026
0027 if ~ismember(pathway.listOfSpecies(i).name,rxnsToKeep)
0028 indexesToDelete(i)=true;
0029 aliasesToDelete=[aliasesToDelete;pathway.listOfSpecies(i).alias];
0030 end
0031 end
0032 end
0033
0034
0035
0036 rxnsToDelete=false(numel(pathway.listOfReactions),1);
0037
0038 for i=1:numel(pathway.listOfReactions)
0039
0040
0041 componentsToDelete=zeros(numel(pathway.listOfReactions(i).componentList),1);
0042 for j=1:numel(pathway.listOfReactions(i).componentList)
0043 if strcmpi(pathway.listOfReactions(i).componentList(j).type,'ENZYME')
0044
0045
0046 if ismember(pathway.listOfReactions(i).componentList(j).alias,aliasesToDelete)
0047 componentsToDelete(j)=-1;
0048 else
0049 componentsToDelete(j)=1;
0050 end
0051 end
0052 end
0053
0054
0055 if ~any(componentsToDelete==1)
0056 rxnsToDelete(i)=true;
0057 else
0058 pathway.listOfReactions(i).componentList(componentsToDelete==-1)=[];
0059 end
0060 end
0061
0062
0063 pathway.listOfSpecies(indexesToDelete)=[];
0064 pathway.listOfReactions(rxnsToDelete)=[];
0065
0066
0067
0068 aliasesToKeeep={};
0069 if deleteUnconnectedMets==true
0070 for i=1:numel(pathway.listOfReactions)
0071 for j=1:numel(pathway.listOfReactions(i).componentList)
0072 aliasesToKeeep=[aliasesToKeeep;pathway.listOfReactions(i).componentList(j).alias];
0073 end
0074 end
0075
0076
0077
0078 indexesToDelete=true(numel(pathway.listOfSpecies),1);
0079 for i=1:numel(pathway.listOfSpecies)
0080 if ismember(pathway.listOfSpecies(i).alias,aliasesToKeeep)
0081 indexesToDelete(i)=false;
0082 end
0083 end
0084
0085 pathway.listOfSpecies(indexesToDelete)=[];
0086 end
0087 end