Permalink
Browse files

Merge branch 'development'

  • Loading branch information...
2 parents b029e54 + 4f8deba commit 96156edd0a05760dd090f52fd33d41ea4f1859e2 @lstein lstein committed Oct 12, 2011
View
@@ -1,3 +1,6 @@
+2.41
+ * Quash bugs related to miscalculating semantic zooming settings.
+
2.40
* Quash a few uninitialized variable warnings when bringing up track configuration dialog.
* Fix inability to toggle visibility & favorite status of plugin tracks from the
@@ -2,7 +2,7 @@ package Bio::Graphics::Browser2;
# $Id$
# Globals and utilities for GBrowse and friends
-our $VERSION = '2.40';
+our $VERSION = '2.41';
use strict;
use warnings;
@@ -297,6 +297,7 @@ sub unit_label {
: $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)
+ : $abs == 0 ? sprintf("%.4g %s", $value, $unit)
: $abs >= 1e-2 ? sprintf("%.4g c%s",$value*100,$unit)
: $abs >= 1e-3 ? sprintf("%.4g m%s",$value*1e3,$unit)
: $abs >= 1e-6 ? sprintf("%.4g u%s",$value*1e6,$unit)
@@ -480,6 +481,7 @@ sub i18n_style {
sub show_summary {
my $self = shift;
my ($label,$length,$settings) = @_;
+
$settings ||= {};
return 0 if defined $settings->{features}{$label}{summary_mode_len} &&
!$settings->{features}{$label}{summary_mode_len};
@@ -492,6 +494,10 @@ sub show_summary {
or $class->isa('Bio::Graphics::Glyph::minmax');
return 0 if $self->semantic_fallback_setting($label=>'global feature',$length);
return 0 unless $c;
+
+ my $section = Bio::Graphics::Browser2::Render->get_section_from_label($label) || 'detail';
+ $length /= $self->details_multiplier if $section eq 'detail';
+
$c =~ s/_//g;
return 0 unless $c <= $length;
my $db = $self->open_database($label,$length) or return;
@@ -601,9 +607,9 @@ sub semantic_label {
my ($self,$label,$length) = @_;
return $label unless defined $length && $length > 0;
- my $mult = $self->global_setting('details multiplier') || 1;
- # round a bit
- $length = int(0.5+($length+1)/$mult);
+ # adjust for details_mult of we are on a 'details' label
+ my $section = Bio::Graphics::Browser2::Render->get_section_from_label($label) || 'detail';
+ $length /= $self->details_multiplier if $section eq 'detail';
# look for:
# 1. a section like "Gene:100000" where the cutoff is <= the length of the segment
@@ -747,7 +753,7 @@ sub invert_types {
return $self->{_inverted}{$keys} = lock_retrieve($inv_path);
}
- my $multiplier = $self->global_setting('details multiplier') || 1;
+# my $multiplier = $self->global_setting('details multiplier') || 1;
my %inverted;
for my $label (sort keys %{$config}) {
@@ -757,7 +763,7 @@ sub invert_types {
$length = $2;
}
- $length *= $multiplier;
+# $length *= $multiplier;
my $feature = $self->semantic_setting($label => 'feature',$length) or next;
my ($dbid) = $self->db_settings($label => $length) or next;
$dbid =~ s/:database$//;
@@ -2166,8 +2166,6 @@ sub source_menu {
# This is currently somewhat hacky, hard to extend and needs to be generalized.
# NOTE: to add new configuration rows, the name of the form element must begin with "conf_" and
# the rest must correspond to a valid glyph option.
-
-# BUG: MOVE THIS INTO ITS OWN MODULE!
sub track_config {
my $self = shift;
my $label = shift;
@@ -25,7 +25,6 @@ sub config_dialog {
:$label =~ /:region$/ ? $render->thin_region_segment
:$render->thin_segment;
my $length = eval{$seg->length}||0;
- $length /= $data_source->global_setting('details multiplier');
eval 'require Bio::Graphics::Browser2::OptionPick; 1'
unless Bio::Graphics::Browser2::OptionPick->can('new');
@@ -68,46 +67,38 @@ sub config_dialog {
my $title = div({-class=>'config-title'},$key);
my $dynamic = $render->translate('DYNAMIC_VALUE');
- my $height = $data_source->semantic_fallback_setting( $label => 'height' , $length) || 10;
- my $width = $data_source->semantic_fallback_setting( $label => 'linewidth', $length ) || 1;
- my $glyph = $data_source->semantic_fallback_setting( $label => 'glyph', $length ) || 'box';
- my $stranded = $data_source->semantic_fallback_setting( $label => 'stranded', $length);
- my $variance_band = $data_source->semantic_fallback_setting( $label => 'variance_band',$length);
- my $limit = $data_source->semantic_fallback_setting( $label => 'feature_limit' , $length) || 0;
- my $summary_length = $data_source->semantic_fallback_setting( $label => 'show summary' , $length) || 0;
+ my $height = $self->setting( $label => 'height' , $length, $summary_mode) || 10;
+ my $width = $self->setting( $label => 'linewidth', $length, $summary_mode ) || 1;
+ my $glyph = $self->setting( $label => 'glyph', $length, $summary_mode ) || 'box';
+ my $stranded = $self->setting( $label => 'stranded', $length, $summary_mode);
+ my $variance_band = $self->setting( $label => 'variance_band',$length, $summary_mode);
+ my $limit = $self->setting( $label => 'feature_limit' , $length, $summary_mode) || 0;
+ my $summary_length= $self->setting( $label => 'show summary' , $length, $summary_mode) || 0;
# options for wiggle & xy plots
- my $min_score= $data_source->semantic_fallback_setting( $label => 'min_score' , $length);
- my $max_score= $data_source->semantic_fallback_setting( $label => 'max_score' , $length);
+ my $min_score= $self->setting( $label => 'min_score' , $length, $summary_mode);
+ my $max_score= $self->setting( $label => 'max_score' , $length, $summary_mode);
$min_score = -1 unless defined $min_score;
$max_score = +1 unless defined $max_score;
- my $autoscale = $data_source->semantic_fallback_setting( $label => 'autoscale' , $length);
- $autoscale = 'local' if $summary_mode;
+ my $autoscale = $self->setting( $label => 'autoscale' , $length, $summary_mode);
$autoscale ||= 'local';
- my $sd_fold = $data_source->semantic_fallback_setting( $label => 'z_score_bound' , $length);
+ my $sd_fold = $self->setting( $label => 'z_score_bound' , $length, $summary_mode);
$sd_fold ||= 4;
- my $bicolor_pivot = $data_source->semantic_fallback_setting( $label => 'bicolor_pivot' , $length);
- my $graph_type = $data_source->semantic_fallback_setting( $label => 'graph_type' , $length);
- my $glyph_subtype = $data_source->semantic_fallback_setting( $label => 'glyph_subtype' , $length);
+ my $bicolor_pivot = $self->setting( $label => 'bicolor_pivot' , $length, $summary_mode);
+ my $graph_type = $self->setting( $label => 'graph_type' , $length, $summary_mode);
+ my $glyph_subtype = $self->setting( $label => 'glyph_subtype' , $length, $summary_mode);
# options for wiggle_whiskers
- my $max_color = $data_source->semantic_fallback_setting( $label => 'max_color' , $length);
- my $mean_color = $data_source->semantic_fallback_setting( $label => 'mean_color' , $length);
- my $stdev_color = $data_source->semantic_fallback_setting( $label => 'stdev_color' , $length);
-
- my @glyph_select;
-
- if ($summary_mode) {
- $glyph = $override->{glyph} || 'wiggle_density';
- @glyph_select = qw(wiggle_xyplot wiggle_density);
- } else {
- @glyph_select = shellwords(
- $data_source->semantic_fallback_setting( $label => 'glyph select', $length )
- );
- unshift @glyph_select,$dynamic if ref $data_source->fallback_setting($label=>'glyph') eq 'CODE';
- }
+ my $max_color = $self->setting( $label => 'max_color' , $length, $summary_mode);
+ my $mean_color = $self->setting( $label => 'mean_color' , $length, $summary_mode);
+ my $stdev_color = $self->setting( $label => 'stdev_color' , $length, $summary_mode);
+
+ my @glyph_select = shellwords(
+ $self->setting( $label => 'glyph select', $length, $summary_mode )
+ );
+ unshift @glyph_select,$dynamic if ref $data_source->fallback_setting($label=>'glyph') eq 'CODE';
my $db = $data_source->open_database($label,$length);
my $quantitative = $glyph =~ /wiggle|vista|xy|density/ || ref($db) =~ /bigwig/i;
@@ -269,7 +260,7 @@ END
th( { -align => 'right' }, $render->translate('BICOLOR_PIVOT_POS_COLOR')),
td( $picker->color_pick(
'conf_pos_color',
- $data_source->semantic_fallback_setting( $label => 'pos_color', $length ),
+ $self->setting( $label => 'pos_color', $length, $summary_mode ),
$override->{'pos_color'}
)
)
@@ -279,7 +270,7 @@ END
th( { -align => 'right' }, $render->translate('BICOLOR_PIVOT_NEG_COLOR') ),
td( $picker->color_pick(
'conf_neg_color',
- $data_source->semantic_fallback_setting( $label => 'neg_color', $length ),
+ $self->setting( $label => 'neg_color', $length, $summary_mode ),
$override->{'neg_color'}
)
)
@@ -291,7 +282,7 @@ END
th( { -align => 'right' }, $render->translate('BACKGROUND_COLOR') ),
td( $picker->color_pick(
'conf_bgcolor',
- $data_source->semantic_fallback_setting( $label => 'bgcolor', $length ),
+ $self->setting( $label => 'bgcolor', $length, $summary_mode ),
$override->{'bgcolor'}
)
)
@@ -302,7 +293,7 @@ END
th( { -align => 'right' }, 'Peak gradient start'),
td( $picker->color_pick(
'conf_start_color',
- $data_source->semantic_fallback_setting( $label => 'start_color', $length ),
+ $self->setting( $label => 'start_color', $length, $summary_mode ),
$override->{'start_color'}
)
)
@@ -313,7 +304,7 @@ END
th( { -align => 'right' }, 'Peak gradient end'),
td( $picker->color_pick(
'conf_end_color',
- $data_source->semantic_fallback_setting( $label => 'end_color', $length ),
+ $self->setting( $label => 'end_color', $length, $summary_mode ),
$override->{'end_color'}
)
)
@@ -322,7 +313,7 @@ END
th( { -align => 'right' }, $render->translate('FG_COLOR') ),
td( $picker->color_pick(
'conf_fgcolor',
- $data_source->semantic_fallback_setting( $label => 'fgcolor', $length ),
+ $self->setting( $label => 'fgcolor', $length, $summary_mode ),
$override->{'fgcolor'}
)
)
@@ -464,7 +455,7 @@ END
td( $picker->popup_menu(
-name => 'conf_height',
-current => $override->{'height'},
- -default => $summary_mode ? 15 : $height,
+ -default => $height,
-values => [
sort { $a <=> $b }
( $height, map { $_ * 5 } ( 1 .. 20 ) )
@@ -560,6 +551,26 @@ END
return $return_html;
}
+sub setting {
+ my $self = shift;
+ my ($label,$option,$length,$is_summary) = @_;
+ my $data_source = $self->render->data_source();
+
+ # bad hack
+ if ($is_summary) {
+ if ($data_source->Bio::Graphics::FeatureFile::setting("$label:summary")) {
+ return $data_source->semantic_fallback_setting("$label:summary",$option,$length);
+ } else {
+ return 'wiggle_density' if $option eq 'glyph';
+ return 15 if $option eq 'height';
+ return 0 if $option eq 'min_score';
+ return 'local' if $option eq 'autoscale';
+ }
+ }
+
+ return $data_source->semantic_fallback_setting($label,$option,$length);
+}
+
sub region_size_menu {
my $self = shift;
my ($name,$length,$extra_val) = @_;
@@ -1149,7 +1149,7 @@ sub make_scale_feature {
my ($segment,$width) = @_;
return unless $segment;
- my $length = $segment->length / $self->details_mult;
+ my $length = $segment->length;
my ($guesstimate, $label) = $self->calculate_scale_size($length, $width);
@@ -1638,7 +1638,7 @@ sub add_features_to_track {
my (@full_types,@summary_types);
for my $l (@labels) {
my @types = $source->label2type($l,$length) or next;
- if ($source->show_summary($l,$self->vis_length,$self->settings)) {
+ if ($source->show_summary($l,$length,$self->settings)) {
$is_summary{$l}++;
push @summary_types,@types;
} else {
@@ -1687,7 +1687,7 @@ sub add_features_to_track {
$l =~ s/:\d+//; # get rid of semantic zooming tag
my $track = $tracks->{$l} or next;
-
+
my $stt = $self->subtrack_manager($l);
my $is_summary = $is_summary{$l};
@@ -2089,13 +2089,12 @@ sub create_track_args {
my $source = $self->source;
my $lang = $self->language;
- my $is_summary = $source->show_summary($label,$self->vis_length,$self->settings);
-
+ my $is_summary = $source->show_summary($label,$length,$self->settings);
my $state = $self->settings;
my $semantic_override = Bio::Graphics::Browser2::Render->find_override_region(
$state->{features}{$label}{semantic_override},
- $length/$self->details_mult);
+ $length);
my $override = $is_summary ? $state->{features}{$label}{summary_override}
: $semantic_override ? $state->{features}{$label}{semantic_override}{$semantic_override}
: {};
@@ -2105,14 +2104,15 @@ sub create_track_args {
push @override,(-feature_limit => $override->{limit}) if $override->{limit};
push @override,(-record_label_positions => 0) unless $args->{section} && $args->{section} eq 'detail';
+ my @summary_args = ();
if ($is_summary) {
- unshift @override,(
- -glyph => 'wiggle_density',
- -height => 15,
- -min_score => 0,
- -autoscale => 'local',
- );
- push @override, $source->i18n_style("$label:summary",$lang) if $source->Bio::Graphics::FeatureFile::setting("$label:summary");
+ @summary_args = $source->Bio::Graphics::FeatureFile::setting("$label:summary")
+ ? $source->i18n_style("$label:summary",$lang)
+ : (-glyph => 'wiggle_density',
+ -height => 15,
+ -min_score => 0,
+ -autoscale => 'local',
+ );
}
my $hilite_callback = $args->{hilite_callback};
@@ -2157,12 +2157,14 @@ sub create_track_args {
@default_args,
$source->default_style,
$source->i18n_style($label,$lang),
+ @summary_args,
@override,
);
} else {
@args = (@default_args,
$source->default_style,
$source->i18n_style($label,$lang,$length),
+ @summary_args,
@override,
);
}

0 comments on commit 96156ed

Please sign in to comment.