Template:MassBank/Matrix
From Metabolomics.JP
(Difference between revisions)
m |
m |
||
| Line 36: | Line 36: | ||
end | end | ||
| − | function | + | function mass(str) |
local t = toFormula({string.match(str,FORMULA_PAT)}) | local t = toFormula({string.match(str,FORMULA_PAT)}) | ||
ret = 0; | ret = 0; | ||
| Line 53: | Line 53: | ||
else return tonumber(string.sub(str,2)); | else return tonumber(string.sub(str,2)); | ||
end | end | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
end | end | ||
function diff(str1, str2) | function diff(str1, str2) | ||
---computes str1 - str2. If negative, returns nil.--- | ---computes str1 - str2. If negative, returns nil.--- | ||
| + | local t1 = {string.match(str1,FORMULA_PAT)}; | ||
| + | local t2 = {string.match(str2,FORMULA_PAT)}; | ||
| + | for i,_ in pairs(t1) do | ||
| + | if (t1[i] < t2[i]) then return nil else t1[i] = t1[i]-t2[i] end | ||
| + | end | ||
| + | local ret = ""; | ||
| + | for i,v in pairs(t1) do | ||
| + | if (v > 1) then ret = ret .. ATOMS[i] .. v; | ||
| + | else if (v == 1) then ret = ret .. ATOMS[i]; end end | ||
| + | end | ||
| + | return ret; | ||
| + | --[[ | ||
local c1,h1,cl1,n1,o1,p1,s1=string.match(str1,FORMULA_PAT); | local c1,h1,cl1,n1,o1,p1,s1=string.match(str1,FORMULA_PAT); | ||
local c2,h2,cl2,n2,o2,p2,s2=string.match(str2,FORMULA_PAT); | local c2,h2,cl2,n2,o2,p2,s2=string.match(str2,FORMULA_PAT); | ||
| Line 111: | Line 108: | ||
else if (s1 == 1) then ret = ret .. "S"; end end | else if (s1 == 1) then ret = ret .. "S"; end end | ||
return ret; | return ret; | ||
| + | ]]-- | ||
end | end | ||
Revision as of 23:31, 13 May 2009
./lua: /tmp/mw_ex_lua_rIh9hZ:155: attempt to call global 'toMass' (a nil value) No ion information in the form &&(formula)&&(formula)&&...&&
| MassBank/Matrix
|