Template:MassBank/Matrix
From Metabolomics.JP
(Difference between revisions)
m |
m |
||
Line 43: | Line 43: | ||
end | end | ||
+ | ---Main Program--- | ||
local ruler = nil; | local ruler = nil; | ||
local fragments = {}; | local fragments = {}; | ||
Line 49: | Line 50: | ||
for line in stdin:gmatch("[%S ,]+") do | for line in stdin:gmatch("[%S ,]+") do | ||
if (string.find(line, "^&&[&%a%d]+&&$") ~= nil) | if (string.find(line, "^&&[&%a%d]+&&$") ~= nil) | ||
− | then ruler = string.gsub(line, "&&", " ") | + | then ruler = string.gsub(line, "&&", " ") |
else | else | ||
---register fragments--- | ---register fragments--- | ||
head, tail = string.match(line, "^(["..FORMULA_CHAR.."]+) *: *(["..FORMULA_CHAR.." ]+)$") | head, tail = string.match(line, "^(["..FORMULA_CHAR.."]+) *: *(["..FORMULA_CHAR.." ]+)$") | ||
if (head ~= nil and tail ~= nil) then | if (head ~= nil and tail ~= nil) then | ||
− | y = {} | + | y = {} |
for x in string.gmatch(tail,"["..FORMULA_CHAR.."]+") do | for x in string.gmatch(tail,"["..FORMULA_CHAR.."]+") do | ||
− | y[x] = x | + | y[x] = x |
end | end | ||
− | fragments[head] = y | + | fragments[head] = y |
end | end | ||
end | end | ||
Line 64: | Line 65: | ||
---Check Ruler--- | ---Check Ruler--- | ||
if (ruler == nil) then | if (ruler == nil) then | ||
− | print("No 'ION INFO' line in the form &&(formula)&&(formula)&&...&&") | + | print("No 'ION INFO' line in the form &&(formula)&&(formula)&&...&&") |
− | ruler = "CHClONSP" | + | ruler = "CHClONSP" |
end | end | ||
− | x = nil | + | x = nil |
− | y = {} | + | y = {} |
for formula in string.gmatch(ruler, "([%S]+)") do | for formula in string.gmatch(ruler, "([%S]+)") do | ||
if (x ~= nil and mass(formula) > mass(x)) then | if (x ~= nil and mass(formula) > mass(x)) then | ||
Line 78: | Line 79: | ||
---Check Fragments--- | ---Check Fragments--- | ||
for i,v in pairs(fragments) do | for i,v in pairs(fragments) do | ||
− | if ( | + | if (v == nil) then print("<big>Fragment "..i.." does not exist.</big>") end |
for j,w in pairs(v) do | for j,w in pairs(v) do | ||
− | if ( | + | if (w == nil) then print("<big>Fragment "..j.." does not exist.</big>") end |
end | end | ||
end | end |
Revision as of 00:14, 14 May 2009
No 'ION INFO' line in the form &&(formula)&&(formula)&&...&&
MassBank/Matrix | 64 CHClONSP |
64 CHClONSP |
|