Template:MassBank/Matrix
From Metabolomics.JP
(Difference between revisions)
m |
m |
||
| Line 142: | Line 142: | ||
=Similar Molecules= | =Similar Molecules= | ||
| + | {{#lua: | ||
| + | function intersection(x, y) | ||
| + | local z = {} | ||
| + | local i = 1 | ||
| + | local j = 1 | ||
| + | repeat | ||
| + | if (x[i] == y[j]) | ||
| + | then table.insert(z, x[i]) i = i + 1 j = j + 1 end | ||
| + | if (i > table.getn(x) or j > table.getn(y)) | ||
| + | then break end | ||
| + | if (x[i] > y[j]) then j = j + 1 end | ||
| + | if (x[i] < y[j]) then i = i + 1 end | ||
| + | if (i > table.getn(x) or j > table.getn(y)) | ||
| + | then break end | ||
| + | until false | ||
| + | return z | ||
| + | end | ||
| + | Name = {} | ||
| + | Ions = {} | ||
| + | Freq = {} | ||
| + | total = 0 | ||
| + | ---Register Ions--- | ||
| + | for id, frag in stdin:gmatch("&&([%a%d]+)&&([%S]+)") do | ||
| + | table.insert(Name, id) | ||
| + | T = {} | ||
| + | for f in string.gmatch(frag,"([%a%d]+)&&") do | ||
| + | table.insert(T, f) | ||
| + | if (Freq[f]) then Freq[f] = Freq[f] + 1 else Freq[f] = 1 total = total + 1 end | ||
| + | end | ||
| + | table.sort(T) | ||
| + | table.insert(Ions, T) | ||
| + | end | ||
| + | ---Compute Similarity--- | ||
| + | Sim = {} | ||
| + | Rank = {} | ||
| + | Score = {} | ||
| + | for i=2, table.getn(Ions) do | ||
| + | R = intersection(Ions[i], Ions[1]) | ||
| + | if (table.getn(R) > 0) then | ||
| + | inf = 0 | ||
| + | for _,v in pairs(R) do | ||
| + | inf = inf - math.log(Freq[v]/total) | ||
| + | end | ||
| + | inf = math.floor(inf*100) / 100 | ||
| + | table.insert(Score, inf) | ||
| + | Rank[inf] = i | ||
| + | end | ||
| + | end | ||
| + | table.sort(Score) | ||
| + | ---Output Similarity--- | ||
| + | for i=math.min(table.getn(Score),10), 1 do | ||
| + | print("# " .. Name[ Rank[Score] ].. " " ..Score[j]) | ||
| + | end | ||
| + | | | ||
| + | &&{{PAGENAME}}{{#car:{{{data}}}}} | ||
| + | {{#SearchLine:^&&_%&&|MassBank}} | ||
| + | }} | ||
Revision as of 03:20, 25 May 2009
| General Index | Ion Frequency | Prec.-Product | Neutral Loss | Help |
Contents |
Precursor-Product Relationship
No "ION INFO" line in the form &&(formula)&&(formula)&&...&&
| MassBank/Matrix | 210 CHClFIONSP |
| 210 CHClFIONSP |
|
Links
Similar Molecules
./lua: /tmp/mw_ex_lua_MIuowN:11: attempt to compare string with nil
Annotations
| Precursor | Product | Comments |
|---|---|---|
| CHClFINOPS |