Sandbox

From Metabolomics.JP
(Difference between revisions)
Jump to: navigation, search
m
m
Line 1: Line 1:
{| class ="wikitable"
+
{{MassBank/Matrix|data=
{{#replace:
+
&&C7H14NO3&&C7H11O3&&C5H8NO2&&C4H8NO2&&C7H13&&C4H10NO&&C6H11&&C6H7&&C4H7O&&C5H9&&C3H8N&&C4H7&&
{{#lua:
+
C7H14NO3:C7H11O3
  function atomicNum(atom, str)
+
C7H14NO3:C4H8NO2 C4H10NO C3H8N
    if (str == "") then return 0; end
+
C4H10NO: C3H8NP
    if (str == atom) then return 1; end
+
}}
    return tonumber(string.sub(str,2));
+
  end
+
  
  function mass(str)
 
    local c,h,n,o=string.match(str,"(C?[1-9]?[0-9]?)(H?[1-9]?[0-9]?)(N?[1-9]?[0-9]?)(O?[1-9]?[0-9]?)");
 
    c = atomicNum("C", c) * 12;
 
    h = atomicNum("H", h);
 
    n = atomicNum("N", n) * 14;
 
    o = atomicNum("O", o) * 16;
 
    return c + h + n + o;
 
  end
 
 
  function diff(str1, str2)
 
    ---computes str1 - str2. If negative, returns nil.---
 
    local c1,h1,n1,o1=string.match(str1,"(C?[1-9]?[0-9]?)(H?[1-9]?[0-9]?)(N?[1-9]?[0-9]?)(O?[1-9]?[0-9]?)");
 
    local c2,h2,n2,o2=string.match(str2,"(C?[1-9]?[0-9]?)(H?[1-9]?[0-9]?)(N?[1-9]?[0-9]?)(O?[1-9]?[0-9]?)");
 
    c1 = atomicNum("C", c1);
 
    h1 = atomicNum("H", h1);
 
    n1 = atomicNum("N", n1);
 
    o1 = atomicNum("O", o1);
 
    c2 = atomicNum("C", c2);
 
    h2 = atomicNum("H", h2);
 
    n2 = atomicNum("N", n2);
 
    o2 = atomicNum("O", o2);
 
    if (c2 > c1) then return nil; else c1 = c1 - c2; end
 
    if (h2 > h1) then return nil; else h1 = h1 - h2; end
 
    if (n2 > n1) then return nil; else n1 = n1 - n2; end
 
    if (o2 > o1) then return nil; else o1 = o1 - o2; end
 
    local ret = "";
 
    if (c1 > 1) then ret = ret .. "C" .. c1;
 
      else if (c1 == 1) then ret = ret .. "C"; end end
 
    if (h1 > 1) then ret = ret .. "H" .. h1;
 
      else if (h1 == 1) then ret = ret .. "H"; end end
 
    if (n1 > 1) then ret = ret .. "N" .. n1;
 
      else if (n1 == 1) then ret = ret .. "N"; end end
 
    if (o1 > 1) then ret = ret .. "O" .. o1;
 
      else if (o1 == 1) then ret = ret .. "O"; end end
 
    return ret;
 
  end
 
 
  local ruler;
 
  local fragments = {};
 
  local x, y;
 
  for line in stdin:gmatch("[%S ,]+") do
 
    if (string.find(line, "=") == nil) then ruler = line;
 
    else ---register fragments---
 
      head, tail = string.match(line, "([CHNO0-9]+) *= *([CHNO0-9 ]+)");
 
      y = {};
 
      for x in string.gmatch(tail,"[CHNO0-9]+") do
 
        y[x] = x;
 
      end
 
      fragments[head] = y;
 
    end
 
  end
 
  local axis  = {};
 
  local i = 1;
 
  for formula in string.gmatch(ruler, "([%S]+)") do
 
    axis[i] = formula;
 
    i = i + 1;
 
  end
 
  print("#-\n");
 
  print("## sample \n");
 
  for i=1, table.getn(axis) do
 
    print("#style='text-align:right'# " .. mass(axis[i]) .. "<br/>" .. axis[i]);
 
  end
 
  for i=1, table.getn(axis) do
 
    print("#-\n");
 
    print("#style='text-align:right'# " .. mass(axis[i]) .. "<br/>" .. axis[i]);
 
    for j=1, table.getn(axis) do
 
      if (j < i) then
 
        s = diff(axis[j],axis[i]);
 
        if (s == nil)
 
          then print('#style="background-color:gray"# ');
 
        else
 
          if (fragments[axis[j]] ~= nil and fragments[axis[j]][axis[i]] ~= nil) then
 
            print('#style="background-color:orange"# ' .. s);
 
          else print('## ' .. s); end
 
        end
 
      else print('#style="background-color:white"# ');
 
      end
 
    end
 
    print("\n");
 
  end
 
|
 
C7H14NO3 C7H11O3 C5H8NO2 C4H8NO2 C7H13 C4H10NO C6H11 C6H7 C4H7O C5H9 C3H8N C4H7
 
C7H14NO3 = C7H11O3 C4H8NO2 C4H10NO C3H8N
 
C4H10NO = C3H8N
 
}}
 
|#|{{#bar:}}}}
 
|}
 
  
 
<!----
 
<!----

Revision as of 01:53, 14 May 2009

General Index

All Molecules
KOX PR PBX COX

Ion Frequency Prec.-Product Neutral Loss Help





150px

Contents

Top 10 Similar Molecules of


Links

Annotations

Precursor Product Comments
(0) (0) C7H14NO3:C7H11O3

C7H14NO3:C4H8NO2 C4H10NO C3H8N C4H10NO: C3H8NP

Precursor-Product Relationship

Sandbox 160
C7H14NO3
143
C7H11O3
114
C5H8NO2
102
C4H8NO2
97
C7H13
88
C4H10NO
83
C6H11
79
C6H7
71
C4H7O
69
C5H9
58
C3H8N
55
C4H7
160 C7H14NO3


143 C7H11O3 H3N


114 C5H8NO2 C2H6O


102 C4H8NO2 C3H6O C


97 C7H13 HNO3


88 C4H10NO C3H4O2


83 C6H11 CH3NO3 CO3 CH2


79 C6H7 CH7NO3 CH4O3 CH6 H4


71 C4H7O C3H7NO2 C3H4O2 CHNO HNO H3N


69 C5H9 C2H5NO3 C2H2O3 C2H4 CH2


58 C3H8N C4H6O3 C2O2 CO2 CH2O


55 C4H7 C3H7NO3 C3H4O3 CHNO2 HNO2 C3H6 H3NO C2H4 C2 O CH2



(pos/neg)<<First Page   (pos/neg)<Previous Page

Next Page>(pos/neg)   Last Page>>(pos/neg)


Personal tools
Namespaces

Variants
Actions
Navigation
metabolites
Toolbox