Bio.Graphics.DisplayRepresentation module

Represent information for graphical display.

Classes in this module are designed to hold information in a way that makes it easy to draw graphical figures.

class Bio.Graphics.DisplayRepresentation.ChromosomeCounts(segment_names, color_scheme=RAINBOW_COLORS)

Bases: object

Represent a chromosome with count information.

This is used to display information about counts along a chromosome. The segments are expected to have different count information, which will be displayed using a color scheme.

I envision using this class when you think that certain regions of the chromosome will be especially abundant in the counts, and you want to pick those out.

__init__(self, segment_names, color_scheme=RAINBOW_COLORS)

Initialize a representation of chromosome counts.

Arguments:
  • segment_names - An ordered list of all segment names along the chromosome. The count and other information will be added to these.

  • color_scheme - A coloring scheme to use in the counts. This should be a dictionary mapping count ranges to colors (specified in reportlab.lib.colors).

add_count(self, segment_name, count=1)

Add counts to the given segment name.

Arguments:
  • segment_name - The name of the segment we should add counts to. If the name is not present, a KeyError will be raised.

  • count - The counts to add the current segment. This defaults to a single count.

scale_segment_value(self, segment_name, scale_value=None)

Divide the counts for a segment by some kind of scale value.

This is useful if segments aren’t represented by raw counts, but are instead counts divided by some number.

add_label(self, segment_name, label)

Add a label to a specific segment.

Raises a KeyError is the specified segment name is not found.

set_scale(self, segment_name, scale)

Set the scale for a specific chromosome segment.

By default all segments have the same scale – this allows scaling by the size of the segment.

Raises a KeyError is the specified segment name is not found.

get_segment_info(self)

Retrieve the color and label info about the segments.

Returns a list consiting of two tuples specifying the counts and label name for each segment. The list is ordered according to the original listing of names. Labels are set as None if no label was specified.

fill_chromosome(self, chromosome)

Add the collected segment information to a chromosome for drawing.

Arguments:
  • chromosome - A Chromosome graphics object that we can add chromosome segments to.

This creates ChromosomeSegment (and TelomereSegment) objects to fill in the chromosome. The information is derived from the label and count information, with counts transformed to the specified color map.

Returns the chromosome with all of the segments added.