0001 function KEGG = createUniversalReactionModel(KEGGFilename, KEGGBlackList)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 if nargin < 2
0013 KEGGBlackList= {};
0014 end
0015 if nargin < 1
0016 KEGGFilename='11-20-08-KEGG-reaction.lst';
0017 end
0018
0019 KEGGReactionList = importdata(KEGGFilename);
0020 KEGG = createModel;
0021 cnt=1;
0022 cnti=1;
0023 h=waitbar(0,'KEGG reaction list ...');
0024 HTABLE = java.util.Hashtable;
0025
0026 for i = 1: length(KEGGReactionList)
0027 clear Rxn rxnFormulas;
0028 [Rxn, rxnFormulas] = strtok(KEGGReactionList(i),':');
0029
0030
0031 if isempty(strmatch(Rxn, KEGGBlackList, 'exact'))
0032
0033 KEGG.rxns(cnti,1)=Rxn;
0034
0035
0036 rxnFormulas= regexprep(rxnFormulas,': ','');
0037 rxnFormulas= regexprep(rxnFormulas,'\+ C','\+ 1 C');
0038 rxnFormulas= regexprep(rxnFormulas,' \+','[c] \+');
0039 rxnFormulas= regexprep(rxnFormulas,'=> C','=> 1 C');
0040 rxnFormulas= regexprep(rxnFormulas,' <','[c] <');
0041 rxnFormulas= regexprep(rxnFormulas,'^(C)','1 C');
0042 rxnFormulas= regexprep(rxnFormulas,' \[c]','[c]');
0043
0044 rxnFormulas= regexprep(rxnFormulas,'\+ G','\+ 1 G');
0045 rxnFormulas= regexprep(rxnFormulas,'=> G','=> 1 G');
0046 rxnFormulas= regexprep(rxnFormulas,'^(G)','1 G');
0047 rxnFormulas= regexprep(rxnFormulas,'^(n) ','2 ');
0048 rxnFormulas= regexprep(rxnFormulas,'\+ n ','\+ 2 ');
0049 rxnFormulas= regexprep(rxnFormulas,'\> n ','\> 2 ');
0050 rxnFormulas= regexprep(rxnFormulas,'\ n-1 ','\ 1 ');
0051 rxnFormulas= regexprep(rxnFormulas,'^(n-1) ','1 ');
0052 rxnFormulas= regexprep(rxnFormulas,'\+ 2n ','\+ 2 ');
0053 rxnFormulas= regexprep(rxnFormulas,'\+ 4n ','\+ 4 ');
0054 rxnFormulas= regexprep(rxnFormulas,'\+ (n+1) ','\+ 3 ');
0055 rxnFormulas= regexprep(rxnFormulas,'\=> (n+1) ','\=> 3 ');
0056 rxnFormulas= regexprep(rxnFormulas,' 3C',' 3 C');
0057 rxnFormulas= regexprep(rxnFormulas,' 2C',' 2 C');
0058 rxnFormulas= regexprep(rxnFormulas,' 4C',' 4 C');
0059
0060 rxnFormulas = strcat(rxnFormulas,'[c]');
0061 rxnFormulas= regexprep(rxnFormulas,'<=>','<==>');
0062 rxnFormulas= regexprep(rxnFormulas,'\=>>','=>');
0063
0064 KEGG.rxnFormulas(cnti,1)=rxnFormulas;
0065 cnti=cnti+1;
0066
0067
0068
0069 [compounds, b1, c1] = regexp(char(rxnFormulas),'C\w+\[c]','match','start','end');
0070 for j=1:length(compounds)
0071 if (~isempty(compounds(j)))
0072
0073 condition2 = isempty(HTABLE.get(compounds{j}));
0074
0075 if (condition2)
0076 HTABLE.put(compounds{j}, cnt);
0077 KEGG.mets(cnt,1)=compounds(j);
0078 cnt=cnt+1;
0079 end
0080 end
0081 end
0082 clear compounds
0083
0084
0085
0086 [compounds, b1, c1] = regexp(char(rxnFormulas),'G\w+\[c]','match','start','end');
0087 for j=1:length(compounds)
0088 if (~isempty(compounds(j)))
0089
0090 condition2 = isempty(HTABLE.get(compounds{j}));
0091
0092 if (condition2)
0093 HTABLE.put(compounds{j}, cnt);
0094 KEGG.mets(cnt,1)=compounds(j);
0095 cnt=cnt+1;
0096 end
0097 end
0098 end
0099
0100 end
0101 if (mod(i,40) ==0), waitbar(i/length(KEGGReactionList),h), end
0102 end
0103 close(h);
0104 KEGG.S=spalloc(length(KEGG.mets) + 2*length(KEGG.mets), length(KEGG.mets) + 2*length(KEGG.mets), length(KEGG.mets) + 2*length(KEGG.mets) );
0105
0106 [KEGG] = addReactionGEM(KEGG,KEGG.rxns,KEGG.rxns,KEGG.rxnFormulas,ones(length(KEGG.rxns),1),-10000*ones(length(KEGG.rxns),1),10000*ones(length(KEGG.rxns),1),1);
0107 a=length(KEGG.mets);
0108 KEGG.S(a+1:end,:)=[];