Skip to content

Commit

Permalink
Support optional fill color on chromosome diagrams
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjc committed Mar 18, 2013
1 parent f91c134 commit 53b3e6c
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions Bio/Graphics/BasicChromosome.py
Expand Up @@ -581,9 +581,9 @@ def __init__(self, bp_length, features,
name_qualifiers = ['gene', 'label', 'name', 'locus_tag', 'product']): name_qualifiers = ['gene', 'label', 'name', 'locus_tag', 'product']):
"""Like the ChromosomeSegment, but accepts a list of features. """Like the ChromosomeSegment, but accepts a list of features.
The features can either be SeqFeature objects, or tuples of five The features can either be SeqFeature objects, or tuples of values:
values: start (int), end (int), strand (+1, -1, O or None), label start (int), end (int), strand (+1, -1, O or None), label (string),
(string) and a ReportLab color. ReportLab color, and optional ReportLab fill color.
Note we require 0 <= start <= end <= bp_length, and within the vertical Note we require 0 <= start <= end <= bp_length, and within the vertical
space allocated to this segmenet lines will be places according to the space allocated to this segmenet lines will be places according to the
Expand Down Expand Up @@ -651,7 +651,11 @@ def _overdraw_subcomponents(self, cur_drawing):
break break
except AttributeError: except AttributeError:
#Assume tuple of ints, string, and color #Assume tuple of ints, string, and color
start, end, strand, name, color = f start, end, strand, name, color = f[:5]
if len(f) > 5:
fill_color = f[5]
else:
fill_color = color
assert 0 <= start <= end <= self.bp_length assert 0 <= start <= end <= self.bp_length
if strand == +1 : if strand == +1 :
#Right side only #Right side only
Expand All @@ -662,13 +666,13 @@ def _overdraw_subcomponents(self, cur_drawing):
x = segment_x x = segment_x
w = segment_width * 0.4 w = segment_width * 0.4
else: else:
#Both or neighther - full width #Both or neither - full width
x = segment_x x = segment_x
w = segment_width w = segment_width
local_scale = segment_height / self.bp_length local_scale = segment_height / self.bp_length
fill_rectangle = Rect(x, segment_y + segment_height - local_scale*start, fill_rectangle = Rect(x, segment_y + segment_height - local_scale*start,
w, local_scale*(start-end)) w, local_scale*(start-end))
fill_rectangle.fillColor = color fill_rectangle.fillColor = fill_color
fill_rectangle.strokeColor = color fill_rectangle.strokeColor = color
cur_drawing.add(fill_rectangle) cur_drawing.add(fill_rectangle)
if name: if name:
Expand Down

0 comments on commit 53b3e6c

Please sign in to comment.