Doc:MassBank/PPR
From Metabolomics.JP
(Difference between revisions)
m |
m |
||
| Line 1: | Line 1: | ||
=How to Create Precursor-Product Page= | =How to Create Precursor-Product Page= | ||
| + | ===Step1=== | ||
まず以下のスロットにイオンのリストを半角スペース区切りで質量の降順に入力してください。 | まず以下のスロットにイオンのリストを半角スペース区切りで質量の降順に入力してください。 | ||
| + | その後、Createボタンを押してください。 | ||
{{#formtag:form|method="post" action="/wiki/Doc:MassBank/PPR"| | {{#formtag:form|method="post" action="/wiki/Doc:MassBank/PPR"| | ||
| Line 10: | Line 12: | ||
}} | }} | ||
| + | ===Step2=== | ||
| + | 生成された文字列 | ||
{{#lua: | {{#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('<span style="color:red">Illegal ion order (check mass!): '..x..' < '..formula..'</span><br/>') | ||
| + | end | ||
| + | x = formula | ||
| + | table.insert(list, formula) | ||
| + | end | ||
| + | |||
| + | |{{#get:Ions}}}} | ||
| + | |||
| + | を、 | ||
Revision as of 20:52, 3 June 2009
How to Create Precursor-Product Page
Step1
まず以下のスロットにイオンのリストを半角スペース区切りで質量の降順に入力してください。 その後、Createボタンを押してください。
Step2
生成された文字列
を、