Template:LBS/FormatSugar: Difference between revisions

mNo edit summary
No edit summary
Line 2: Line 2:
   local seq = stdin:match("[%S()%[%], ]+");
   local seq = stdin:match("[%S()%[%], ]+");
   local ret = "";
   local ret = "";
   seq = string.gsub(seq, "a/b([1-9?]%-[1-9/?]*)", "<sub>&alpha;/&beta;%1</sub>");
   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, "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, "b([1-9?]?-[1-9/?]*)", "<sub>&beta;%1</sub>");
   seq = string.gsub(seq, "?([1-9?]%-[1-9/?]*)", "<sub>?%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, "Cer$", "<b>Cer</b>");
   seq = string.gsub(seq, "(Gal[NAcH234Me]*)", '<span style="color:Gold"><b>%1</b></span>');
   seq = string.gsub(seq, "(Gal[NAcH234Me]*)", '<span style="color:Gold"><b>%1</b></span>');
Line 18: Line 18:
   seq = string.gsub(seq, "(KDN)", '<span style="color:Green"><b>%1</b></span>');
   seq = string.gsub(seq, "(KDN)", '<span style="color:Green"><b>%1</b></span>');
   print(seq);
   print(seq);
|{{{1|GlcNAcb1-3Xyla1-4Galb1-3GalNAca1-4(NeuAc?1-2NeuGc4Mea1-3)GalNAcb1-4(EtnP-6)GlcNAcb1-3Manb1-4Glcb1-1Cer}}}}}
|{{{1|GlcNAca/b1-3Xyla-4Galb1-3GalNAca1-4(NeuAc?1-2NeuGc4Mea1-3)GalNAcb1-4(EtnP-6)GlcNAcb1-3Manb1-4Glcb1-1Cer}}}}}

Revision as of 09:48, 20 November 2014

{{#lua:

 local seq = stdin:match("[%S()%[%], ]+");
 local ret = "";
 seq = string.gsub(seq, "a/b([1-9?]?-[1-9/?]*)", "α/β%1");
 seq = string.gsub(seq, "a([1-9?]?-[1-9/?]*)", "α%1");
 seq = string.gsub(seq, "b([1-9?]?-[1-9/?]*)", "β%1");
 seq = string.gsub(seq, "?([1-9?]?-[1-9/?]*)", "?%1");
 seq = string.gsub(seq, "Cer$", "Cer");
 seq = string.gsub(seq, "(Gal[NAcH234Me]*)", '%1');
 seq = string.gsub(seq, "(Glc[NAcH2]*)", '%1');
 seq = string.gsub(seq, "(Man[A]*)", '%1');
 seq = string.gsub(seq, "(Rha)", '%1');
 seq = string.gsub(seq, "(Fuc[A]*)", '%1');
 seq = string.gsub(seq, "(NeuAc[Me489]*)", '%1');
 seq = string.gsub(seq, "(NeuGc[Me489]*)", '%1');
 seq = string.gsub(seq, "(Xyl)", '%1');
 seq = string.gsub(seq, "(Ara)", '%1');
 seq = string.gsub(seq, "(KDN)", '%1');
 print(seq);

|GlcNAca/b1-3Xyla-4Galb1-3GalNAca1-4(NeuAc?1-2NeuGc4Mea1-3)GalNAcb1-4(EtnP-6)GlcNAcb1-3Manb1-4Glcb1-1Cer}}