0001 function linkMetaCycKEGGRxns
0002
0003
0004
0005
0006
0007
0008
0009
0010 load('metaCycRxns.mat');
0011 fprintf('NOTE: Importing MetaCyc reactions...\n');
0012 metaCycModel = metaCycRxns;
0013 metaCycModel.rxnFrom=cell(numel(metaCycModel.rxns),1);
0014 metaCycModel.rxnFrom(:)={'MetaCyc'};
0015 metaCycModel.grRules={};
0016 metaCycModel.genes={};
0017 metaCycModel.rxnGeneMat=sparse(numel(metaCycModel.rxns),1);
0018
0019
0020 keggModel=getRxnsFromKEGG();
0021
0022
0023 rxnToRemove=intersect(rxnLinks.kegg,keggModel.rxns);
0024 rxnToRemove=unique(rxnToRemove);
0025 shrinkedKeggModel=removeReactions(keggModel,rxnToRemove,true,true);
0026
0027 fprintf('Mapping MetaCyc and KEGG reactions...\n');
0028
0029
0030
0031 load('metaCycMets.mat');
0032 for i=1:numel(shrinkedKeggModel.mets)
0033 [a, b]=ismember(shrinkedKeggModel.mets{i},metaCycMets.keggid);
0034 if a
0035
0036 shrinkedKeggModel.mets{i}=metaCycMets.mets{b};
0037 shrinkedKeggModel.metNames{i}=metaCycMets.mets{b};
0038 end
0039 end
0040
0041
0042
0043
0044 metaCycModel.comps={'s'};
0045 metaCycModel.compNames={'System'};
0046 metaCycModel.metNames=metaCycModel.mets;
0047 if ~isfield(metaCycModel,'metComps')
0048 metaCycModel.metComps=ones(numel(metaCycModel.mets),1);
0049 end
0050
0051 shrinkedKeggModel.comps={'s'};
0052 shrinkedKeggModel.compNames={'System'};
0053 shrinkedKeggModel.metNames=shrinkedKeggModel.mets;
0054 if ~isfield(shrinkedKeggModel,'metComps')
0055 shrinkedKeggModel.metComps=ones(numel(shrinkedKeggModel.mets),1);
0056 end
0057
0058
0059 mappingModel=mergeModels({shrinkedKeggModel metaCycModel},'metNames');
0060
0061
0062 mappingModel=removeMets(mappingModel,{'PROTON','WATER'});
0063
0064
0065
0066
0067 I=find(ismember(mappingModel.rxnFrom,'KEGG'));
0068 for i=1:numel(I)
0069 testRxn=mappingModel.S(:,I(i));
0070 match=find(~any(bsxfun(@minus, mappingModel.S,testRxn)));
0071
0072 count=numel(match);
0073 if count>1
0074 for j=2:count
0075
0076 if isequal(mappingModel.rxnFrom{match(j)},'MetaCyc')
0077
0078
0079
0080 rxnLinks.kegg=[rxnLinks.kegg;mappingModel.rxns(match(1))];
0081 rxnLinks.metacyc=[rxnLinks.metacyc;mappingModel.rxns(match(j))];
0082 end
0083 end
0084 end
0085
0086 end
0087
0088
0089 numLink=numel(rxnLinks.kegg);
0090 rxnLinks.check=cell(numLink,1);
0091 for i=1:numLink
0092 rxnLinks.check{i}=strcat(rxnLinks.kegg{i},rxnLinks.metacyc{i});
0093 end
0094
0095 [~, index]=unique(rxnLinks.check);
0096 rxnLinks.kegg=rxnLinks.kegg(index);
0097 rxnLinks.metacyc=rxnLinks.metacyc(index);
0098 rxnLinks=rmfield(rxnLinks,'check');
0099
0100
0101 ravenPath=findRAVENroot();
0102 rxnsFile=fullfile(ravenPath,'external','metacyc','metaCycRxns.mat');
0103 save(rxnsFile,'metaCycRxns','rxnLinks','TRANSPORT','UNBALANCED','UNDETERMINED','isSpontaneous');
0104 fprintf(['Reaction associations between MetaCyc and KEGG have been successfully updated!\n\n']);
0105
0106 end