[Bioperl-l] Bio::Graphics::Panel gridlines and pixels

Lincoln Stein lstein at cshl.edu
Wed Feb 7 07:18:40 EST 2007


However, I'm also very interested in why grid-drawing takes so long. When
I've profiled drawing, neither grid drawing nor map_pt() consume any
significant amount of time.

Lincoln

On 2/6/07, Mitch Skinner <mitch_skinner at berkeley.edu> wrote:
>
> Hello,
>
> I'm working on an AJAX version of GBrowse (http://genome.biowiki.org),
> where we're pre-rendering entire chromosomes by breaking them up into
> tiles.  One of the problems we have is that it takes a long time to
> render all those tiles.  One of the things that's slowing the process
> down (and using lots of RAM) is rendering the gridlines, and it would
> make things a lot easier (and faster) for us if we could assume that the
> gridlines were the same for each tile.  Since we're only rendering at a
> particular set of zoom levels (that we have control over), I think this
> is a reasonable assumption.
>
> Given the right set of zoom levels, the assumption works almost all the
> time, except for one specific case.  It has to do with the way draw_grid
> and map_pt in Bio::Graphics::Panel work for the very first gridline.
>
> Here's how draw_grid (in CVS HEAD) computes the first gridline:
>
>     my $first_tick = $minor * int($self->start/$minor);
>
> $first_tick, $minor and $self->start are in base-pair space, which is
> 1-based.  However, if ($self->start < $minor) then $first_tick is 0.
> This might not be a problem, except that $first_tick is translated into
> pixel coordinates in map_pt, which expects 1-based bp coordinates.  Here
> are the relevant lines in map_pt:
>
>     my $val = $flip
>       ? int (0.5 + $pr - ($length - ($_- 1)) * $scale)
>       : int (0.5 + ($_-$offset-1) * $scale);
>
> This style of rounding only works for positive numbers; rounding 0.6 by
> doing int(0.5 + 0.6) gives you 1 as expected, but rounding -0.6 by doing
> int(0.5 + -0.6) gives you 0.  So if the first three gridlines are at 0,
> 10, and 20 bp, then (assuming $scale is 1, $offset is 0, $flip evaluates
> false, and pad left is 0) they're drawn at pixels 0, 9, and 19.
>
> I think that there should be gridlines at pixels 0, 10, and 20.  The
> fact that currently the first interval is 9 pixels and the second is 10
> pixels is breaking my hopeful assumption about the gridlines.
>
> AFAICT my problems are solved if we make two changes:
> change the above line from draw_grid to this:
>     my $first_tick = 1 + $minor * int(($start - 1)/$minor);
> and change the lines from map_pt to this:
>
>     my $val = $flip
>       ? ($pr - ($length - ($_- 1)) * $scale)
>       : (($_-$offset-1) * $scale);
>     $val = int($val + .5 * ($val <=> 0));
>
> Does this make sense?  If people agree that these changes are right then
> I can also produce a proper patch if y'all would prefer that.
>
> Regards,
> Mitch
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l
>



-- 
Lincoln D. Stein
Cold Spring Harbor Laboratory
1 Bungtown Road
Cold Spring Harbor, NY 11724
(516) 367-8380 (voice)
(516) 367-8389 (fax)
FOR URGENT MESSAGES & SCHEDULING,
PLEASE CONTACT MY ASSISTANT,
SANDRA MICHELSEN, AT michelse at cshl.edu


More information about the Bioperl-l mailing list