# Bio.Graphics.BasicChromosome module

Draw representations of organism chromosomes with added information.

These classes are meant to model the drawing of pictures of chromosomes. This can be useful for lots of things, including displaying markers on a chromosome (ie. for genetic mapping) and showing syteny between two chromosomes.

The structure of these classes is intended to be a Composite, so that it will be easy to plug in and switch different parts without breaking the general drawing capabilities of the system. The relationship between classes is that everything derives from _ChromosomeComponent, which specifies the overall interface. The parts then are related so that an Organism contains Chromosomes, and these Chromosomes contain ChromosomeSegments. This representation differs from the canonical composite structure in that we don’t really have ‘leaf’ nodes here – all components can potentially hold sub-components.

Most of the time the ChromosomeSegment class is what you’ll want to customize for specific drawing tasks.

For providing drawing capabilities, these classes use reportlab:

http://www.reportlab.com

This provides nice output in PDF, SVG and postscript. If you have reportlab’s renderPM module installed you can also use PNG etc.

class Bio.Graphics.BasicChromosome.Organism(output_format='pdf')

  Bases: `_ChromosomeComponent`

  Top level class for drawing chromosomes.

  This class holds information about an organism and all of its 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.

  __init__(output_format='pdf')

    Initialize the class.

  draw(output_file, title)

    Draw out the information for the Organism.

    Arguments:

      - 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).

      - title – The output title of the produced document.

  __annotate_func__ = None
  __annotations_cache__ = {}
  __firstlineno__ = 97
  __static_attributes__ = ('_legend_height', 'output_format', 'page_size', 'title_size')

class Bio.Graphics.BasicChromosome.Chromosome(chromosome_name)

  Bases: `_ChromosomeComponent`

  Class for drawing a chromosome of an organism.

  This organizes the drawing of a single organisms chromosome. This class can be instantiated directly, but the draw method makes the most sense to be called in the context of an organism.

  __init__(chromosome_name)

    Initialize a Chromosome for drawing.

    Arguments:

      - chromosome_name - The label for the chromosome.

    Attributes:

      - start_x_position, end_x_position - The x positions on the page where the chromosome should be drawn. This allows multiple chromosomes to be drawn on a single page.

      - start_y_position, end_y_position - The y positions on the page where the chromosome should be contained.

    Configuration Attributes:

      - title_size - The size of the chromosome title.

      - scale_num - A number of scale the drawing by. This is useful if you want to draw multiple chromosomes of different sizes at the same scale. If this is not set, then the chromosome drawing will be scaled by the number of segments in the chromosome (so each chromosome will be the exact same final size).

  subcomponent_size()

    Return the scaled size of all subcomponents of this component.

  draw(cur_drawing)

    Draw a chromosome on the specified template.

    Ideally, the x_position and y_*_position attributes should be set prior to drawing – otherwise we’re going to have some problems.

  __annotate_func__ = None
  __annotations_cache__ = {}
  __firstlineno__ = 185
  __static_attributes__ = ('_color_labels', '_name', 'chr_percent', 'end_x_position', 'end_y_position', 'label_sep_percent', 'label_size', 'scale_num', 'start_x_position', 'start_y_position', 'title_size')

class Bio.Graphics.BasicChromosome.ChromosomeSegment

  Bases: `_ChromosomeComponent`

  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.

  __init__()

    Initialize a ChromosomeSegment.

    Attributes:

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

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

    Configuration Attributes:

      - 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.

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

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

      - label_size - The size of the label.

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

  draw(cur_drawing)

    Draw a chromosome segment.

    Before drawing, the range we are drawing in needs to be set.

  __annotate_func__ = None
  __annotations_cache__ = {}
  __firstlineno__ = 380
  __static_attributes__ = ('chr_percent', 'end_x_position', 'end_y_position', 'fill_color', 'label', 'label_size', 'scale', 'start_x_position', 'start_y_position')

class Bio.Graphics.BasicChromosome.AnnotatedChromosomeSegment(bp_length, features, default_feature_color=colors.blue, name_qualifiers=('gene', 'label', 'name', 'locus_tag', 'product'))

  Bases: `ChromosomeSegment`

  Annotated chromosome segment.

  This is like the ChromosomeSegment, but accepts a list of features.

  __init__(bp_length, features, default_feature_color=colors.blue, name_qualifiers=('gene', 'label', 'name', 'locus_tag', 'product'))

    Initialize.

    The features can either be SeqFeature objects, or tuples of values: start (int), end (int), strand (+1, -1, O or None), label (string), ReportLab color (string or object), and optional ReportLab fill color.

    Note we require 0 <= start <= end <= bp_length, and within the vertical space allocated to this segment lines will be places according to the start/end coordinates (starting from the top).

    Positive stand features are drawn on the right, negative on the left, otherwise all the way across.

    We recommend using consistent units for all the segment’s scale values (e.g. their length in base pairs).

    When providing features as SeqFeature objects, the default color is used, unless the feature’s qualifiers include an Artemis colour string (functionality also in GenomeDiagram). The caption also follows the GenomeDiagram approach and takes the first qualifier from the list or tuple specified in name_qualifiers.

    Note additional attribute label_sep_percent controls the percentage of area that the chromosome segment takes up, by default half of the chr_percent attribute (half of 25%, thus 12.5%)

  __annotate_func__ = None
  __annotations_cache__ = {}
  __firstlineno__ = 621
  __static_attributes__ = ('bp_length', 'default_feature_color', 'features', 'label_sep_percent', 'name_qualifiers')

class Bio.Graphics.BasicChromosome.TelomereSegment(inverted=0)

  Bases: `ChromosomeSegment`

  A segment that is located at the end of a linear chromosome.

  This is just like a regular segment, but it draws the end of a chromosome which is represented by a half circle. This just overrides the _draw_segment class of ChromosomeSegment to provide that specialized drawing.

  __init__(inverted=0)

    Initialize a segment at the end of a chromosome.

    See ChromosomeSegment for all of the attributes that can be customized in a TelomereSegments.

    Arguments:

      - inverted – Whether or not the telomere should be inverted (ie. drawn on the bottom of a chromosome)

  __annotate_func__ = None
  __annotations_cache__ = {}
  __firstlineno__ = 753
  __static_attributes__ = ('_inverted',)

class Bio.Graphics.BasicChromosome.SpacerSegment

  Bases: `ChromosomeSegment`

  A segment that is located at the end of a linear chromosome.

  Doesn’t draw anything, just empty space which can be helpful for layout purposes (e.g. making room for feature labels).

  draw(cur_diagram)

    Draw nothing to the current diagram (dummy method).

    The segment spacer has no actual image in the diagram, so this method therefore does nothing, but is defined to match the expected API of the other segment objects.

  __annotate_func__ = None
  __annotations_cache__ = {}
  __firstlineno__ = 806
  __static_attributes__ = ()

Biopython v: 1.86

Versions
  Previous
  Latest
  Develop

Biopython Project
  Homepage
  On GitHub