createXMatrix

PURPOSE ^

createXMatrix creates a matrix full of exchange reactions based

SYNOPSIS ^

function ExchangeRxnMatrix = createXMatrix(compoundsIn, transport, compartment)

DESCRIPTION ^

createXMatrix creates a matrix full of exchange reactions based
 on the input list (creates an exchange reaction for each of the
 metabolites present in the model)

 ExchangeRxnMatrix = createXMatrix(compoundsIn, transport, compartment)

 compoundsIn - SU matrix 

 transport     if 1, transport reactions will be defined as well for every
 compounds (default: 0, which corresponds to only exchange reactions)
 compartment   [c] --> transport from cytoplasm [c] to extracellulat space
 [e] (default), [p] creates transport from [c] to [p] and from [p] to [c]

 11-10-07 IT

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function ExchangeRxnMatrix = createXMatrix(compoundsIn, transport, compartment)
0002 %createXMatrix creates a matrix full of exchange reactions based
0003 % on the input list (creates an exchange reaction for each of the
0004 % metabolites present in the model)
0005 %
0006 % ExchangeRxnMatrix = createXMatrix(compoundsIn, transport, compartment)
0007 %
0008 % compoundsIn - SU matrix
0009 %
0010 % transport     if 1, transport reactions will be defined as well for every
0011 % compounds (default: 0, which corresponds to only exchange reactions)
0012 % compartment   [c] --> transport from cytoplasm [c] to extracellulat space
0013 % [e] (default), [p] creates transport from [c] to [p] and from [p] to [c]
0014 %
0015 % 11-10-07 IT
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 %removes the compartment from compound name
0032 compoundsIn=regexprep(compoundsIn,'(\w*)]','');
0033 compoundsIn=regexprep(compoundsIn,'[','');
0034 compoundsIn=regexprep(compoundsIn,']','');
0035 compoundsIn=regexprep(compoundsIn,' ','');
0036 
0037 compounds=unique(compoundsIn);
0038 
0039 %creates sparse matrix with corresponding dimensions
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             %   ExchangeRxnMatrix.grRules{cnt}='';
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 %currently only this branch is taken.
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             %   ExchangeRxnMatrix.grRules{cnt}='';
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                 % creates transport reaction from [c] to [e]
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                 %  ExchangeRxnMatrix.grRules{cnt}='';
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) % keep this branch the same for now.
0099                 % creates transport reaction from [c] to [p]
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                 %  ExchangeRxnMatrix.grRules{cnt}='';
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                 % creates transport reaction from [p] to [e]
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                 %    ExchangeRxnMatrix.grRules{cnt}='';
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);

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