# biopython/biopython

Colour/color support (mostly comment changes, but a couple of codes c…

`…hanges too)`
• Loading branch information...
1 parent 625f926 commit 9a188e048282eae6a222497cfa4a6295331822e1 peterjc committed Dec 11, 2008
 @@ -83,23 +83,28 @@ def page_sizes(size): def draw_box((x1, y1), (x2, y2), (x3, y3), (x4, y4), - colour=colors.lightgreen, border=None, color=None): + color=colors.lightgreen, border=None, colour=None): """ draw_box(self, (x1, y1), (x2, y2), (x3, y3), (x4, y4), color=colors.lightgreen) o (x1,y1)...(x4,y4) Co-ordinates for four corners of the box - o color The color for the box + o color /colour The color for the box + (colour takes priority over color) + + o border Border color for the box Returns a closed path object, beginning at (x1,y1) going round the four points in order, and filling with the passed color. """ - if color is None: + #Let the UK spelling (colour) override the USA spelling (color) + if colour is not None: color = colour + if color == colors.white and border is None: # Force black border on strokecolor = colors.black # white boxes with elif border is None: # undefined border, else - strokecolor = color # use fill colour + strokecolor = color # use fill color elif border is not None: strokecolor = border return Polygon([x1, y1, x2, y2, x3, y3, x4, y4],
 @@ -900,16 +900,16 @@ def draw_arc(self, inner_radius, outer_radius, startangle, endangle, o endangle Float angle subtended by end of arc at drawing centre - o color colors.Color object for arc + o color colors.Color object for arc (overridden by backwards + compatible argument with UK spelling, colour). Returns a Group object describing an arc corresponding to the passed values """ - + #Let the UK spelling (colour) override the USA spelling (color) if colour is not None: color = colour - if border is None: border = color # Calculate trig values for angle and coordinates
 @@ -64,15 +64,18 @@ def translate(self, color=None, colour=None): """ translate(self, color) o color Color defined as an int, a tuple of three ints 0->255 - or a tuple of three floats 0 -> 1 + or a tuple of three floats 0 -> 1 (overridden by + backwards compatible argument with UK spelling, colour). Returns a colors.Color object, determined semi-intelligently depending on the input values """ + #Let the UK spelling (colour) override the USA spelling (color) if colour is not None: color = colour + if color is None: - raise ValueError, "Passed colour must be a valid colour type" + raise ValueError, "Passed color (or colour) must be a valid color type" if type(color) == type(1): color = self.scheme_color(color) elif type(color) == type((1., 2., 3.)) and type(color[0]) == type(1.):
 @@ -105,11 +105,14 @@ def __init__(self, parent=None, feature_id=None, feature=None, o feature Bio.SeqFeature object to be wrapped - o color color.Color Color to draw the feature (overridden if - 'color' found in feature qualifiers + 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 @@ -229,23 +232,24 @@ def get_feature(self): """ return self._feature + def set_colour(self, colour): + """Backwards compatible variant of set_color(self, color) using UK spelling.""" + color = self._colortranslator.translate(colour) + self.color = color - def set_color(self, color, colour=None): + def set_color(self, color): """ set_color(self, color) o color The color to draw the feature - either a colors.Color - object, an RGB tuple of floats, or an integer - corresponding to colors in colors.txt - + object, an RGB tuple of floats, or an integer + corresponding to colors in colors.txt + Set the color in which the feature will be drawn """ - if colour is not None: - color = colour - + #TODO - Make this into the set method for a color property? color = self._colortranslator.translate(color) self.color = color - def __getattr__(self, name): """ __getattr__(self, name) -> various
 @@ -117,6 +117,9 @@ def add_feature(self, feature, **kwargs): id = self.next_id # get id number self.features[id] = Feature(self, id, feature) # add feature for key in kwargs: + if key == "colour" : + #Deal with "colour" as a special case by also mapping to "color" + setattr(self.features[id], "color", kwargs[key]) setattr(self.features[id], key, kwargs[key]) self.next_id += 1 # increment next id @@ -148,6 +151,12 @@ def set_all_features(self, attr, value): if getattr(feature, attr) != value: setattr(feature, attr, value) # set it to the passed value + #For backwards compatibility, we support both colour and color. + #As a quick hack, make "colour" set both "colour" and "color". + #if attr=="colour" : + # self.set_all_feature("color",value) + + def get_features(self, attribute=None, value=None, comparator=None): """ get_features(self, attribute=None, value=None, comparator=None) -> [Feature, Feature, ...]
 @@ -100,15 +100,18 @@ def __init__(self, id=None, data=None, name=None, style='bar', o style String describing the presentation style ('bar', 'line', 'heat') - o color colors.Color describing the color to draw all or the - 'high' (some styles) values + o color colors.Color describing the color to draw all or the + 'high' (some styles) values (overridden by backwards + compatible argument with UK spelling, colour). o altcolor colors.Color describing the color to draw the 'low' - values (some styles only) + values (some styles only) (overridden by backwards + compatible argument with UK spelling, colour). """ + + #Let the UK spelling (colour) override the USA spelling (color) if colour is not None: color = colour - if altcolour is not None: altcolor = altcolour
 @@ -82,7 +82,8 @@ def __init__(self, name=None): def new_graph(self, data, name=None, style='bar', color=colors.lightgreen, - altcolor=colors.darkseagreen, linewidth=1, centre=None, colour=None, altcolour=None): + altcolor=colors.darkseagreen, linewidth=1, centre=None, + colour=None, altcolour=None): """ new_graph(self, data, name=None, style='bar', color=colors.lightgreen, altcolor=colors.darkseagreen) @@ -94,11 +95,13 @@ def new_graph(self, data, name=None, style='bar', color=colors.lightgreen, will be drawn o color colors.Color describing the color to draw all or 'high' - (some styles) data - - o altcolor colors.Color describing the color to draw 'low' (some - styles) data + (some styles) data (overridden by backwards compatible + argument with UK spelling, colour). + o altcolor colors.Color describing the color to draw 'low' (some + styles) data (overridden by backwards compatible argument + with UK spelling, colour). + o linewidth Float describing linewidth for graph o centre Float setting the value at which the x-axis @@ -107,9 +110,9 @@ def new_graph(self, data, name=None, style='bar', color=colors.lightgreen, Add a GraphData object to the diagram (will be stored internally """ + #Let the UK spelling (colour) override the USA spelling (color) if colour is not None: color = colour - if altcolour is not None: altcolor = altcolour
 @@ -175,11 +175,15 @@ def __init__(self, name=None, height=1, hide=0, greytrack=0, rotate the grey track labels o greytrack_font_color colors.Color describing the color to draw - the grey track labels + the grey track labels (overridden by + backwards compatible argument with UK + spelling, colour). o scale Boolean, 1 if a scale is to be drawn on the track o scale_color colors.Color to draw the elemnts of the scale + (overridden by backwards compatible argument with UK + spelling, colour). o scale_font String describing the font to use for the scale labels @@ -207,14 +211,17 @@ def __init__(self, name=None, height=1, hide=0, greytrack=0, should be written over large ticks o scale_smalltick_labels Boolean describing whether position labels - should be written over small ticks o name String to help identify the track + should be written over small ticks + + o name String to help identify the track o height Relative height to draw the track o axis_labels Boolean describing whether the value labels should be placed on the Y axes """ - if greytrack_font_colour is not None: + #Let the UK spelling (colour) override the USA spelling (color) + if greytrack_font_color is not None: greytrack_font_color = greytrack_font_colour if scale_colour is not None: scale_color = scale_colour
 @@ -2,6 +2,19 @@ This file provides documentation for modules in Biopython that have been moved or deprecated in favor of other modules. This provides some quick and easy to find documentation about how to update your code to work again. +Bio.Graphics.GenomeDiagram and colour/color +=========================================== +GenomeDiagram originally used colour (UK spelling of color) for argument names. +For its integration into Biopython 1.50, this will support both colour and color, +to help people port existing scripts written for the standalone version of +GenomeDiagram. However, we do intend to deprecate and then eventually remove +support for colour in later releases of Biopython. + +Bio.AlignAce and Bio.MEME +========================= +As of Biopython 1.50, these modules are considered to be obsolete with the +introduction of Bio.Motif, and will be deprecated in a future release. + Numeric support =============== Following the release of 1.48, Numeric support in Biopython is discontinued.

#### 0 comments on commit `9a188e0`

Please sign in to comment.