Sandbox

From Metabolomics.JP
(Difference between revisions)
Jump to: navigation, search
m
m
Line 45: Line 45:
 
   end
 
   end
  
   local ruler = stdin:match("[%S ,]+");
+
   local ruler;
 +
  local fragments = {};
 +
  local x, y;
 +
  for line in stdin:gmatch("[%S ,]+") do
 +
    if (string.find(line, "=") == nil) then ruler = line;
 +
    else ---register fragments---
 +
      head, tail = string.match(line, "([CHNO0-9]+) *= *([CHNO0-9 ]+)");
 +
      y = {};
 +
      for x in string.gmatch(tail,"[CHNO0-9]+") do
 +
        y[x] = x;
 +
      end
 +
      fragments[head] = y;
 +
    end
 +
  end
 
   local axis  = {};
 
   local axis  = {};
 
   local i = 1;
 
   local i = 1;
Line 57: Line 70:
 
     print("#style='text-align:right'# " .. mass(axis[i]) .. "<br/>" .. axis[i]);
 
     print("#style='text-align:right'# " .. mass(axis[i]) .. "<br/>" .. axis[i]);
 
   end
 
   end
  local s;
 
 
   for i=1, table.getn(axis) do
 
   for i=1, table.getn(axis) do
 
     print("#-\n");
 
     print("#-\n");
Line 64: Line 76:
 
       if (j < i) then
 
       if (j < i) then
 
         s = diff(axis[j],axis[i]);
 
         s = diff(axis[j],axis[i]);
         if (s == nil) then print('#style="background-color:gray"# ');
+
         if (s == nil)
         else print("## " .. s);
+
          then print('#style="background-color:gray"# ');
 +
         else
 +
          if (fragments[axis[j]] ~= nil and fragments[axis[j]][axis[i]] ~= nil) then
 +
            print('#style="background-color:orange"# ' .. s);
 +
          else print('## ' .. s); end
 
         end
 
         end
 
       else print('#style="background-color:white"# ');
 
       else print('#style="background-color:white"# ');
Line 72: Line 88:
 
     print("\n");
 
     print("\n");
 
   end
 
   end
| C7H14NO3 C7H11O3 C5H8NO2 C4H8NO2 C7H13 C4H10NO C6H11 C6H7 C4H7O C5H9 C3H8N C4H7
+
|
 +
C7H14NO3 C7H11O3 C5H8NO2 C4H8NO2 C7H13 C4H10NO C6H11 C6H7 C4H7O C5H9 C3H8N C4H7
 +
C7H14NO3 = C7H11O3 C4H8NO2 C4H10NO C3H8N
 +
C4H10NO = C3H8N
 
}}
 
}}
 
|#|{{#bar:}}}}
 
|#|{{#bar:}}}}

Revision as of 12:00, 12 May 2009


Personal tools
Namespaces

Variants
Actions
Navigation
metabolites
Toolbox