createUniversalReactionModel

PURPOSE ^

createUMatrix creates the U matrix using the universal data from the KEGG

SYNOPSIS ^

function KEGG = createUniversalReactionModel(KEGGFilename, KEGGBlackList)

DESCRIPTION ^

createUMatrix creates the U matrix using the universal data from the KEGG
 database
 
 KEGG = createUMatrix(KEGGFilename)
 
 KEGG              U Matrix
 KEGGFilename      downloaded from KEGG database (ie. 'reaction.lst')

 11-10-07 IT

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function KEGG = createUniversalReactionModel(KEGGFilename, KEGGBlackList)
0002 %createUMatrix creates the U matrix using the universal data from the KEGG
0003 % database
0004 %
0005 % KEGG = createUMatrix(KEGGFilename)
0006 %
0007 % KEGG              U Matrix
0008 % KEGGFilename      downloaded from KEGG database (ie. 'reaction.lst')
0009 %
0010 % 11-10-07 IT
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; % hashes Kegg.mets
0025 
0026 for i = 1: length(KEGGReactionList)
0027     clear Rxn rxnFormulas;
0028     [Rxn, rxnFormulas] = strtok(KEGGReactionList(i),':');
0029      %continue if reaction is not in KEGGBlacklist
0030      
0031      if isempty(strmatch(Rxn, KEGGBlackList, 'exact'))%length(strmatch(Rxn,KEGGBlackList,'exact'))==0
0032          
0033     KEGG.rxns(cnti,1)=Rxn;
0034 
0035     %reformats syntax of reaction
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     %compounds is a list of each of metabolites involved in the
0067     %reaction that has a KEGGID starting with 'C'. b1 and c1 are just
0068     %so that the output has the correct number of variable
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             %condition1 = length(strmatch(compounds(j),KEGG.mets))==0
0073             condition2 = isempty(HTABLE.get(compounds{j}));
0074             %if condition1 ~= condition2, pause; end
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     %compounds is a list of each of metabolites involved in the
0085     %reaction that has a KEGGID starting with 'G'
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             %condition1 = length(strmatch(compounds(j),KEGG.mets))==0
0090             condition2 = isempty(HTABLE.get(compounds{j}));
0091             %if condition1 ~= condition2, pause; end
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,:)=[];

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