Template:LBS/FormatSugar: Difference between revisions
m (New page: {{#lua: local seq = stdin:match("%S+"); local ret = ""; for p,q,r,s in string.gmatch(seq, "(%a+[%dMe]?)([?ab])([1-9])%-([1-9])") do if (string.match(p, "^Glc")) then ret = ...) |
mNo edit summary |
||
Line 1: | Line 1: | ||
{{#lua: | {{#lua: | ||
local seq = stdin:match("%S+"); | local seq = stdin:match("[%S()%[%]]+"); | ||
local ret = ""; | local ret = ""; | ||
for p,q,r,s in string.gmatch(seq, "(% | for o,p,q,r,s,t in string.gmatch(seq, "([%[%(]?)(%a+)([?ab%-])([1-9]?)%-?([1-9])([%]%)]?)") do | ||
if (o) then ret = ret .. o end | |||
if (string.match(p, "^Glc")) then | if (string.match(p, "^Glc")) then | ||
ret = ret .. '<span style="color:blue"><b>' .. p .. "</b></span>" | ret = ret .. '<span style="color:blue"><b>' .. p .. "</b></span>" | ||
Line 22: | Line 23: | ||
ret = ret .. r .. "-" .. s .. "</sub>" | ret = ret .. r .. "-" .. s .. "</sub>" | ||
if (t) then ret = ret .. t end | |||
end | end | ||
if (string.match(seq,"Cer$")) then | if (string.match(seq,"Cer$")) then | ||
Line 27: | Line 29: | ||
end | end | ||
print(ret) | print(ret) | ||
|{{{1|GlcNAcb1-3Manb1-4Glcb1-1Cer}}}}} | |{{{1|GlcNAcb1-3Galb1-3GalNAca1-4GalNAcb1-4(EtnP-6)GlcNAcb1-3Manb1-4Glcb1-1Cer}}}}} | ||
<!---- GlcNAc([1-6]Me)?|GalNAc([1-6]Me)?|GlcN|GalN|NeuAc([1-9]Me)?|NeuNH|NeuGc([1-9]Me)?|GlcA|GalA|Fuc([1-6]Me)?|Ara|Xyl([1-6]Me)?|Rha|KDN|Glc|Gal([1-6]Me)?|Man|Ins- ---> | <!---- GlcNAc([1-6]Me)?|GalNAc([1-6]Me)?|GlcN|GalN|NeuAc([1-9]Me)?|NeuNH|NeuGc([1-9]Me)?|GlcA|GalA|Fuc([1-6]Me)?|Ara|Xyl([1-6]Me)?|Rha|KDN|Glc|Gal([1-6]Me)?|Man|Ins- ---> |
Revision as of 20:07, 4 March 2011
{{#lua:
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 if (o) then ret = ret .. o end if (string.match(p, "^Glc")) then ret = ret .. '' .. p .. "" elseif (string.match(p, "^Gal")) then ret = ret .. '' .. p .. "" elseif (string.match(p, "^Man")) then ret = ret .. '' .. p .. "" elseif (string.match(p, "^Fuc")) then ret = ret .. '' .. p .. "" elseif (string.match(p, "^Neu")) then ret = ret .. '' .. p .. "" else ret = ret .. p end
if (q == "a") then ret = ret .. "α" elseif (q == "b") then ret = ret .. "β" else ret = ret .. "" .. q end
ret = ret .. r .. "-" .. s .. "" if (t) then ret = ret .. t end end if (string.match(seq,"Cer$")) then ret = ret .. "Cer" end print(ret)
|GlcNAcb1-3Galb1-3GalNAca1-4GalNAcb1-4(EtnP-6)GlcNAcb1-3Manb1-4Glcb1-1Cer}}