Skip to content

Commit

Permalink
fixed cm issue
Browse files Browse the repository at this point in the history
  • Loading branch information
lstein committed Sep 28, 2010
1 parent bc58741 commit 1fab29d
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 27 deletions.
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
another, this will not be reflected in the summary density plots, which will show all features
of the matching type regardless of the filter.
* Basic support for Google federated login via openid.
* "unit label" and "unit divider" should now work as advertised.

2.15 Mon Sep 13 11:22:40 EDT 2010
* Set the "DNA accessor" for databases to the default database. Assuming that the backend supports
Expand All @@ -31,6 +32,7 @@
Bio::DB::GFF database backend.
* Fixed problems with losing all default tracks when first loading the browser (this was a bug
introduced in SVN and never released.)
* You can now override the "buttons" images path in individual datasource files.

2.14 Fri Aug 27 11:05:08 EDT 2010
* Prevent a blank-screen crash when searching for chromosomes not in the database.
Expand Down
18 changes: 18 additions & 0 deletions htdocs/js/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,24 @@ function set_dragcolors(color) {
detailsObject.background = color;
}

// set the colors for the rubberband regions
function set_dragunits(unit,divider) {
if (unit == null) unit = 'bp';
if (divider == null) divider = 1;
if (overviewObject != null) {
overviewObject.unit = unit;
overviewObject.divider = divider;
}
if (regionObject != null) {
regionObject.unit = unit;
regionObject.divider = divider;
}
if (detailsObject != null) {
detailsObject.unit = unit;
detailsObject.divider = divider;
}
}

function create_time_key () {
time_obj = new Date();
return time_obj.getTime();
Expand Down
11 changes: 8 additions & 3 deletions htdocs/js/rubber.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ var selectAreaIsActive;

// Constructor
var SelectArea = function () {
this.background = 'yellow';
this.unit = 'bp';
this.divider = 1;
return this;
}

Expand Down Expand Up @@ -295,14 +298,16 @@ SelectArea.prototype.moveRubber = function(event) {
self.overrideAutoSubmit = false;
}

var unit = 'bp';
var unit = self.unit;
var divider = self.divider;
selectSequenceWidth /= divider;
if (selectSequenceWidth > 1000 && selectSequenceWidth < 1000000) {
selectSequenceWidth = selectSequenceWidth/1000;
unit = 'kbp';
unit = 'k'+unit;
}
else if (selectSequenceWidth > 1000000) {
selectSequenceWidth = selectSequenceWidth/1000000;
unit = 'Mbp';
unit = 'M'+unit;
}

if (Math.floor(selectSequenceWidth) != selectSequenceWidth) {
Expand Down
10 changes: 8 additions & 2 deletions lib/Bio/Graphics/Browser2/DataSource.pm
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ sub unit_label {
my $abs = abs($value);

my $label;
$label = $abs >= 1e9 ? sprintf("%.4g G%s",$value/1e9,$unit)
$label = $unit =~ /^[kcM]/ ? sprintf("%.4g %s",$value,$unit)
: $abs >= 1e9 ? sprintf("%.4g G%s",$value/1e9,$unit)
: $abs >= 1e6 ? sprintf("%.4g M%s",$value/1e6,$unit)
: $abs >= 1e3 ? sprintf("%.4g k%s",$value/1e3,$unit)
: $abs >= 1 ? sprintf("%.4g %s", $value, $unit)
Expand Down Expand Up @@ -572,9 +573,14 @@ sub show_section { # one of instructions, upload_tracks, search, overview, regi
return $setting eq 'hide' || $setting eq 'off' ? 0 : 1;
}

sub unit_divider {
my $self = shift;
return $self->global_setting('unit_divider') || 1;
}

sub get_ranges {
my $self = shift;
my $divisor = $self->global_setting('unit_divider') || 1;
my $divisor = $self->unit_divider;
my $rangestr = $self->global_setting('zoom levels') || '100 1000 10000 100000 1000000 10000000';
if ($divisor == 1 ) {
return split /\s+/,$rangestr;
Expand Down
5 changes: 3 additions & 2 deletions lib/Bio/Graphics/Browser2/Region.pm
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ sub whole_seg {
sub set_features_by_region {
my $self = shift;
my ($ref,$start,$stop) = @_;
my $features = $self->lookup_features($ref,$start,$stop);
my $divider = $self->source->unit_divider;
my $features = $self->lookup_features($ref,$start/$divider,$stop/$divider);
$self->features($features);
return $features;
}
Expand Down Expand Up @@ -221,7 +222,7 @@ sub lookup_features {

my $db = $self->db;

my $divisor = $source->global_setting('unit_divider') || 1;
my $divisor = $source->unit_divider;
$start *= $divisor if defined $start;
$stop *= $divisor if defined $stop;

Expand Down
33 changes: 23 additions & 10 deletions lib/Bio/Graphics/Browser2/Render.pm
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ sub run {
warn "[$$] add_user_tracks()" if $debug;
$self->add_user_tracks($self->data_source);

warn "user = ",$self->session->username;
# warn "user = ",$self->session->username;

warn "[$$] testing for asynchronous event()" if $debug;
if ($self->run_asynchronous_event) {
Expand Down Expand Up @@ -798,6 +798,7 @@ sub generate_title {
my $dsn = $self->data_source;
my $state = $self->state;
my $description = $dsn->description;
my $divider = $self->data_source->unit_divider;

return $description unless $features;
return !$features || !$state->{name} ? $description
Expand All @@ -806,8 +807,8 @@ sub generate_title {
$self->tr('SHOWING_FROM_TO',
scalar $dsn->unit_label($features->[0]->length),
$features->[0]->seq_id,
$dsn->commas($features->[0]->start),
$dsn->commas($features->[0]->end))
$dsn->commas($features->[0]->start/$divider),
$dsn->commas($features->[0]->end/$divider))
: $description;
}

Expand Down Expand Up @@ -1540,8 +1541,7 @@ sub cleanup {
my $self = shift;
warn "cleanup()" if DEBUG;
my $state = $self->state;
$state->{name} = "$state->{ref}:$state->{start}..$state->{stop}"
if $state->{ref}; # to remember us by :-)
$state->{name} = $self->region_string if $state->{ref}; # to remember us by :-)
}

sub fatal_error {
Expand Down Expand Up @@ -2309,7 +2309,7 @@ sub update_coordinates {
}

# update our "name" state and the CGI parameter
$state->{name} = "$state->{ref}:$state->{start}..$state->{stop}";
$state->{name} = $self->region_string;
param(name => $state->{name});

warn "name = $state->{name}" if DEBUG;
Expand Down Expand Up @@ -2491,7 +2491,7 @@ sub asynchronous_update_sections {
return $return_object;
}

# asynchronous_update_element has been DEPRICATED
# asynchronous_update_element has been DEPRECATED
# in favor of asynchronous_update_sections
sub asynchronous_update_element {
my $self = shift;
Expand All @@ -2503,13 +2503,14 @@ sub asynchronous_update_element {
my $segment = $self->segment;
my $dsn = $self->data_source;
my $description = $dsn->description;
my $divider = $dsn->unit_divider;
return $description . '<br>'
. $self->tr(
'SHOWING_FROM_TO',
scalar $source->unit_label( $segment->length ),
$segment->seq_id,
$source->commas( $segment->start ),
$source->commas( $segment->end )
$source->commas( $segment->start/$divider ),
$source->commas( $segment->end/$divider )
);
}
elsif ( $element eq 'span' ) { # this is the popup menu that shows ranges
Expand Down Expand Up @@ -2637,13 +2638,24 @@ sub asynchronous_update_coordinates {
}

# update our "name" state and the CGI parameter
$state->{name} = "$state->{ref}:$state->{start}..$state->{stop}";
$state->{name} = $self->region_string;
}

$self->session->flush();
$position_updated;
}

sub region_string {
my $self = shift;
my $state = $self->state;
my $source = $self->data_source;
my $divider = $source->unit_divider;
$state->{name} = "$state->{ref}:".
$source->commas($state->{start}/$divider).
'..'.
$source->commas($state->{stop}/$divider);
}

sub zoom_to_span {
my $self = shift;
my ($state,$new_span) = @_;
Expand Down Expand Up @@ -3194,6 +3206,7 @@ sub get_panel_renderer {
my $seg = shift || $self->segment;
my $whole = shift || $self->whole_segment;
my $region = shift || $self->region_segment;

return Bio::Graphics::Browser2::RenderPanels->new(-segment => $seg,
-whole_segment => $whole,
-region_segment => $region,
Expand Down
26 changes: 17 additions & 9 deletions lib/Bio/Graphics/Browser2/Render/HTML.pm
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,10 @@ sub render_html_head {
$fill =~ s/^(\w+):[\d.]+$/$1/;
$set_dragcolors = "set_dragcolors('$fill')";
}
my $units = $self->data_source->setting('units') || 'bp';
my $divider = $self->data_source->unit_divider;
my $set_units = "set_dragunits('$units',$divider)";

my @extra_headers;
push @extra_headers, $self->render_user_head;

Expand All @@ -405,17 +409,19 @@ sub render_html_head {

# add body's onload arguments, including ones used by plugins
my $autocomplete = '';
my $body_onLoads = "initialize_page();$set_dragcolors;$autocomplete";
while(my($keys, $values) = each(%plugin_onLoads)) {
if ($keys eq "body") {
$body_onLoads .= $values;
}
}
push @args,(-onLoad => "$body_onLoads");

# this looks wrong
# my $body_onLoads = "initialize_page();$set_dragcolors;$set_units;$autocomplete";
# while(my($keys, $values) = each(%plugin_onLoads)) {
# if ($keys eq "body") {
# $body_onLoads .= $values;
# }
# }
# push @args,(-onLoad => $body_onLoads);

my $plugin_onloads = join ';',map {eval{$_->body_onloads}} @plugin_list;
my $other_actions = join ';',@other_initialization;
push @args,(-onLoad => "initialize_page(); $set_dragcolors; $plugin_onloads; $other_actions");
push @args,(-onLoad => "initialize_page(); $set_dragcolors; $set_units; $plugin_onloads; $other_actions");

return start_html(@args);
}
Expand Down Expand Up @@ -1877,12 +1883,14 @@ sub zoomBar {

my ($length,$max) = @_;


my $show = $self->tr('Show');

my %seen;
my @r = sort {$a<=>$b} $self->data_source->get_ranges();
my @ranges = grep {!$seen{$_}++ && $_<=$max} sort {$b<=>$a} @r,$length;
$max *= $self->data_source->unit_divider;

my @ranges = grep {!$seen{$self->data_source->unit_label($_)}++ && $_<=$max} sort {$b<=>$a} @r,$length;
my %labels = map {$_=>$show.' '.$self->data_source->unit_label($_)} @ranges;
return popup_menu(-class => 'searchtitle',
-name => 'span',
Expand Down
3 changes: 2 additions & 1 deletion lib/Bio/Graphics/Browser2/RenderPanels.pm
Original file line number Diff line number Diff line change
Expand Up @@ -956,14 +956,15 @@ sub render_scale_bar {
-label_position => 'left'
);
}

$panel->add_track(
$wide_segment,
-glyph => 'arrow',
-double => 1,
-tick => 2,
-units_in_label => $no_tick_units,
-units => $units,
-unit_divider => $source->global_setting('unit_divider') || 1,
-unit_divider => $source->unit_divider,
%add_track_extra_args,
);

Expand Down

0 comments on commit 1fab29d

Please sign in to comment.