Template:MassBank/Matrix

From Metabolomics.JP
(Difference between revisions)
Jump to: navigation, search
m
m
Line 65: Line 65:
 
   end
 
   end
  
   local ruler;
+
   local ruler = nil;
 
   local fragments = {};
 
   local fragments = {};
 
   local x, y;
 
   local x, y;
 
   ---Read Data---
 
   ---Read Data---
 
   for line in stdin:gmatch("[%S ,]+") do
 
   for line in stdin:gmatch("[%S ,]+") do
     if (string.find(line, ":") == nil)  
+
     if (string.find(line, "^(&&[A-Za-z0-9]+)+&&$") == nil)  
 
     then ruler = string.gsub(line, "&&", " ");
 
     then ruler = string.gsub(line, "&&", " ");
     else ---register fragments---
+
     else  
 +
      ---register fragments---
 
       head, tail = string.match(line, "([CHNOPSl0-9]+) *: *([CHNOPSl0-9 ]+)");
 
       head, tail = string.match(line, "([CHNOPSl0-9]+) *: *([CHNOPSl0-9 ]+)");
       y = {};
+
       if (head ~= nil and tail ~= nil) then
      for x in string.gmatch(tail,"[CHNOPSl0-9]+") do
+
        y = {};
        y[x] = x;
+
        for x in string.gmatch(tail,"[CHNOPSl0-9]+") do
 +
          y[x] = x;
 +
        end
 +
        fragments[head] = y;
 
       end
 
       end
      fragments[head] = y;
 
 
     end
 
     end
 
   end
 
   end
 
   ---Check Ruler---
 
   ---Check Ruler---
 +
  if (ruler == nil) then
 +
    print("No ion information in the form &&(formula)&&(formula)&&...&&");
 +
    exit();
 +
  end
 
   x = nil;
 
   x = nil;
 
   for formula in string.gmatch(ruler, "([%S]+)") do
 
   for formula in string.gmatch(ruler, "([%S]+)") do
Line 138: Line 145:
 
     if (string.find(line, ":") == nil) then
 
     if (string.find(line, ":") == nil) then
 
       ruler = line;
 
       ruler = line;
    else
 
      head = string.match(line, "([CHNOPSl0-9]+) *: *[CHNOPSl0-9 ]+");
 
      fgmt = fgmt .. " " .. head;
 
 
     end
 
     end
 
   end
 
   end

Revision as of 16:08, 13 May 2009

MassBank/Matrix 141
CHClNOPS
141
CHClNOPS



Personal tools
Namespaces

Variants
Actions
Navigation
metabolites
Toolbox