0001 function ExchangeRxnMatrix = createXMatrix(compoundsIn, transport, compartment)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 if nargin < 3
0019 compartment = '[c]';
0020 end
0021 if nargin < 2
0022 transport = 0;
0023 end
0024 h=waitbar(0,'Exchange reaction list ...');
0025 ExchangeRxnMatrix = createModel;
0026
0027
0028 cnt=1;
0029 HTABLE = java.util.Hashtable;
0030
0031
0032 compoundsIn=regexprep(compoundsIn,'(\w*)]','');
0033 compoundsIn=regexprep(compoundsIn,'[','');
0034 compoundsIn=regexprep(compoundsIn,']','');
0035 compoundsIn=regexprep(compoundsIn,' ','');
0036
0037 compounds=unique(compoundsIn);
0038
0039
0040 if transport==0
0041 ExchangeRxnMatrix.S=spalloc(length(compounds),length(compounds),length(compounds));
0042 elseif transport == 1
0043 if (strcmp(compartment,'[c]')==1)
0044 ExchangeRxnMatrix.S=spalloc(length(compounds),2*length(compounds),3*length(compounds));
0045 elseif (strcmp(compartment,'[p]')==1)
0046 ExchangeRxnMatrix.S=spalloc(length(compounds),3*length(compounds),5*length(compounds));
0047 end
0048 end
0049
0050 ExchangeRxnMatrix.mets=compounds;
0051 for i=1:length(compounds)
0052 HTABLE.put(compounds{i}, i);
0053 end
0054 for i=1:length(compounds)
0055 if ~isempty(compounds(i))
0056 if transport == 0
0057 tmp = ['sink_' compounds(i) '[c]'];
0058 ExchangeRxnMatrix.rxns(cnt,1) = strcat(tmp(1),tmp(2),tmp(3));
0059 tmp = ['sink for ' compounds(i)];
0060 ExchangeRxnMatrix.rxnsNames(cnt,1) = strcat(tmp(1),tmp(2));
0061 tmp = ['1 ' compounds(i) '[c] <==>'];
0062 ExchangeRxnMatrix.rxnFormulas(cnt,1) = strcat(tmp(1),tmp(2),tmp(3));
0063 tmp = [compounds(i) '[c]'];
0064 ExchangeRxnMatrix.mets(i) = strcat(tmp(1),tmp(2));
0065
0066 [ExchangeRxnMatrix] = addReactionGEM(ExchangeRxnMatrix,ExchangeRxnMatrix.rxns(cnt,1),ExchangeRxnMatrix.rxnsNames(cnt,1),ExchangeRxnMatrix.rxnFormulas(cnt,1),1,-10000,10000);
0067 cnt = cnt + 1;
0068
0069 elseif transport == 1
0070 tmp = ['Ex_' compounds(i) '[e]'];
0071 ExchangeRxnMatrix.rxns(cnt,1) = strcat(tmp(1),tmp(2),tmp(3));
0072 tmp = ['Exchange of ' compounds(i)];
0073 ExchangeRxnMatrix.rxnsNames(cnt,1) = strcat(tmp(1),tmp(2));
0074 tmp = ['1 ' compounds(i) '[e] <==>'];
0075 ExchangeRxnMatrix.rxnFormulas(cnt,1) = strcat(tmp(1),tmp(2),tmp(3));
0076 tmp = [compounds(i) '[e]'];
0077 ExchangeRxnMatrix.mets(i) = strcat(tmp(1),tmp(2));
0078 HTABLE.put(ExchangeRxnMatrix.mets{i}, i);
0079
0080 [ExchangeRxnMatrix, HTABLE] = addReactionGEM(ExchangeRxnMatrix,ExchangeRxnMatrix.rxns(cnt,1),ExchangeRxnMatrix.rxnsNames(cnt,1),ExchangeRxnMatrix.rxnFormulas(cnt,1),1,-10000,10000,[],[],[],[],[], HTABLE);
0081 cnt = cnt + 1;
0082
0083 if (strcmp(compartment,'[c]')==1)
0084
0085 tmp = [compounds(i) 'tr'];
0086 ExchangeRxnMatrix.rxns(cnt,1) = strcat(tmp(1),tmp(2));
0087 tmp = ['Transport of ' compounds(i)];
0088 ExchangeRxnMatrix.rxnsNames(cnt,1) = strcat(tmp(1),tmp(2));
0089 tmp = ['1 ' compounds(i) '[e] <==> 1 ' compounds(i) '[c]'];
0090 ExchangeRxnMatrix.rxnFormulas(cnt,1) = strcat(tmp(1),tmp(2),tmp(3),tmp(4),tmp(5));
0091 tmp = [compounds(i) '[c]'];
0092 ExchangeRxnMatrix.mets(length(ExchangeRxnMatrix.mets)+1,1) = strcat(tmp(1),tmp(2));
0093 HTABLE.put(ExchangeRxnMatrix.mets{end}, length(ExchangeRxnMatrix.mets));
0094
0095 [ExchangeRxnMatrix, HTABLE] = addReactionGEM(ExchangeRxnMatrix,ExchangeRxnMatrix.rxns(cnt,1),ExchangeRxnMatrix.rxnsNames(cnt,1),ExchangeRxnMatrix.rxnFormulas(cnt,1),1,-10000,10000,[],[],[],[],[], HTABLE);
0096 cnt = cnt + 1;
0097
0098 elseif (strcmp(compartment,'[p]')==1)
0099
0100 tmp = [compounds(i) 'tpr'];
0101 ExchangeRxnMatrix.rxns(cnt,1) = strcat(tmp(1),tmp(2));
0102 tmp = ['[c] to [p] Transport of ' compounds(i)];
0103 ExchangeRxnMatrix.rxnsNames(cnt,1) = strcat(tmp(1),tmp(2));
0104 tmp = ['1 ' compounds(i) '[p] <==> 1 ' compounds(i) '[c]'];
0105 ExchangeRxnMatrix.rxnFormulas(cnt,1) = strcat(tmp(1),tmp(2),tmp(3),tmp(4),tmp(5));
0106 tmp = [compounds(i) '[c]'];
0107 ExchangeRxnMatrix.mets(length(ExchangeRxnMatrix.mets)+1,1) = strcat(tmp(1),tmp(2));
0108 tmp = [compounds(i) '[p]'];
0109 ExchangeRxnMatrix.mets(length(ExchangeRxnMatrix.mets)+1,1) = strcat(tmp(1),tmp(2));
0110
0111 [ExchangeRxnMatrix] = addReactionGEM(ExchangeRxnMatrix,ExchangeRxnMatrix.rxns(cnt,1),ExchangeRxnMatrix.rxnsNames(cnt,1),ExchangeRxnMatrix.rxnFormulas(cnt,1),1,-10000,10000);
0112 cnt = cnt + 1;
0113
0114
0115 tmp = [compounds(i) 'tr'];
0116 ExchangeRxnMatrix.rxns(cnt,1) = strcat(tmp(1),tmp(2));
0117 tmp = ['[p] to [e] Transport of ' compounds(i)];
0118 ExchangeRxnMatrix.rxnsNames(cnt,1) = strcat(tmp(1),tmp(2));
0119 tmp = ['1 ' compounds(i) '[e] <==> 1 ' compounds(i) '[p]'];
0120 ExchangeRxnMatrix.rxnFormulas(cnt,1) = strcat(tmp(1),tmp(2),tmp(3),tmp(4),tmp(5));
0121
0122 [ExchangeRxnMatrix] = addReactionGEM(ExchangeRxnMatrix,ExchangeRxnMatrix.rxns(cnt,1),ExchangeRxnMatrix.rxnsNames(cnt,1),ExchangeRxnMatrix.rxnFormulas(cnt,1),1,-10000,10000);
0123 cnt = cnt + 1;
0124 end
0125 end
0126 end
0127 if(mod(i, 40) ==0),waitbar(i/length(compounds),h);end
0128 end
0129 close(h);