Sandbox4
From Metabolomics.JP
(Difference between revisions)
Line 14: | Line 14: | ||
}} | }} | ||
+ | ===Family Distribution=== | ||
{{#lua: | {{#lua: | ||
T = {} | T = {} | ||
total = 0 | total = 0 | ||
+ | tfam = 0 | ||
for family, num in stdin:gmatch("([%a]+) ([%d]+)") do | for family, num in stdin:gmatch("([%a]+) ([%d]+)") do | ||
total = total + num | total = total + num | ||
− | if (T[family] == null) then T[family] = num else T[family] = T[family] + num end | + | if (T[family] == null) then T[family] = tonumber(num) tfam = tfam + 1 else T[family] = T[family] + num end |
end | end | ||
− | + | S = {} | |
− | + | I = {} | |
− | S = {} I = {} | + | |
for k,v in pairs(T) do | for k,v in pairs(T) do | ||
if (S[v] == null) then S[v] = { k } table.insert(I,v) else table.insert(S[v], k) end | if (S[v] == null) then S[v] = { k } table.insert(I,v) else table.insert(S[v], k) end | ||
end | end | ||
− | |||
− | |||
table.sort(I) | table.sort(I) | ||
− | + | print('{{{#bar:}} class="wikitable"') | |
− | T = S[ | + | print('{{#bar:}}-') |
− | + | print('! #metabolite {{#bar:}}{{#bar:}} Total '..total..' metabolites in '..tfam..' families') | |
− | + | for i=table.getn(I), 1, -1 do | |
− | + | print('{{#bar:}}-') | |
+ | T = S[I[i]] | ||
+ | print("{{#bar:}}"..I[i].."{{#bar:}}{{#bar:}}") | ||
+ | for j,w in pairs(T) do | ||
+ | print("[[:Category:"..w.."{{#bar:}}"..w.."]]; ") | ||
+ | end | ||
end | end | ||
− | + | print("{{#bar:}}}") | |
| {{#repeat:Stats/Family/GetFamilyName|1|{{#var:stat}} }} | | {{#repeat:Stats/Family/GetFamilyName|1|{{#var:stat}} }} | ||
+ | }} | ||
+ | |||
+ | ===Order Distribution=== | ||
+ | {{#lua: | ||
+ | T = {} | ||
+ | total = 0 | ||
+ | tord = 0 | ||
+ | for order, num in stdin:gmatch("([%a]+) ([%d]+)") do | ||
+ | total = total + num | ||
+ | if (T[order] == null) then T[order] = tonumber(num) tord = tord + 1 else T[order] = T[order] + num end | ||
+ | end | ||
+ | S = {} | ||
+ | I = {} | ||
+ | for k,v in pairs(T) do | ||
+ | if (S[v] == null) then S[v] = { k } table.insert(I,v) else table.insert(S[v], k) end | ||
+ | end | ||
+ | table.sort(I) | ||
+ | print('{{{#bar:}} class="wikitable"') | ||
+ | print('{{#bar:}}-') | ||
+ | print('! #metabolite {{#bar:}}{{#bar:}} Total '..total..' metabolites in '..tord..' orders') | ||
+ | for i=table.getn(I), 1, -1 do | ||
+ | print('{{#bar:}}-') | ||
+ | T = S[I[i]] | ||
+ | print("{{#bar:}}"..I[i].."{{#bar:}}{{#bar:}}") | ||
+ | print(table.concat(T, "; ")) | ||
+ | end | ||
+ | print("{{#bar:}}}") | ||
+ | | {{#repeat:Stats/Family/GetOrderName|1|{{#var:stat}} }} | ||
}} | }} |
Revision as of 22:52, 10 December 2009