Back to index

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

List of all members.

Public Member Functions

def __init__
def draw
def add
def remove
def draw

Public Attributes

 start_x_position
 end_x_position
 start_y_position
 end_y_position
 scale
 fill_color
 label
 label_size
 chr_percent

Private Member Functions

def _draw_subcomponents
def _draw_segment
def _overdraw_subcomponents
def _draw_label

Detailed Description

Draw a segment of a chromosome.

This class provides the important configurable functionality of drawing
a Chromosome. Each segment has some customization available here, or can
be subclassed to define additional functionality. Most of the interesting
drawing stuff is likely to happen at the ChromosomeSegment level.

Definition at line 350 of file BasicChromosome.py.


Constructor & Destructor Documentation

Initialize a ChromosomeSegment.

Attributes:
o start_x_position, end_x_position - Defines the x range we have
to draw things in.

o start_y_position, end_y_position - Defines the y range we have
to draw things in.

Configuration Attributes:

o scale - A scaling value for the component. By default this is
set at 1 (ie -- has the same scale as everything else). Higher
values give more size to the component, smaller values give less.

o fill_color - A color to fill in the segment with. Colors are
available in reportlab.lib.colors

o label - A label to place on the chromosome segment. This should
be a text string specifying what is to be included in the label.

o label_size - The size of the label.

o chr_percent - The percentage of area that the chromosome
segment takes up.

Reimplemented from Bio.Graphics.BasicChromosome._ChromosomeComponent.

Definition at line 358 of file BasicChromosome.py.

00358 
00359     def __init__(self):
00360         """Initialize a ChromosomeSegment.
00361 
00362         Attributes:
00363         o start_x_position, end_x_position - Defines the x range we have
00364         to draw things in.
00365 
00366         o start_y_position, end_y_position - Defines the y range we have
00367         to draw things in.
00368 
00369         Configuration Attributes:
00370 
00371         o scale - A scaling value for the component. By default this is
00372         set at 1 (ie -- has the same scale as everything else). Higher
00373         values give more size to the component, smaller values give less.
00374 
00375         o fill_color - A color to fill in the segment with. Colors are
00376         available in reportlab.lib.colors
00377 
00378         o label - A label to place on the chromosome segment. This should
00379         be a text string specifying what is to be included in the label.
00380 
00381         o label_size - The size of the label.
00382 
00383         o chr_percent - The percentage of area that the chromosome
00384         segment takes up.
00385         """
00386         _ChromosomeComponent.__init__(self)
00387 
00388         self.start_x_position = -1
00389         self.end_x_position = -1
00390         self.start_y_position = -1
00391         self.end_y_position = -1
00392 
00393         # --- attributes for configuration
00394         self.scale = 1
00395         self.fill_color = None
00396         self.label = None
00397         self.label_size = 6
00398         self.chr_percent = .25

Here is the caller graph for this function:


Member Function Documentation

def Bio.Graphics.BasicChromosome.ChromosomeSegment._draw_label (   self,
  cur_drawing 
) [private]
Add a label to the chromosome segment.

The label will be applied to the right of the segment.

This may be overlapped by any sub-feature labels on other segments!

Definition at line 459 of file BasicChromosome.py.

00459 
00460     def _draw_label(self, cur_drawing):
00461         """Add a label to the chromosome segment.
00462 
00463         The label will be applied to the right of the segment.
00464 
00465         This may be overlapped by any sub-feature labels on other segments!
00466         """
00467         if self.label is not None:
00468 
00469             label_x = 0.5 * (self.start_x_position + self.end_x_position) + \
00470                       (self.chr_percent + 0.05) * (self.end_x_position -
00471                                                    self.start_x_position)
00472             label_y = ((self.start_y_position - self.end_y_position) / 2 +
00473                        self.end_y_position)
00474 
00475             label_string = String(label_x, label_y, self.label)
00476             label_string.fontName = 'Helvetica'
00477             label_string.fontSize = self.label_size
00478 
00479             cur_drawing.add(label_string)

Here is the caller graph for this function:

def Bio.Graphics.BasicChromosome.ChromosomeSegment._draw_segment (   self,
  cur_drawing 
) [private]
Draw the current chromosome segment.

Reimplemented in Bio.Graphics.BasicChromosome.TelomereSegment.

Definition at line 421 of file BasicChromosome.py.

00421 
00422     def _draw_segment(self, cur_drawing):
00423         """Draw the current chromosome segment.
00424         """
00425         # set the coordinates of the segment -- it'll take up the MIDDLE part
00426         # of the space we have.
00427         segment_y = self.end_y_position
00428         segment_width = (self.end_x_position - self.start_x_position) \
00429                         * self.chr_percent
00430         segment_height = self.start_y_position - self.end_y_position
00431         segment_x = self.start_x_position \
00432                   + 0.5 * (self.end_x_position - self.start_x_position - segment_width)
00433         
00434         # first draw the sides of the segment
00435         right_line = Line(segment_x, segment_y,
00436                           segment_x, segment_y + segment_height)
00437         left_line = Line(segment_x + segment_width, segment_y,
00438                          segment_x + segment_width, segment_y + segment_height)
00439         
00440         cur_drawing.add(right_line)
00441         cur_drawing.add(left_line)
00442         
00443         # now draw the box, if it is filled in
00444         if self.fill_color is not None:
00445             fill_rectangle = Rect(segment_x, segment_y,
00446                                   segment_width, segment_height)
00447             fill_rectangle.fillColor = self.fill_color
00448             fill_rectangle.strokeColor = None
00449 
00450             cur_drawing.add(fill_rectangle)

Here is the caller graph for this function:

def Bio.Graphics.BasicChromosome.ChromosomeSegment._draw_subcomponents (   self,
  cur_drawing 
) [private]
Draw any subcomponents of the chromosome segment.

This should be overridden in derived classes if there are
subcomponents to be drawn.

Definition at line 413 of file BasicChromosome.py.

00413 
00414     def _draw_subcomponents(self, cur_drawing):
00415         """Draw any subcomponents of the chromosome segment.
00416 
00417         This should be overridden in derived classes if there are
00418         subcomponents to be drawn.
00419         """
00420         pass

Here is the caller graph for this function:

Draw any subcomponents of the chromosome segment over the main part.

This should be overridden in derived classes if there are
subcomponents to be drawn.

Reimplemented in Bio.Graphics.BasicChromosome.AnnotatedChromosomeSegment.

Definition at line 451 of file BasicChromosome.py.

00451 
00452     def _overdraw_subcomponents(self, cur_drawing):
00453         """Draw any subcomponents of the chromosome segment over the main part.
00454 
00455         This should be overridden in derived classes if there are
00456         subcomponents to be drawn.
00457         """
00458         pass

Here is the caller graph for this function:

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 
)
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 397 of file BasicChromosome.py.

Definition at line 388 of file BasicChromosome.py.

Definition at line 390 of file BasicChromosome.py.

Definition at line 394 of file BasicChromosome.py.

Definition at line 395 of file BasicChromosome.py.

Definition at line 396 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: