[Biopython-dev] Genome Diagram Default Behavior
Peter Cock
p.j.a.cock at googlemail.com
Wed Aug 1 05:27:14 EDT 2012
On Wed, Aug 1, 2012 at 1:37 AM, Zachary Charlop-Powers wrote:
> Hello Biopython,
>
> I am writing about a small feature that I would like to see implemented
> (and could possibly help to implement it: I haven't contributed before and
> am not sure exactly how tough this will be). When using Genome Diagram to
> draw features you can specify which strand to put a feature on. If the
> strand is positive it will go above the track in the positive-facing
> direction and if negative it will go below the track in the negative facing
> direction. (seehttp://biopython.org/DIST/docs/tutorial/Tutorial.html#htoc200) . That's a
> great behavior.
Yep - all fine so far.
> However if you use strand="None", Genome Diagram will draw
> the features inline with the track and always in the positive direction.
> For myself, and probably others, keeping the direction of the features is
> immensely useful as you can often get a sense of operon structure in
> prokaryote genomes just by looking at the genes. Of course the forward and
> the minus strands can be drawn but condensing small sections of genes to a
> single track saves space when making images.
>
> So, would it be possible to change the default behavior of Genome Diagram
> to draw features inline (strand="None"), but to preserve their orientation?
I think I know what you mean - that kind of picture is quite common
e.g. for viruses - but only where there are no overlapping genes
on opposite strands. GenomeDiagram was written originally primarily
for bacteria, were overlapping genes on opposite strands are more
common, which may explain the design choices made.
Currently strand controls both orientation (for arrows, no effect on
box sigils) and vertical placement (above, below, or straddling the
line). Basically you want to override the vertical placement only?
Note this is sigil dependent - it makes sense for the arrow, but not
the default box (which was originally the only sigil supported).
The good news is the underlying drawing code can do this - the
arrow drawing is just given a bounding box and the requested
orientation (left or right) argument set by the get_feature_sigil
method of the LinearDrawer or CircularDrawer.
If you need this right now, a careful hack in get_feature_sigil is
the way to proceed.
The question is how to most cleanly expose this to the user while
not breaking anything else (e.g. cross links), and ideally allow for
a related option which Leighton and I have considered (but not
had a pressing need to implement) for frame specific placement.
i.e. Rather than treating the vertical drawing spaces as two regions
(above the axis line for the forward strand, below the line for the
reverse strand), treat it as six regions (three frames above and
below the axis line). I'm picturing something a bit like the view
in the Artemis annotation editor.
One question which constrains this design choice is would you
want to mix these placements on the same track? I think yes -
using plain strandless BOX features (at the bottom of the z-order
stack) is a really useful way to to highlight a region of interest
(which could have multiple genes drawn on top of it).
That suggests this setting might be best at the GenomeDiagram
feature level. Perhaps a new attribute/argument 'strand_mode',
(a) ignore strand for vertical placement (what you want)
(b) divide vertical space in two (current behaviour)
(c) divide vertical space in six (frame specific placement)
Hmm. Leighton?
Peter
P.S. Frame specific placement would work best with an
overhaul of how we draw multi-fragment features like genes
with exons. Here a whole new sigil class for linking sub-parts
of a feature might make sense. That is again something we
only chatted about so far, but would make GenomeDiagram
more useful for drawing eukaryotic annotation.
More information about the Biopython-dev
mailing list