File: sam_seq.lua

package info (click to toggle)
highlight 4.10-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,556 kB
  • sloc: cpp: 27,579; makefile: 411; sh: 341; ansic: 264; php: 236; python: 217; ruby: 132; perl: 61; tcl: 1
file content (53 lines) | stat: -rw-r--r-- 1,386 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Description="Generate coloured bio sequences in Sequence Alignment Maps"

-- optional parameter: syntax description
function syntaxUpdate(desc)

  t = {}
  t["A"] = "144;238;144" --144, 238, 144
  t["T"] = "240;128;128" --240, 128, 128
  t["C"] = "173;216;230" --173, 216, 230
  t["G"] = "255;160;122" --255, 160, 122

  function Decorate(token, state, kwclass)

    if ( (HL_OUTPUT == HL_FORMAT_HTML or HL_OUTPUT == HL_FORMAT_XHTML or HL_OUTPUT == HL_FORMAT_TRUECOLOR)
        and #token > 63 and state == HL_KEYWORD and not string.match(token,"[^ATCG]") ) then

      retVal = ""
      for c in token:gmatch"." do
        if (HL_OUTPUT == HL_FORMAT_HTML or HL_OUTPUT == HL_FORMAT_XHTML) then
          retVal = retVal .. "<span class='elem_".. c .. "'>".. c .. "</span>"
        elseif (HL_OUTPUT == HL_FORMAT_TRUECOLOR) then
          retVal = retVal .. "\27[48;2;".. t[c] .. "m".. c .. "\27m"
        end
      end
      return retVal
    end
  end
end

function themeUpdate(desc)
  if (HL_OUTPUT == HL_FORMAT_HTML or HL_OUTPUT == HL_FORMAT_XHTML) then

    Injections[#Injections+1]=[[
span.elem_A {
  background-color: lightgreen;
}
span.elem_T {
  background-color: lightcoral;
}
span.elem_C {
  background-color: lightblue;
}
span.elem_G {
  background-color: lightsalmon;
}
]]
  end
end

Plugins={
  { Type="lang", Chunk=syntaxUpdate },
  { Type="theme", Chunk=themeUpdate }
}