Template:JAS/MutationStat

Revision as of 17:01, 19 July 2012 by Editor (talk | contribs) (New page: {| class="wikitable" style="text-align:center" |+ The number of mutations <small>(E = exon; I = intron)</small> | {{#lua: function SortAndPrint(prefix, T) local idx = {} for k,v ...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
The number of mutations (E = exon; I = intron)

{{#lua:

 function SortAndPrint(prefix, T)
   local idx = {}
   for k,v in pairs(T) do
     table.insert(idx, k)
   end
   table.sort(idx)
   for i=1, #idx do
     print(prefix .. idx[i] .. "
" .. T[idx[i]] .."\n|") end end
 local exn = {}
 local inn = {}
 local etc = {}
 local total =0
 for gene in stdin:gmatch("&&(%w+)\n") do
   total = total+1
   local n = tonumber(string.match(gene,"(%d+)"))
   if (string.match(gene,"exon")) then
     if (exn[n] == nil) then exn[n] = 1 else exn[n] = exn[n]+1 end
   elseif (string.match(gene,"intron")) then
     if (inn[n] == nil) then inn[n] = 1 else inn[n] = inn[n]+1 end
   else
     if (etc[gene] == nil) then etc[gene] = 1 else etc[gene] = etc[gene]+1 end
   end
 end
 SortAndPrint("E", exn)
 SortAndPrint("I", inn)
 SortAndPrint("", etc)
 print("Total
" .. total)

}}