Module:LBS: Difference between revisions

(Created page with "local getArgs = require('Module:Arguments').getArgs; local lbs = {}; function lbs.FormatSugar( frame ) local args = getArgs(frame); local arg; if nil == args[1] then arg = "GlcNAca/b1-3Xyla-4Galb1-3GalNAca1-4(NeuAc?1-2NeuGc4Mea1-3)GalNAcb1-4(EtnP-6)GlcNAcb1-3Manb1-4Glcb1-1Cer"; else arg = args[1]; end seq = arg:match("[%S()%[%], ]+"); local ret = ""; seq = string.gsub(seq, "a/b([1-9?]?-[1-9/?]*)", "<sub>α/β%1</sub>"); seq = string.g...")
 
No edit summary
 
Line 1: Line 1:
local getArgs = require('Module:Arguments').getArgs;
local getArgs = require('Module:Arguments').getArgs;
local defArgs = require('Module:Arguments').defaultArgs;
local lbs = {};
local lbs = {};


function lbs.FormatSugar( frame )
function lbs.FormatSugar( frame )
   local args = getArgs(frame);
   local args = defArgs(getArgs(frame), 1, "GlcNAca/b1-3Xyla-4Galb1-3GalNAca1-4(NeuAc?1-2NeuGc4Mea1-3)GalNAcb1-4(EtnP-6)GlcNAcb1-3Manb1-4Glcb1-1Cer");
  local arg;
   local arg = args[1];
  if nil == args[1] then
    arg = "GlcNAca/b1-3Xyla-4Galb1-3GalNAca1-4(NeuAc?1-2NeuGc4Mea1-3)GalNAcb1-4(EtnP-6)GlcNAcb1-3Manb1-4Glcb1-1Cer";
   else
    arg = args[1];
  end


   seq = arg:match("[%S()%[%], ]+");
   seq = arg:match("[%S()%[%], ]+");

Latest revision as of 04:18, 26 January 2023

Documentation for this module may be created at Module:LBS/doc

local getArgs = require('Module:Arguments').getArgs;
local defArgs = require('Module:Arguments').defaultArgs;
local lbs = {};

function lbs.FormatSugar( frame )
  local args = defArgs(getArgs(frame), 1, "GlcNAca/b1-3Xyla-4Galb1-3GalNAca1-4(NeuAc?1-2NeuGc4Mea1-3)GalNAcb1-4(EtnP-6)GlcNAcb1-3Manb1-4Glcb1-1Cer");
  local arg = args[1];

  seq = arg:match("[%S()%[%], ]+");
  local ret = "";
  seq = string.gsub(seq, "a/b([1-9?]?-[1-9/?]*)", "<sub>&alpha;/&beta;%1</sub>");
  seq = string.gsub(seq, "a([1-9?]?-[1-9/?]*)", "<sub>&alpha;%1</sub>");
  seq = string.gsub(seq, "b([1-9?]?-[1-9/?]*)", "<sub>&beta;%1</sub>");
  seq = string.gsub(seq, "?([1-9?]?-[1-9/?]*)", "<sub>?%1</sub>");
  seq = string.gsub(seq, "Cer$", "<b>Cer</b>");
  seq = string.gsub(seq, "(Gal[NAcH234Me]*)", '<span style="color:Gold"><b>%1</b></span>');
  seq = string.gsub(seq, "(Glc[NAcH2]*)", '<span style="color:Blue"><b>%1</b></span>');
  seq = string.gsub(seq, "(Man[A]*)", '<span style="color:Green"><b>%1</b></span>');
  seq = string.gsub(seq, "(Rha)", '<span style="color:Green"><b>%1</b></span>');
  seq = string.gsub(seq, "(Fuc[A]*)", '<span style="color:Red"><b>%1</b></span>');
  seq = string.gsub(seq, "(NeuAc[Me489]*)", '<span style="color:Purple"><b>%1</b></span>');
  seq = string.gsub(seq, "(NeuGc[Me489]*)", '<span style="color:Gray"><b>%1</b></span>');
  seq = string.gsub(seq, "(Xyl)", '<span style="color:DarkOrange"><b>%1</b></span>');
  seq = string.gsub(seq, "(Ara)", '<span style="color:DarkOrange"><b>%1</b></span>');
  seq = string.gsub(seq, "(KDN)", '<span style="color:Green"><b>%1</b></span>');

  return seq;
end

return lbs;