Back to index

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

List of all members.

Public Member Functions

def __init__
def draw
def add
def remove
def draw

Public Attributes

 page_size
 title_size
 output_format

Private Member Functions

def _draw_title
def _draw_legend

Private Attributes

 _legend_height

Detailed Description

Top level class for drawing chromosomes.

This class holds information about an organism and all of it's
chromosomes, and provides the top level object which could be used
for drawing a chromosome representation of an organism.

Chromosomes should be added and removed from the Organism via the
add and remove functions.

Definition at line 88 of file BasicChromosome.py.


Constructor & Destructor Documentation

def Bio.Graphics.BasicChromosome.Organism.__init__ (   self,
  output_format = 'pdf' 
)

Definition at line 98 of file BasicChromosome.py.

00098 
00099     def __init__(self, output_format = 'pdf'):
00100         _ChromosomeComponent.__init__(self)
00101 
00102         # customizable attributes
00103         self.page_size = letter
00104         self.title_size = 20
00105 
00106         #Do we need this given we don't draw a legend?
00107         #If so, should be a public API...
00108         self._legend_height = 0 # 2 * inch
00109 
00110         self.output_format = output_format

Here is the caller graph for this function:


Member Function Documentation

def Bio.Graphics.BasicChromosome.Organism._draw_legend (   self,
  cur_drawing,
  start_y,
  width 
) [private]
Draw a legend for the figure.

Subclasses should implement this (see also self._legend_height) to
provide specialized legends.

Definition at line 161 of file BasicChromosome.py.

00161 
00162     def _draw_legend(self, cur_drawing, start_y, width):
00163         """Draw a legend for the figure.
00164 
00165         Subclasses should implement this (see also self._legend_height) to
00166         provide specialized legends.
00167         """
        pass

Here is the caller graph for this function:

def Bio.Graphics.BasicChromosome.Organism._draw_title (   self,
  cur_drawing,
  title,
  width,
  height 
) [private]
Write out the title of the organism figure.

Definition at line 151 of file BasicChromosome.py.

00151 
00152     def _draw_title(self, cur_drawing, title, width, height):
00153         """Write out the title of the organism figure.
00154         """
00155         title_string = String(width / 2, height - inch, title)
00156         title_string.fontName = 'Helvetica-Bold'
00157         title_string.fontSize = self.title_size
00158         title_string.textAnchor = "middle"
00159 
00160         cur_drawing.add(title_string)
    

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.Organism.draw (   self,
  output_file,
  title 
)
Draw out the information for the Organism.

Arguments:

o output_file -- The name of a file specifying where the
document should be saved, or a handle to be written to.
The output format is set when creating the Organism object.

o title -- The output title of the produced document.

Definition at line 111 of file BasicChromosome.py.

00111 
00112     def draw(self, output_file, title):
00113         """Draw out the information for the Organism.
00114 
00115         Arguments:
00116 
00117         o output_file -- The name of a file specifying where the
00118         document should be saved, or a handle to be written to.
00119         The output format is set when creating the Organism object.
00120 
00121         o title -- The output title of the produced document.
00122         """
00123         width, height = self.page_size
00124         cur_drawing = Drawing(width, height)
00125 
00126         self._draw_title(cur_drawing, title, width, height)
00127 
00128         cur_x_pos = inch * .5
00129         if len(self._sub_components) > 0:
00130             x_pos_change = (width - inch) / len(self._sub_components)
00131         # no sub_components
00132         else:
00133             pass
00134 
00135         for sub_component in self._sub_components:
00136             # set the drawing location of the chromosome
00137             sub_component.start_x_position = cur_x_pos + 0.05 * x_pos_change
00138             sub_component.end_x_position = cur_x_pos + 0.95 * x_pos_change
00139             sub_component.start_y_position = height - 1.5 * inch
00140             sub_component.end_y_position = self._legend_height + 1 * inch
00141 
00142             # do the drawing
00143             sub_component.draw(cur_drawing)
00144 
00145             # update the locations for the next chromosome
00146             cur_x_pos += x_pos_change
00147 
00148         self._draw_legend(cur_drawing, self._legend_height + 0.5 * inch, width)
00149 
00150         return _write(cur_drawing, output_file, self.output_format)

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

Definition at line 109 of file BasicChromosome.py.

Definition at line 102 of file BasicChromosome.py.

Definition at line 103 of file BasicChromosome.py.


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