Template:MassBank/Matrix
From Metabolomics.JP
(Difference between revisions)
m |
m |
||
| Line 3: | Line 3: | ||
FORMULA_PAT = "(C?[1-9]?[0-9]?)(H?[1-9]?[0-9]?)(C?l?[2-9]?)(N?[1-9]?[0-9]?)(O?[1-9]?[0-9]?)(P?[2-9]?)(S?[2-9]?)"; | FORMULA_PAT = "(C?[1-9]?[0-9]?)(H?[1-9]?[0-9]?)(C?l?[2-9]?)(N?[1-9]?[0-9]?)(O?[1-9]?[0-9]?)(P?[2-9]?)(S?[2-9]?)"; | ||
FORMULA_CHAR = "CHNOPSl0-9"; | FORMULA_CHAR = "CHNOPSl0-9"; | ||
| + | ATOMS = {C=12, H=1, Cl=35, N=14, O=16, P=31, S=32}; | ||
| + | |||
| + | function map(f, list) | ||
| + | local ret = {}; | ||
| + | for _, v in pairs(list) do | ||
| + | table.insert(ret, f(v)); | ||
| + | end | ||
| + | return ret; | ||
| + | end | ||
| + | |||
function atomicNum(atom, str) | function atomicNum(atom, str) | ||
| − | if (str == "") then return 0 | + | if (str == "") then return 0 end |
| − | if (str == atom) then return 1 | + | if (ATOMS[str] ~= nil) then return 1 end |
| − | if (string.len(str) > 2 and string.sub(str,1,2) = | + | if (str == atom) then return 1 end |
| + | if (string.len(str) > 2 and ATOMS[string.sub(str,1,2)] ~= nil) | ||
then return tonumber(string.sub(str,3)); | then return tonumber(string.sub(str,3)); | ||
else return tonumber(string.sub(str,2)); | else return tonumber(string.sub(str,2)); | ||
Revision as of 18:11, 13 May 2009
No ion information in the form &&(formula)&&(formula)&&...&&
| MassBank/Matrix | 64 CHClONSP |
| 64 CHClONSP |
|