0001 function [MW, Ematrix] = computeMW(model, metList, warnings)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 if nargin < 3
0023 warnings = true;
0024 end
0025
0026 if nargin < 2 || isempty(metList)
0027 metList = model.mets;
0028 metIDs = 1:length(model.mets);
0029 else
0030 metIDs = findMetIDs(model,metList);
0031 end
0032
0033 metIDs = reshape(metIDs, length(metIDs),1);
0034
0035 MW = zeros(size(metIDs));
0036 for n = 1:length(metIDs)
0037 i = metIDs(n);
0038 formula = model.metFormulas(i);
0039 [compounds, tok] = regexp(formula, '([A-Z][a-z]*)(\d*)', 'match', 'tokens');
0040 tok = tok{1,1};
0041 for j = 1:length(tok)
0042 t = tok{1,j};
0043 comp = t{1,1};
0044 q = str2num(t{1,2});
0045 if (isempty(q))
0046 q = 1;
0047 end
0048 mwt = 0;
0049 switch comp
0050 case 'H'
0051 mwt = 1;
0052 case 'C'
0053 mwt = 12;
0054 case 'N'
0055 mwt = 14;
0056 case 'O'
0057 mwt = 16;
0058 case 'Na'
0059 mwt = 23;
0060 case 'Mg'
0061 mwt = 24;
0062 case 'P'
0063 mwt = 31;
0064 case 'S'
0065 mwt = 32;
0066 case 'Cl'
0067 mwt = 35;
0068 case 'K'
0069 mwt = 39;
0070 case 'Ca'
0071 mwt = 40;
0072 case 'Mn'
0073 mwt = 55;
0074 case 'Fe'
0075 mwt = 56;
0076 case 'Ni'
0077 mwt = 58;
0078 case 'Co'
0079 mwt = 59;
0080 case 'Cu'
0081 mwt = 63;
0082 case 'Zn'
0083 mwt = 65;
0084 case 'As'
0085 mwt = 75;
0086 case 'Se'
0087 mwt = 80;
0088 case 'Ag'
0089 mwt = 107;
0090 case 'Cd'
0091 mwt = 114;
0092 case 'W'
0093 mwt = 184;
0094 case 'Hg'
0095 mwt = 202;
0096 otherwise
0097 if warnings
0098 display('Warning');
0099 display(formula)
0100 display(comp);
0101 end
0102 end
0103 MW(n) = MW(n)+ q*mwt;
0104 end
0105 end
0106 Ematrix = computeElementalMatrix(model,metList,false);
0107