Example #1
0
    def test_color_conversions(self):
        """Test color translations.
        """
        translator = ColorTranslator()

        # Does the translate method correctly convert the passed argument?
        assert translator.float1_color((0.5, 0.5, 0.5)) == translator.translate((0.5, 0.5, 0.5)), \
            "Did not correctly translate colour from floating point RGB tuple"
        assert translator.int255_color((1, 75, 240)) == translator.translate((1, 75, 240)), \
            "Did not correctly translate colour from integer RGB tuple"
        assert translator.artemis_color(7) == translator.translate(7), \
            "Did not correctly translate colour from Artemis colour scheme"
        assert translator.scheme_color(2) == translator.translate(2), \
            "Did not correctly translate colour from user-defined colour scheme"
Example #2
0
    def __init__(self,
                 parent=None,
                 feature_id=None,
                 feature=None,
                 color=colors.lightgreen,
                 label=0,
                 colour=None):
        """ __init__(self, parent=None, feature_id=None, feature=None,
                 color=colors.lightgreen, label=0)

            o parent    FeatureSet containing the feature

            o feature_id    Unique id for the feature

            o feature   Bio.SeqFeature object to be wrapped

            o color    color.Color Color to draw the feature (overridden
                       by backwards compatible argument with UK spelling,
                       colour).  Either argument is overridden if 'color'
                       is found in feature qualifiers

            o label     Boolean, 1 if the label should be shown
        """
        #Let the UK spelling (colour) override the USA spelling (color)
        if colour is not None:
            color = colour

        self._colortranslator = ColorTranslator()

        # Initialise attributes
        self.parent = parent
        self.id = feature_id
        self.color = color  # default color to draw the feature
        self._feature = None  # Bio.SeqFeature object to wrap
        self.hide = 0  # show by default
        self.sigil = 'BOX'
        self.arrowhead_length = 1.0  # 100% of the box height
        self.arrowshaft_height = 0.4  # 40% of the box height
        self.name_qualifiers = [
            'gene', 'label', 'name', 'locus_tag', 'product'
        ]
        self.label = label
        self.label_font = 'Helvetica'
        self.label_size = 6
        self.label_color = colors.black
        self.label_angle = 45
        self.label_position = 'start'

        if feature is not None:
            self.set_feature(feature)