Template:LBS/FormatSugar: Difference between revisions

mNo edit summary
(Replaced content with "{{#invoke:LBS|FormatSugar||{{{1|GlcNAca/b1-3Xyla-4Galb1-3GalNAca1-4(NeuAc?1-2NeuGc4Mea1-3)GalNAcb1-4(EtnP-6)GlcNAcb1-3Manb1-4Glcb1-1Cer}}}}}")
Tag: Replaced
 
(12 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{#lua:
{{#invoke:LBS|FormatSugar||{{{1|GlcNAca/b1-3Xyla-4Galb1-3GalNAca1-4(NeuAc?1-2NeuGc4Mea1-3)GalNAcb1-4(EtnP-6)GlcNAcb1-3Manb1-4Glcb1-1Cer}}}}}
  local seq = stdin:match("[%S()%[%]]+");
  local ret = "";
  for o,p,q,r,s,t in string.gmatch(seq, "([%[%(]?)(%a+)([?ab%-])([1-9]?)%-?([1-9])([%]%)]?)") do
    ---Process ( ---
    if (o) then ret = ret .. o end
    ---Process sugar name---
    if (string.match(p, "^Glc")) then
      ret = ret .. '<span style="color:blue"><b>' .. p .. "</b></span>"
    elseif (string.match(p, "^Gal")) then
      ret = ret .. '<span style="color:gold"><b>' .. p .. "</b></span>"
    elseif (string.match(p, "^Man")) then
      ret = ret .. '<span style="color:green"><b>' .. p .. "</b></span>"
    elseif (string.match(p, "^Fuc")) then
      ret = ret .. '<span style="color:red"><b>' .. p .. "</b></span>"
    elseif (string.match(p, "^Neu")) then
      ret = ret .. '<span style="color:pink"><b>' .. p .. "</b></span>"
    else
      ret = ret .. '<b>' .. p .. '</b>'
    end
    ---Process alpha or beta---
    if (q == "a") then ret = ret .. "<sub>&alpha;"
    elseif (q == "b") then ret = ret .. "<sub>&beta;"
    elseif (q == "-") then ret = ret .. "<sub>*"
    else ret = ret .. "<sub>" .. q end
    ---Process bond position---
    ret = ret .. r .. "-" .. s .. "</sub>"
    if (t) then ret = ret .. t end
  end
  if (string.match(seq,"Cer$")) then
      ret = ret .. "<b>Cer</b>"
  end
  print(ret)
|{{{1|GlcNAcb1-3Galb1-3GalNAca1-4GalNAcb1-4(EtnP-6)GlcNAcb1-3Manb1-4Glcb1-1Cer}}}}}

Latest revision as of 07:28, 1 February 2023

GlcNAcα/β1-3Xylα-4Galβ1-3GalNAcα1-4(NeuAc?1-2NeuGc4Meα1-3)GalNAcβ1-4(EtnP-6)GlcNAcβ1-3Manβ1-4Glcβ1-1Cer