Template:Pathway/Metabolic

From Metabolomics.JP
< Template:Pathway(Difference between revisions)
Jump to: navigation, search
Line 4: Line 4:
 
{{#lua:
 
{{#lua:
 
   local list = {};
 
   local list = {};
  ---Set the first line
+
   local count = 0;
   local line = stdin:match("([^\n]+)");
+
  print(line);
+
  for v in string.gmatch(line, "(%d%d?)") do
+
    table.add(list,v);
+
  end
+
  ---From the second line, leave connected positions only
+
 
   for line in stdin:gmatch("([^\n]+)") do
 
   for line in stdin:gmatch("([^\n]+)") do
 +
    if (count==0) then
 +
      --- First line
 +
      for k, v in string.gmatch(line, "(%d%d?) (%d%d?) %d?%d? ?;") do
 +
        table.add(list,v);
 +
      end
 +
    else
 +
      --- Second and later lines
 
     print("\n" .. line .. "\n");
 
     print("\n" .. line .. "\n");
 
     if (string.sub(line,1,1) == 'R') then
 
     if (string.sub(line,1,1) == 'R') then
 
       line = string.sub(line,2);
 
       line = string.sub(line,2);
 +
      --- Create reverse mapping
 
       local map = {};
 
       local map = {};
 
       for k, v in string.gmatch(line, "(%d%d?) (%d%d?) %d?%d? ?;") do
 
       for k, v in string.gmatch(line, "(%d%d?) (%d%d?) %d?%d? ?;") do
Line 20: Line 22:
 
         print(v .. "-" .. k .. " ");
 
         print(v .. "-" .. k .. " ");
 
       end
 
       end
 +
      --- Leave only positions that can be mapped
 
       for k, v in pairs(list) do
 
       for k, v in pairs(list) do
 
         if (map[v] == nil) then
 
         if (map[v] == nil) then
Line 28: Line 31:
 
       end
 
       end
 
     else
 
     else
 +
      --- Create standard mapping
 
       local map = {};
 
       local map = {};
 
       for k, v in string.gmatch(line, "(%d%d?) (%d%d?) %d?%d? ?;") do
 
       for k, v in string.gmatch(line, "(%d%d?) (%d%d?) %d?%d? ?;") do
Line 33: Line 37:
 
         print(k .. "-" .. v .. " ");
 
         print(k .. "-" .. v .. " ");
 
       end
 
       end
 +
      --- Leave only positions that can be mapped
 
       for k, v in pairs(list) do
 
       for k, v in pairs(list) do
 
         if (map[v] == nil) then
 
         if (map[v] == nil) then
Line 40: Line 45:
 
         end
 
         end
 
       end
 
       end
 +
    end
 
     end
 
     end
 
   end
 
   end

Revision as of 06:45, 16 March 2009



Personal tools
Namespaces

Variants
Actions
Navigation
metabolites
Toolbox