Back to index

python-biopython  1.60
Public Member Functions | Public Attributes | Private Member Functions
Bio.Graphics.BasicChromosome.AnnotatedChromosomeSegment Class Reference
Inheritance diagram for Bio.Graphics.BasicChromosome.AnnotatedChromosomeSegment:
Inheritance graph
[legend]
Collaboration diagram for Bio.Graphics.BasicChromosome.AnnotatedChromosomeSegment:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def draw
def draw
def add
def remove

Public Attributes

 bp_length
 features
 default_feature_color
 name_qualifiers
 label_sep_percent
 start_x_position
 end_x_position
 start_y_position
 end_y_position
 scale
 fill_color
 label
 label_size
 chr_percent

Private Member Functions

def _overdraw_subcomponents

Detailed Description

Definition at line 577 of file BasicChromosome.py.


Constructor & Destructor Documentation

def Bio.Graphics.BasicChromosome.AnnotatedChromosomeSegment.__init__ (   self,
  bp_length,
  features,
  default_feature_color = colors.blue,
  name_qualifiers = ['gene',
  label,
  name,
  locus_tag,
  product 
)
Like the ChromosomeSegment, but accepts a list of features.

The features can either be SeqFeature objects, or tuples of five
values: start (int), end (int), strand (+1, -1, O or None), label
(string) and a ReportLab color.

Note we require 0 <= start <= end <= bp_length, and within the vertical
space allocated to this segmenet lines will be places according to the
start/end coordindates (starting from the top).

Positive stand features are drawn on the right, negative on the left,
otherwise all the way across.

We recommend using consisent units for all the segment's scale values
(e.g. their length in base pairs).

When providing features as SeqFeature objects, the default color
is used, unless the feature's qualifiers include an Artemis colour
string (functionality also in GenomeDiagram). The caption also follows
the GenomeDiagram approach and takes the first qualifier from the list
specified in name_qualifiers.

Note additional attribute label_sep_percent controls the percentage of
area that the chromosome segment takes up, by default half of the
chr_percent attribute (half of 25%, thus 12.5%)

Definition at line 580 of file BasicChromosome.py.

00580 
00581                  name_qualifiers = ['gene', 'label', 'name', 'locus_tag', 'product']):
00582         """Like the ChromosomeSegment, but accepts a list of features.
00583         
00584         The features can either be SeqFeature objects, or tuples of five
00585         values: start (int), end (int), strand (+1, -1, O or None), label
00586         (string) and a ReportLab color.
00587         
00588         Note we require 0 <= start <= end <= bp_length, and within the vertical
00589         space allocated to this segmenet lines will be places according to the
00590         start/end coordindates (starting from the top).
00591         
00592         Positive stand features are drawn on the right, negative on the left,
00593         otherwise all the way across.
00594         
00595         We recommend using consisent units for all the segment's scale values
00596         (e.g. their length in base pairs).
00597         
00598         When providing features as SeqFeature objects, the default color
00599         is used, unless the feature's qualifiers include an Artemis colour
00600         string (functionality also in GenomeDiagram). The caption also follows
00601         the GenomeDiagram approach and takes the first qualifier from the list
00602         specified in name_qualifiers.
00603 
00604         Note additional attribute label_sep_percent controls the percentage of
00605         area that the chromosome segment takes up, by default half of the
00606         chr_percent attribute (half of 25%, thus 12.5%)
00607 
00608         """
00609         ChromosomeSegment.__init__(self)
00610         self.bp_length = bp_length
00611         self.features = features
00612         self.default_feature_color = default_feature_color
00613         self.name_qualifiers = name_qualifiers
00614         self.label_sep_percent = self.chr_percent * 0.5

Here is the caller graph for this function:


Member Function Documentation

Draw any annotated features on the chromosome segment.

Assumes _draw_segment already called to fill out the basic shape,
and assmes that uses the same boundaries.

Reimplemented from Bio.Graphics.BasicChromosome.ChromosomeSegment.

Definition at line 615 of file BasicChromosome.py.

00615 
00616     def _overdraw_subcomponents(self, cur_drawing):
00617         """Draw any annotated features on the chromosome segment.
00618         
00619         Assumes _draw_segment already called to fill out the basic shape,
00620         and assmes that uses the same boundaries.
00621         """
00622         # set the coordinates of the segment -- it'll take up the MIDDLE part
00623         # of the space we have.
00624         segment_y = self.end_y_position
00625         segment_width = (self.end_x_position - self.start_x_position) \
00626                         * self.chr_percent
00627         label_sep = (self.end_x_position - self.start_x_position) \
00628                         * self.label_sep_percent
00629         segment_height = self.start_y_position - self.end_y_position
00630         segment_x = self.start_x_position \
00631                   + 0.5 * (self.end_x_position - self.start_x_position - segment_width)
00632         
00633         left_labels = []
00634         right_labels = []
00635         for f in self.features:
00636             try:
00637                 #Assume SeqFeature objects
00638                 start = f.location.start
00639                 end = f.location.end
00640                 strand = f.strand
00641                 try:
00642                     #Mimic the GenomeDiagram code
00643                     color = _color_trans.artemis_color( \
00644                                              f.qualifiers['color'][0])
00645                 except:
00646                     color = self.default_feature_color
00647                 name = ""
00648                 for qualifier in self.name_qualifiers:            
00649                     if qualifier in f.qualifiers:
00650                         name = f.qualifiers[qualifier][0]
00651                         break
00652             except AttributeError:
00653                 #Assume tuple of ints, string, and color
00654                 start, end, strand, name, color = f
00655             assert 0 <= start <= end <= self.bp_length
00656             if strand == +1 :
00657                 #Right side only
00658                 x = segment_x + segment_width * 0.6
00659                 w = segment_width * 0.4
00660             elif strand == -1:
00661                 #Left side only
00662                 x = segment_x
00663                 w = segment_width * 0.4
00664             else:
00665                 #Both or neighther - full width
00666                 x = segment_x
00667                 w = segment_width
00668             local_scale = segment_height / self.bp_length
00669             fill_rectangle = Rect(x, segment_y + segment_height - local_scale*start,
00670                                   w, local_scale*(start-end))
00671             fill_rectangle.fillColor = color
00672             fill_rectangle.strokeColor = color
00673             cur_drawing.add(fill_rectangle)
00674             if name:
00675                 value = (segment_y + segment_height - local_scale*start, color, name)
00676                 if strand == -1:
00677                     self._left_labels.append(value)
00678                 else:
00679                     self._right_labels.append(value)
00680 
            
def Bio.Graphics.BasicChromosome._ChromosomeComponent.add (   self,
  component 
) [inherited]
Add a sub_component to the list of components under this item.

Definition at line 63 of file BasicChromosome.py.

00063 
00064     def add(self, component):
00065         """Add a sub_component to the list of components under this item.
00066         """
00067         assert isinstance(component, _ChromosomeComponent), \
00068                "Expected a _ChromosomeComponent object, got %s" % component
00069         
00070         self._sub_components.append(component)

Here is the caller graph for this function:

Draw the specified component.

Definition at line 83 of file BasicChromosome.py.

00083 
00084     def draw(self):
00085         """Draw the specified component.
00086         """
        raise AssertionError("Subclasses must implement.")
def Bio.Graphics.BasicChromosome.ChromosomeSegment.draw (   self,
  cur_drawing 
) [inherited]
Draw a chromosome segment.

Before drawing, the range we are drawing in needs to be set.

Reimplemented in Bio.Graphics.BasicChromosome.SpacerSegment.

Definition at line 399 of file BasicChromosome.py.

00399 
00400     def draw(self, cur_drawing):
00401         """Draw a chromosome segment.
00402 
00403         Before drawing, the range we are drawing in needs to be set.
00404         """
00405         for position in (self.start_x_position, self.end_x_position,
00406                          self.start_y_position, self.end_y_position):
00407             assert position != -1, "Need to set drawing coordinates."
00408 
00409         self._draw_subcomponents(cur_drawing) #Anything behind
00410         self._draw_segment(cur_drawing)
00411         self._overdraw_subcomponents(cur_drawing) #Anything on top
00412         self._draw_label(cur_drawing)

Here is the call graph for this function:

def Bio.Graphics.BasicChromosome._ChromosomeComponent.remove (   self,
  component 
) [inherited]
Remove the specified component from the subcomponents.

Raises a ValueError if the component is not registered as a
sub_component.

Definition at line 71 of file BasicChromosome.py.

00071 
00072     def remove(self, component):
00073         """Remove the specified component from the subcomponents.
00074 
00075         Raises a ValueError if the component is not registered as a
00076         sub_component.
00077         """
00078         try:
00079             self._sub_components.remove(component)
00080         except ValueError:
00081             raise ValueError("Component %s not found in sub_components." %
00082                              component)


Member Data Documentation

Definition at line 609 of file BasicChromosome.py.

Definition at line 397 of file BasicChromosome.py.

Definition at line 611 of file BasicChromosome.py.

Definition at line 388 of file BasicChromosome.py.

Definition at line 390 of file BasicChromosome.py.

Definition at line 610 of file BasicChromosome.py.

Definition at line 394 of file BasicChromosome.py.

Definition at line 395 of file BasicChromosome.py.

Definition at line 613 of file BasicChromosome.py.

Definition at line 396 of file BasicChromosome.py.

Definition at line 612 of file BasicChromosome.py.

Definition at line 393 of file BasicChromosome.py.

Definition at line 387 of file BasicChromosome.py.

Definition at line 389 of file BasicChromosome.py.


The documentation for this class was generated from the following file: