Template:LBGA/GroupTable: Difference between revisions

mNo edit summary
Line 6: Line 6:


  function printTable(T, title)  
  function printTable(T, title)  
   print('==' .. title .. ' Sugar==\n{& class="wikitable sortable"\n! ID && Polar group<br/><small>Gro: glycerol </small> && Sugar group<br/><small>Glc: Glucose Gul: gulose</small>')
   print('==' .. title .. '<small>including inositol</small>==\n{& class="wikitable sortable"\n! ID && Polar group<br/><small>Gro: glycerol </small> && Sugar group<br/><small>Glc: Glucose Gul: gulose</small>')
   for k,v in ipairs(T) do
   for k,v in ipairs(T) do
     s = "\n&-\n& [[" .. v .. "]] && "
     s = "\n&-\n& [[" .. v .. "]] && "
Line 27: Line 27:
  end
  end


  printTable(S0, "No")
  printTable(S0, "No Sugar")
  printTable(S1, "One")
  printTable(S1, "One Sugar")
  printTable(S2, "Two")
  printTable(S2, "Two Sugars")
  printTable(S3, "Three or more")
  printTable(S3, "Three or more")
|
|

Revision as of 05:37, 10 July 2013

{{#lua:

local Tp = {}
local Ts = {}
local S0 = {}; S1 = {}; S2= {}; S3 = {}
function printTable(T, title) 
  print('==' .. title .. 'including inositol==\n{| class="wikitable sortable"\n! ID || Polar group
Gro: glycerol || Sugar group
Glc: Glucose Gul: gulose') for k,v in ipairs(T) do s = "\n|-\n| " .. v .. " || " if (Tp[v] ~= nil) then s = s .. Tp[v] end s = s .. " || " if (Ts[v] ~= nil) then s = s .. Ts[v] end print(s) end print("\n|}") end
for id, group, seq in stdin:gmatch("||([^\n]+)|([%w]+)Group=([^\n]+)") do
  if (string.match(group,"Polar")) then Tp[id] = seq end
  if (string.match(group,"Sugar")) then Ts[id] = seq end
  s = string.sub(id,7,7)
  if (s == "0") then table.insert(S0, id)
  elseif (s == "1") then table.insert(S1, id)
  elseif (s == "2") then table.insert(S2, id)
  else table.insert(S3, id) end
end
printTable(S0, "No Sugar")
printTable(S1, "One Sugar")
printTable(S2, "Two Sugars")
printTable(S3, "Three or more")

| SugarGroup=|PolarGroup= }}