示例#1
0
文件: options.py 项目: yohell/msaview
 def parse_str(self, string):
     try:
         return Color.from_str(string.strip())
     except:
         try:
             return presets.get_value('color:' + string.strip())
         except:
             pass
         raise ValueError('must be a color, such as navajowhite or #15a5ff')
示例#2
0
 def to_markup(self, color=presets.get_value('color:black')):
     """Return markup appropriate for a tooltip.
     
     color can optionally be applied to a pertinent segment of the returned markup.
     
     """
     template = "<span foreground=%r weight='bold'>%s</span> %s-%s"
     markup = template % (color.to_str(), self.name.replace('<', '&lt;'), self.region.start, self.region.start + self.region.length)
     if self.description:
         markup += " (%s)" % self.description
     return markup
示例#3
0
文件: color.py 项目: yohell/msaview
class RegexColormapSetting(ColormapSetting):
    element_setting_type = RegexColorMappingSetting
    colormap_class = RegexColormap.from_mappings

presets.register_type('colormap', ColormapSetting)
presets.register_type('colormap.regex', RegexColormapSetting)
presets.add_builtin('color:clustalx_blue', Color(25, 127, 229)) 
presets.add_builtin('color:clustalx_cyan', Color(25, 178, 178))
presets.add_builtin('color:clustalx_green', Color(25, 204, 25))
presets.add_builtin('color:clustalx_magenta', Color(204, 76, 204))
presets.add_builtin('color:clustalx_orange', Color(229, 153, 76))
presets.add_builtin('color:clustalx_pink', Color(229, 127, 127))
presets.add_builtin('color:clustalx_red', Color(229, 51, 25))
presets.add_builtin('color:clustalx_yellow', Color(204, 204, 0))
cm = ResidueColormap(VILMAFCW=presets.get_value('color:clustalx_blue'), 
                     HY=presets.get_value('color:clustalx_cyan'),
                     TSNQ=presets.get_value('color:clustalx_green'),
                     DE=presets.get_value('color:clustalx_magenta'),
                     G=presets.get_value('color:clustalx_orange'),
                     KR=presets.get_value('color:clustalx_red'),
                     P=presets.get_value('color:clustalx_yellow'))
presets.add_builtin('colormap:clustalx', cm)

presets.add_builtin('colormap.regex:highlight_unaligned', 
    RegexColormap.from_mappings([
        (r'[.-]+', Color(1.0, 1.0, 1.0)),
        (r'(?<!-)-+(?!-)', Color(25, 127, 229)),
        (r'^[.-]+|[.-]+$', Color(229, 51, 25)),
        (r'[a-z]+', Color.from_str('#1919dddd1919')), #Color(25, 204, 25)),
        (r'[xX]+', Color(.7, 0, .9))]))