Doc:MassBank/PPR

From Metabolomics.JP
Revision as of 21:02, 3 June 2009 by Adm (Talk | contribs)

Jump to: navigation, search

How to Create Precursor-Product Page

Step1

まず以下のスロットにイオンのリストを半角スペース区切りで質量の降順に入力してください。 その後、Createボタンを押してください。

Step2

生成された文字列がページソースの基本です。

{{#lua:

 FORMULA_PAT = "(C?[1-9]?[0-9]?)(H?[1-9]?[0-9]?)(C?l?[2-9]?)(F?[2-9]?)(I?[2-9]?)(N?[1-9]?[0-9]?)(O?[1-9]?[0-9]?)(P?[2-9]?)(S?[2-9]?)";
 FORMULA_CHAR = "CHFINOPSl0-9";
 ATOM = {"C", "H", "Cl", "F", "I", "N", "O", "P", "S"};
 MASS = {12, 1, 35, 19, 127, 14, 16, 31, 32};
 function toFormula(t)
   for i,v in pairs(t) do
     if (v == "")
     then t[i] = 0
     else if (v == ATOM[i])
       then t[i] = 1
       else t[i]=tonumber(string.sub(v,1+string.len(ATOM[i])))
       end
     end
   end
   return t
 end
 function mass(str)
   local t = toFormula({string.match(str,FORMULA_PAT)})
   ret = 0;
   for i,v in pairs(t) do
     ret = ret + t[i] * MASS[i]
   end
   return ret;
 end
 function diff(str1, str2)
   ---computes str1 - str2. If negative, returns nil.---
   local t1 = toFormula({string.match(str1,FORMULA_PAT)})
   local t2 = toFormula({string.match(str2,FORMULA_PAT)})
   for i,_ in pairs(t1) do
     if (t1[i] < t2[i]) then return nil else t1[i] = t1[i]-t2[i] end
   end
   local ret = "";
   for i,v in pairs(t1) do
     if (v >= 1) then ret = ret .. ATOM[i] end
     if (v > 1) then ret = ret .. v end
   end
   return ret
 end
 local list = {}
 local x = nil
 for formula in stdin:gmatch("([%S]+)") do
   if (x ~= nil and mass(formula) > mass(x)) then
     print('Illegal ion order (check mass!): '..x..' < '..formula..'
') end x = formula table.insert(list, formula) end print("{{MassBank/Matrix|data=") print(table.concat(list,"&&")) for i=1,table.getn(list)-1 do label = false str = "&&"..list[i]..":" for j=i+1,table.getn(list) do if (diff(list[i],list[j])) then str = str .. " " ..list[j] label = true end end if (label) then print(str) end end |{{#get:Ions}}}} を、
Personal tools
Namespaces

Variants
Actions
Navigation
metabolites
Toolbox