Example #1
0
    def 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.
        """
        width, height = self.page_size
        cur_drawing = Drawing(width, height)

        self._draw_title(cur_drawing, title, width, height)

        # calculate the x and y position changes for each distribution
        cur_x_pos = inch * .5
        end_x_pos = width - inch * .5
        cur_y_pos = height - 1.5 * inch
        end_y_pos = .5 * inch
        x_pos_change = ((end_x_pos - cur_x_pos) /
                        float(self.number_of_columns))
        num_y_rows = math.ceil(float(len(self.distributions))
                               / float(self.number_of_columns))
        y_pos_change = (cur_y_pos - end_y_pos) / num_y_rows

        self._draw_distributions(cur_drawing, cur_x_pos, x_pos_change,
                                 cur_y_pos, y_pos_change, num_y_rows)
        self._draw_legend(cur_drawing, 2.5 * inch, width)

        return _write(cur_drawing, output_file, self.output_format)
Example #2
0
    def 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.
        """
        width, height = self.page_size
        cur_drawing = Drawing(width, height)

        self._draw_title(cur_drawing, title, width, height)

        # calculate the x and y position changes for each distribution
        cur_x_pos = inch * .5
        end_x_pos = width - inch * .5
        cur_y_pos = height - 1.5 * inch
        end_y_pos = .5 * inch
        x_pos_change = ((end_x_pos - cur_x_pos) /
                        float(self.number_of_columns))
        num_y_rows = math.ceil(
            float(len(self.distributions)) / float(self.number_of_columns))
        y_pos_change = (cur_y_pos - end_y_pos) / num_y_rows

        self._draw_distributions(cur_drawing, cur_x_pos, x_pos_change,
                                 cur_y_pos, y_pos_change, num_y_rows)
        self._draw_legend(cur_drawing, 2.5 * inch, width)

        return _write(cur_drawing, output_file, self.output_format)
Example #3
0
    def 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.
        Alternatively, output_file=None will return the drawing using
        the low-level ReportLab objects (for further processing, such
        as adding additional graphics, before writing).

        o title -- The output title of the produced document.
        """
        width, height = self.page_size
        cur_drawing = Drawing(width, height)

        self._draw_title(cur_drawing, title, width, height)

        cur_x_pos = inch * .5
        if len(self._sub_components) > 0:
            x_pos_change = (width - inch) / len(self._sub_components)
        # no sub_components
        else:
            pass

        for sub_component in self._sub_components:
            # set the drawing location of the chromosome
            sub_component.start_x_position = cur_x_pos + 0.05 * x_pos_change
            sub_component.end_x_position = cur_x_pos + 0.95 * x_pos_change
            sub_component.start_y_position = height - 1.5 * inch
            sub_component.end_y_position = self._legend_height + 1 * inch

            # do the drawing
            sub_component.draw(cur_drawing)

            # update the locations for the next chromosome
            cur_x_pos += x_pos_change

        self._draw_legend(cur_drawing, self._legend_height + 0.5 * inch, width)

        if output_file is None:
            #Let the user take care of writing to the file...
            return cur_drawing

        return _write(cur_drawing, output_file, self.output_format)
Example #4
0
    def write(self, filename='test1.ps', output='PS', dpi=72):
        """ write(self, filename='test1.ps', output='PS', dpi=72)

            o filename      String indicating the name of the output file,
                            or a handle to write to.

            o output        String indicating output format, one of PS, PDF,
                            SVG, or provided the ReportLab renderPM module is
                            installed, one of the bitmap formats JPG, BMP,
                            GIF, PNG, TIFF or TIFF.  The format can be given
                            in upper or lower case.

            o dpi           Resolution (dots per inch) for bitmap formats.

            Write the completed drawing out to a file in a prescribed format

            No return value.
        """
        return _write(self.drawing, filename, output, dpi=dpi)
Example #5
0
    def write(self, filename='test1.ps', output='PS', dpi=72):
        """ write(self, filename='test1.ps', output='PS', dpi=72)

            o filename      String indicating the name of the output file,
                            or a handle to write to.

            o output        String indicating output format, one of PS, PDF,
                            SVG, or provided the ReportLab renderPM module is
                            installed, one of the bitmap formats JPG, BMP,
                            GIF, PNG, TIFF or TIFF.  The format can be given
                            in upper or lower case.

            o dpi           Resolution (dots per inch) for bitmap formats.

            Write the completed drawing out to a file in a prescribed format

            No return value.
        """
        return _write(self.drawing, filename, output, dpi=dpi)
Example #6
0
    def draw_to_file(self, output_file, title):
        """Write the comparative plot to a file.

        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.
        """
        width, height = self.page_size
        cur_drawing = Drawing(width, height)

        self._draw_title(cur_drawing, title, width, height)

        start_x = inch * .5
        end_x = width - inch * .5
        end_y = height - 1.5 * inch
        start_y = .5 * inch
        self._draw_scatter_plot(cur_drawing, start_x, start_y, end_x, end_y)

        return _write(cur_drawing, output_file, self.output_format)