0001 function [spontaneousRxnList, pathwayID]=addSpontaneousRxns(rxnList, metList)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 metList=convertCharArray(metList);
0019 rxnList=convertCharArray(rxnList);
0020 rxnList=unique(rxnList);
0021
0022
0023 load('metaCycRxns.mat');
0024 pathways={};
0025 for i=1:numel(metaCycRxns.rxns)
0026 if ~isempty(metaCycRxns.pwys{i})
0027 pathways=[pathways;transpose(strsplit(metaCycRxns.pwys{i},';'))];
0028 end
0029 end
0030 pathways=unique(pathways);
0031
0032
0033 sprxnPwyMat=zeros(numel(isSpontaneous),numel(pathways));
0034 for i=1:numel(isSpontaneous)
0035 [a, b]=ismember(isSpontaneous{i},metaCycRxns.rxns);
0036 if ~isempty(metaCycRxns.pwys{b})
0037 [crap, indexes]=ismember(strsplit(metaCycRxns.pwys{b},';'),pathways);
0038 sprxnPwyMat(i,indexes)=1;
0039 end
0040 end
0041
0042
0043 pwys={};
0044 for i=1:numel(rxnList)
0045 [a, b]=ismember(rxnList{i},metaCycRxns.rxns);
0046 if a && ~isempty(metaCycRxns.pwys{b})
0047 pwys=[pwys;transpose(strsplit(metaCycRxns.pwys{b},';'))];
0048 end
0049 end
0050 pwys=unique(pwys);
0051
0052
0053 hits=[];
0054 for i=1:numel(pwys)
0055 [a, b]=ismember(pwys{i},pathways);
0056 if ~isempty(find(sprxnPwyMat(:,b)))
0057 hits=[hits;find(sprxnPwyMat(:,b))];
0058 end
0059 end
0060 spontaneousRxnList=isSpontaneous(unique(hits));
0061
0062
0063 for i=1:numel(spontaneousRxnList)
0064 [a, b]=ismember(spontaneousRxnList{i},metaCycRxns.rxns);
0065
0066
0067 reactants=all(ismember(metaCycRxns.mets(find(metaCycRxns.S(:,b)==-1)),metList));
0068 products=all(ismember(metaCycRxns.mets(find(metaCycRxns.S(:,b)==1)),metList));
0069
0070
0071 if metaCycRxns.rev(b)==1
0072 if ~(reactants || products)
0073 spontaneousRxnList{i}=[];
0074 end
0075
0076 else
0077 if ~reactants
0078 spontaneousRxnList{i}=[];
0079 end
0080 end
0081 end
0082 spontaneousRxnList=spontaneousRxnList(~cellfun(@isempty, spontaneousRxnList));
0083
0084
0085 spontaneousRxnList=setdiff(spontaneousRxnList,rxnList);
0086
0087
0088 pathwayID=cell(numel(spontaneousRxnList),1);
0089 for i=1:numel(spontaneousRxnList)
0090 index=find(strcmp(spontaneousRxnList{i},isSpontaneous));
0091
0092 relevantpwys=intersect(pathways(find(sprxnPwyMat(index,:))),pwys);
0093 pathwayID{i}=strjoin(relevantpwys,';');
0094 end
0095
0096 end