Back to index

python-biopython  1.60
Public Member Functions | Public Attributes | Private Member Functions
Bio.Graphics.Distribution.DistributionPage Class Reference

List of all members.

Public Member Functions

def __init__
def draw

Public Attributes

 distributions
 number_of_columns
 page_size
 title_size
 output_format

Private Member Functions

def _draw_title
def _draw_distributions
def _draw_legend

Detailed Description

Display a grouping of distributions on a page.

This organizes Distributions, and will display them nicely
on a single page.

Definition at line 27 of file Distribution.py.


Constructor & Destructor Documentation

def Bio.Graphics.Distribution.DistributionPage.__init__ (   self,
  output_format = 'pdf' 
)

Definition at line 33 of file Distribution.py.

00033 
00034     def __init__(self, output_format = 'pdf'):
00035         self.distributions = []
00036 
00037         # customizable attributes
00038         self.number_of_columns = 1
00039         self.page_size = letter
00040         self.title_size = 20
00041 
00042         self.output_format = output_format

Here is the caller graph for this function:


Member Function Documentation

def Bio.Graphics.Distribution.DistributionPage._draw_distributions (   self,
  cur_drawing,
  start_x_pos,
  x_pos_change,
  start_y_pos,
  y_pos_change,
  num_y_drawings 
) [private]
Draw all of the distributions on the page.

Arguments:

o cur_drawing - The drawing we are working with.

o start_x_pos - The x position on the page to start drawing at.

o x_pos_change - The change in x position between each figure.

o start_y_pos - The y position on the page to start drawing at.

o y_pos_change - The change in y position between each figure.

o num_y_drawings - The number of drawings we'll have in the y
(up/down) direction.

Definition at line 86 of file Distribution.py.

00086 
00087                             start_y_pos, y_pos_change, num_y_drawings):
00088         """Draw all of the distributions on the page.
00089 
00090         Arguments:
00091 
00092         o cur_drawing - The drawing we are working with.
00093 
00094         o start_x_pos - The x position on the page to start drawing at.
00095 
00096         o x_pos_change - The change in x position between each figure.
00097 
00098         o start_y_pos - The y position on the page to start drawing at.
00099 
00100         o y_pos_change - The change in y position between each figure.
00101 
00102         o num_y_drawings - The number of drawings we'll have in the y
00103         (up/down) direction.
00104         """
00105         for y_drawing in range(int(num_y_drawings)):
00106             # if we are on the last y position, we may not be able
00107             # to fill all of the x columns
00108             if ((y_drawing + 1) * self.number_of_columns >
00109                 len(self.distributions)):
00110                 num_x_drawings = len(self.distributions) - \
00111                                  y_drawing * self.number_of_columns
00112             else:
00113                 num_x_drawings = self.number_of_columns
00114             for x_drawing in range(num_x_drawings):
00115                 dist_num = y_drawing * self.number_of_columns + x_drawing
00116                 cur_distribution = self.distributions[dist_num]
00117 
00118                 # find the x and y boundaries of the distribution
00119                 x_pos = start_x_pos + x_drawing * x_pos_change
00120                 end_x_pos = x_pos + x_pos_change
00121                 end_y_pos = start_y_pos - y_drawing * y_pos_change
00122                 y_pos = end_y_pos - y_pos_change
00123 
00124                 # draw the distribution
00125                 cur_distribution.draw(cur_drawing, x_pos, y_pos, end_x_pos,
00126                                       end_y_pos)

Here is the caller graph for this function:

def Bio.Graphics.Distribution.DistributionPage._draw_legend (   self,
  cur_drawing,
  start_y,
  width 
) [private]
Add a legend to the figure.

Subclasses can implement to provide a specialized legend.

Definition at line 127 of file Distribution.py.

00127 
00128     def _draw_legend(self, cur_drawing, start_y, width):
00129         """Add a legend to the figure.
00130 
00131         Subclasses can implement to provide a specialized legend.
00132         """
00133         pass

Here is the caller graph for this function:

def Bio.Graphics.Distribution.DistributionPage._draw_title (   self,
  cur_drawing,
  title,
  width,
  height 
) [private]
Add the title of the figure to the drawing.

Definition at line 75 of file Distribution.py.

00075 
00076     def _draw_title(self, cur_drawing, title, width, height):
00077         """Add the title of the figure to the drawing.
00078         """
00079         title_string = String(width / 2, height - inch, title)
00080         title_string.fontName = 'Helvetica-Bold'
00081         title_string.fontSize = self.title_size
00082         title_string.textAnchor = "middle"
00083 
00084         cur_drawing.add(title_string)

Here is the call graph for this function:

Here is the caller graph for this function:

def Bio.Graphics.Distribution.DistributionPage.draw (   self,
  output_file,
  title 
)
Draw out the distribution information.

Arguments:

o output_file - The name of the file to output the information to,
        or a handle to write to.

o title - A title to display on the graphic.

Definition at line 43 of file Distribution.py.

00043 
00044     def draw(self, output_file, title):
00045         """Draw out the distribution information.
00046 
00047         Arguments:
00048 
00049         o output_file - The name of the file to output the information to,
00050                         or a handle to write to.
00051 
00052         o title - A title to display on the graphic.
00053         """
00054         width, height = self.page_size
00055         cur_drawing = Drawing(width, height)
00056 
00057         self._draw_title(cur_drawing, title, width, height)
00058 
00059         # calculate the x and y position changes for each distribution
00060         cur_x_pos = inch * .5
00061         end_x_pos = width - inch * .5
00062         cur_y_pos = height - 1.5 * inch
00063         end_y_pos = .5 * inch
00064         x_pos_change = ((end_x_pos - cur_x_pos) /
00065                         float(self.number_of_columns))
00066         num_y_rows = math.ceil(float(len(self.distributions))
00067                                / float(self.number_of_columns))
00068         y_pos_change = (cur_y_pos - end_y_pos) / num_y_rows
00069         
00070         self._draw_distributions(cur_drawing, cur_x_pos, x_pos_change,
00071                                  cur_y_pos, y_pos_change, num_y_rows)
00072         self._draw_legend(cur_drawing, 2.5 * inch, width)
00073 
00074         return _write(cur_drawing, output_file, self.output_format)

Here is the call graph for this function:


Member Data Documentation

Definition at line 34 of file Distribution.py.

Definition at line 37 of file Distribution.py.

Definition at line 41 of file Distribution.py.

Definition at line 38 of file Distribution.py.

Definition at line 39 of file Distribution.py.


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