Template:MassBank/Matrix
From Metabolomics.JP
(Difference between revisions)
m |
m |
||
Line 9: | Line 9: | ||
function mass(str) | function mass(str) | ||
− | local c,h,n,o=string.match(str,"(C?[1-9]?[0-9]?)(H?[1-9]?[0-9]?)(N?[1-9]?[0-9]?)(O?[1-9]?[0-9]?)"); | + | local c,h,n,o,s=string.match(str,"(C?[1-9]?[0-9]?)(H?[1-9]?[0-9]?)(N?[1-9]?[0-9]?)(O?[1-9]?[0-9]?)(S?[1-9]?)"); |
c = atomicNum("C", c) * 12; | c = atomicNum("C", c) * 12; | ||
h = atomicNum("H", h); | h = atomicNum("H", h); | ||
n = atomicNum("N", n) * 14; | n = atomicNum("N", n) * 14; | ||
o = atomicNum("O", o) * 16; | o = atomicNum("O", o) * 16; | ||
− | return c + h + n + o; | + | s = atomicNum("S", s) * 32; |
+ | return c + h + n + o + s; | ||
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 c1,h1,n1,o1=string.match(str1,"(C?[1-9]?[0-9]?)(H?[1-9]?[0-9]?)(N?[1-9]?[0-9]?)(O?[1-9]?[0-9]?)"); | + | local c1,h1,n1,o1,s1=string.match(str1,"(C?[1-9]?[0-9]?)(H?[1-9]?[0-9]?)(N?[1-9]?[0-9]?)(O?[1-9]?[0-9]?)(S?[1-9]?)"); |
− | local c2,h2,n2,o2=string.match(str2,"(C?[1-9]?[0-9]?)(H?[1-9]?[0-9]?)(N?[1-9]?[0-9]?)(O?[1-9]?[0-9]?)"); | + | local c2,h2,n2,o2,s2=string.match(str2,"(C?[1-9]?[0-9]?)(H?[1-9]?[0-9]?)(N?[1-9]?[0-9]?)(O?[1-9]?[0-9]?)(S?[1-9]?)"); |
c1 = atomicNum("C", c1); | c1 = atomicNum("C", c1); | ||
h1 = atomicNum("H", h1); | h1 = atomicNum("H", h1); | ||
n1 = atomicNum("N", n1); | n1 = atomicNum("N", n1); | ||
o1 = atomicNum("O", o1); | o1 = atomicNum("O", o1); | ||
+ | s1 = atomicNum("S", s1); | ||
c2 = atomicNum("C", c2); | c2 = atomicNum("C", c2); | ||
h2 = atomicNum("H", h2); | h2 = atomicNum("H", h2); | ||
n2 = atomicNum("N", n2); | n2 = atomicNum("N", n2); | ||
o2 = atomicNum("O", o2); | o2 = atomicNum("O", o2); | ||
+ | s2 = atomicNum("S", s2); | ||
if (c2 > c1) then return nil; else c1 = c1 - c2; end | if (c2 > c1) then return nil; else c1 = c1 - c2; end | ||
if (h2 > h1) then return nil; else h1 = h1 - h2; end | if (h2 > h1) then return nil; else h1 = h1 - h2; end | ||
if (n2 > n1) then return nil; else n1 = n1 - n2; end | if (n2 > n1) then return nil; else n1 = n1 - n2; end | ||
if (o2 > o1) then return nil; else o1 = o1 - o2; end | if (o2 > o1) then return nil; else o1 = o1 - o2; end | ||
+ | if (s2 > s1) then return nil; else s1 = s1 - s2; end | ||
local ret = ""; | local ret = ""; | ||
if (c1 > 1) then ret = ret .. "C" .. c1; | if (c1 > 1) then ret = ret .. "C" .. c1; | ||
Line 42: | Line 46: | ||
if (o1 > 1) then ret = ret .. "O" .. o1; | if (o1 > 1) then ret = ret .. "O" .. o1; | ||
else if (o1 == 1) then ret = ret .. "O"; end end | else if (o1 == 1) then ret = ret .. "O"; end end | ||
+ | if (s1 > 1) then ret = ret .. "S" .. s1; | ||
+ | else if (s1 == 1) then ret = ret .. "S"; end end | ||
return ret; | return ret; | ||
end | end | ||
Line 51: | Line 57: | ||
if (string.find(line, ":") == nil) then ruler = line; | if (string.find(line, ":") == nil) then ruler = line; | ||
else ---register fragments--- | else ---register fragments--- | ||
− | head, tail = string.match(line, "([ | + | head, tail = string.match(line, "([CHNOS0-9]+) *: *([CHNOS0-9 ]+)"); |
y = {}; | y = {}; | ||
− | for x in string.gmatch(tail,"[ | + | for x in string.gmatch(tail,"[CHNOS0-9]+") do |
y[x] = x; | y[x] = x; | ||
end | end | ||
Line 89: | Line 95: | ||
end | end | ||
| | | | ||
− | {{{data| | + | {{{data|CHNOS}}} |
}} | }} | ||
|#|{{#bar:}}}} | |#|{{#bar:}}}} | ||
|} | |} |
Revision as of 13:08, 12 May 2009
MassBank/Matrix | 75 CHNOS |
75 CHNOS |