computeMW

PURPOSE ^

computeMW Compute molecular weight and elemental matrix of compounds

SYNOPSIS ^

function [MW, Ematrix] = computeMW(model, metList, warnings)

DESCRIPTION ^

computeMW Compute molecular weight and elemental matrix of compounds

 [MW, Ematrix] = computeMW(model, metList, warnings)

INPUT
 model             COBRA model structure 
                   (must define .mets and .metFormulas)

OPTIONAL INPUTS
 metList           Cell array of which metabolites to search for.
                   (Default = all metabolites in model)
 warnings          Display warnings if there are errors with the
                   formula.  (Default = true)

OUTPUT
 MW                Vector of molecular weights
 Ematrix           m x 6 matrix of order [C N O H P other]

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [MW, Ematrix] = computeMW(model, metList, warnings)
0002 %computeMW Compute molecular weight and elemental matrix of compounds
0003 %
0004 % [MW, Ematrix] = computeMW(model, metList, warnings)
0005 %
0006 %INPUT
0007 % model             COBRA model structure
0008 %                   (must define .mets and .metFormulas)
0009 %
0010 %OPTIONAL INPUTS
0011 % metList           Cell array of which metabolites to search for.
0012 %                   (Default = all metabolites in model)
0013 % warnings          Display warnings if there are errors with the
0014 %                   formula.  (Default = true)
0015 %
0016 %OUTPUT
0017 % MW                Vector of molecular weights
0018 % Ematrix           m x 6 matrix of order [C N O H P other]
0019 
0020 % Jan Schellenberger (Nov. 5, 2008)
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) % go through each token.
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

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