Package Bio :: Package Graphics :: Module BasicChromosome
[hide private]
[frames] | no frames]

Module BasicChromosome

source code

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

Classes [hide private]
  _ChromosomeComponent
Base class specifying the interface for a component of the system.
  Organism
Top level class for drawing chromosomes.
  Chromosome
Class for drawing a chromosome of an organism.
  ChromosomeSegment
Draw a segment of a chromosome.
  AnnotatedChromosomeSegment
  TelomereSegment
A segment that is located at the end of a linear chromosome.
  SpacerSegment
A segment that is located at the end of a linear chromosome.
Functions [hide private]
 
_spring_layout(desired, minimum, maximum, gap=0)
Function to try and layout label co-ordinates (or other floats, PRIVATE).
source code
 
_place_labels(desired_etc, minimum, maximum, gap=0) source code
Variables [hide private]
  _color_trans = _ColorTranslator()
  __package__ = 'Bio.Graphics'
Function Details [hide private]

_spring_layout(desired, minimum, maximum, gap=0)

source code 
Function to try and layout label co-ordinates (or other floats, PRIVATE).

Originally written for the y-axis vertical positioning of labels on a
chromosome diagram (where the minimum gap between y-axis co-ordinates is
the label height), it could also potentially be used for x-axis placement,
or indeed radial placement for circular chromosomes within GenomeDiagram.

In essence this is an optimisation problem, balancing the desire to have
each label as close as possible to its data point, but also to spread out
the labels to avoid overlaps. This could be described with a cost function
(modelling the label distance from the desired placement, and the inter-
label separations as springs) and solved as a multi-variable minimization
problem - perhaps with NumPy or SciPy.

For now however, the implementation is a somewhat crude ad hoc algorithm.

NOTE - This expects the input data to have been sorted!