Permalink
Browse files

support for placing cap on number of features to display per track; n…

…eed bio::graphics 1.97 or higher
  • Loading branch information...
1 parent 0c7053a commit c7094853094c802df9447aa0ee3863526a274825 @lstein lstein committed Jul 2, 2009
View
@@ -1,4 +1,5 @@
1.996 * Add "feature limit" option to keep very populous tracks under control.
+ * Attempt to fix problem of FastCGI processes hanging around even after apache restarted.
1.995 * Install to an alternate location (e.g. home directory) by using --install_base argument when
calling perl Build.PL.
* Don't overwrite user's configuration files when doing an upgrade install!
View
@@ -20,7 +20,6 @@ if ($fcgi) {
};
while (!$FCGI_DONE && ($fcgi->Accept >= 0)) {
- print STDERR "accepted request\n";
my $globals = Bio::Graphics::Browser->open_globals;
CGI->initialize_globals();
Bio::Graphics::Browser::Render::HTML->new($globals)->run();
View
@@ -245,6 +245,8 @@ END
NO_TRACKS => '*none*',
+ FEATURES_CLIPPED => 'Showing %s of %s features',
+
FILE_INFO => 'Last modified %s. Annotated landmarks: %s',
FOOTER_1 => <<END,
@@ -318,7 +320,7 @@ END
FORMAT => 'Format',
- LIMIT => 'Limit',
+ LIMIT => 'Max. features to show',
ADJUST_ORDER => 'Adjust Order',
@@ -426,6 +428,8 @@ END
LINEWIDTH => 'Line width',
+ STRANDED => 'Show strand',
+
DEFAULT => '(default)',
DYNAMIC_VALUE => 'Dynamically calculated',
View
@@ -237,6 +237,8 @@ END
NO_TRACKS => '*none*',
+ FEATURES_CLIPPED => 'Showing %s of %s features',
+
FILE_INFO => 'Last modified %s. Annotated landmarks: %s',
FOOTER_1 => <<END,
@@ -310,7 +312,7 @@ END
FORMAT => 'Format',
- LIMIT => 'Limit',
+ LIMIT => 'Max. features to show',
ADJUST_ORDER => 'Adjust Order',
@@ -420,6 +422,8 @@ END
LINEWIDTH => 'Line width',
+ STRANDED => 'Show strand',
+
DEFAULT => '(default)',
DYNAMIC_VALUE => 'Dynamically calculated',
@@ -1970,15 +1970,17 @@ sub reconfigure_track {
my $self = shift;
my $label = shift;
my $state = $self->state();
- $state->{features}{$label}{visible} = param('show_track') ? 1 : 0;
- $state->{features}{$label}{options} = param('format_option');
- $state->{features}{$label}{limit} = param('limit');
+ $state->{features}{$label}{visible} = param('show_track') ? 1 : 0;
+ $state->{features}{$label}{options} = param('format_option');
+ $state->{features}{$label}{limit} = param('limit');
my $dynamic = $self->tr('DYNAMIC_VALUE');
for my $s ( 'bgcolor', 'fgcolor', 'height', 'glyph', 'linewidth' ) {
my $value = param($s);
- delete $state->{features}{$label}{override_settings}{$s}, next
- if $value eq $dynamic;
- $state->{features}{$label}{override_settings}{$s} = $value;
+ if ($value eq $dynamic) {
+ delete $state->{features}{$label}{override_settings}{$s};
+ } else {
+ $state->{features}{$label}{override_settings}{$s} = $value;
+ }
}
$state->{features}{$label}{override_settings}{stranded} = param('stranded') || 0;
}
@@ -1620,6 +1620,7 @@ sub track_config {
if ( param('track_defaults') ) {
$state->{features}{$label}{override_settings} = {};
+ $state->{features}{$label}{limit} = $data_source->fallback_setting( $label => 'feature_limit');
}
my $override = $state->{features}{$label}{override_settings}||{};
@@ -1634,12 +1635,14 @@ sub track_config {
my $width = $data_source->fallback_setting( $label => 'linewidth' ) || 1;
my $glyph = $data_source->fallback_setting( $label => 'glyph' ) || 'box';
my $stranded = $data_source->fallback_setting( $label => 'stranded');
+ my $dynamic = $self->tr('DYNAMIC_VALUE');
+
my @glyph_select = shellwords(
$data_source->fallback_setting( $label => 'glyph select' ) );
@glyph_select
- = qw(arrow anchored_arrow box crossbox dashed_line diamond dna dot dumbbell ellipse
+ = ($dynamic,qw(arrow anchored_arrow box crossbox dashed_line diamond dna dot dumbbell ellipse
ex line primers saw_teeth segments span splice_site translation triangle
- two_bolts wave) unless @glyph_select;
+ two_bolts wave)) unless @glyph_select;
my %glyphs = map { $_ => 1 } ( $glyph, @glyph_select );
my $url = url( -absolute => 1, -path => 1 );
@@ -1736,12 +1739,12 @@ END
)
),
TR( th( { -align => 'right' }, $self->tr('Limit') ),
- td( popup_menu(
- -name => 'limit',
- -values => [ 0, 5, 10, 25, 100 ],
+ td( $picker->popup_menu(
+ -name => 'limit',
+ -values => [ 0, 5, 10, 25, 50, 100, 200, 500, 1000 ],
-labels => { 0 => $self->tr('No_limit') },
-override => 1,
- -default => $state->{features}{$label}{limit}
+ -default => $state->{features}{$label}{limit},
)
)
),
@@ -1333,10 +1333,15 @@ sub add_features_to_track {
my (%iterators,%iterator2dbid);
for my $db (keys %db2db) {
- my @types_in_this_db = map { $source->label2type($_,$length) } keys %{$db2label{$db}};
+ my @labels = keys %{$db2label{$db}};
+ my @types_in_this_db = map { $source->label2type($_,$length) } @labels;
next unless @types_in_this_db;
- my $iterator = $self->get_iterator($db2db{$db},$segment,\@types_in_this_db)
+
+ my $iterator = $self->get_iterator($db2db{$db},
+ $segment,
+ \@types_in_this_db)
or next;
+
$iterators{$iterator} = $iterator;
$iterator2dbid{$iterator} = $source->db2id($db);
}
@@ -1346,7 +1351,7 @@ sub add_features_to_track {
# The effect of this loop is to fetch a feature from each iterator in turn
# using a queueing scheme. This allows streaming iterators to parallelize a
# bit. This may not be worth the effort.
- my (%feature2dbid,%classes,%max_features,%limit_hit);
+ my (%feature2dbid,%classes);
while (keys %iterators) {
for my $iterator (values %iterators) {
@@ -1368,19 +1373,8 @@ sub add_features_to_track {
my $track = $tracks->{$l} or next;
-
- $max_features{$l} = $source->fallback_setting($l => 'feature limit') || 0
- unless exists $max_features{$l};
-
$filters->{$l}->($feature) or next if $filters->{$l};
$feature_count{$l}++;
-
- if ($max_features{$l}
- && $feature_count{$l}
- && $feature_count{$l} >= $max_features{$l}) {
- $limit_hit{$l}++;
- next;
- }
# -----------------------------------------------------------------------------
# GROUP CODE
@@ -1472,12 +1466,15 @@ sub add_features_to_track {
-description => $do_description,
);
$tracks->{$l}->configure(-connector => 'none') if !$do_bump;
- $tracks->{$l}->configure(-bump_limit => $limit)
+ $tracks->{$l}->configure(-bump_limit => $limit,
+ -feature_limit => $limit)
if $limit && $limit > 0;
- if ($limit_hit{$l}) {
+ if (eval{$tracks->{$l}->features_clipped}) { # may not be present in older Bio::Graphics
+ my $max = $tracks->{$l}->feature_limit;
+ my $count = $tracks->{$l}->feature_count;
$tracks->{$l}->panel->key_style('between');
- $tracks->{$l}->configure(-key => "Showing $max_features{$l} of $feature_count{$l} features");
+ $tracks->{$l}->configure(-key => $self->language->tr('FEATURES_CLIPPED',$max,$count));
}
}
}
@@ -1516,7 +1513,7 @@ sub load_external_sources {
sub get_iterator {
my $self = shift;
- my ($db,$segment,$feature_types) = @_;
+ my ($db,$segment,$feature_types,$max) = @_;
# The Bio::DB::SeqFeature::Store database supports correct
# semantics for directly retrieving features that overlap
@@ -1528,7 +1525,9 @@ sub get_iterator {
my @args = (-type => $feature_types,
-seq_id => $segment->seq_id,
-start => $segment->start,
- -end => $segment->end);
+ -end => $segment->end,
+ -max_features => $max, # some adaptors allow this
+ );
return $db->get_seq_stream(@args);
}
@@ -1719,6 +1718,8 @@ sub create_track_args {
my $override = $self->settings->{features}{$label}{override_settings} || {}; # user-set override settings for tracks
my @override = map {'-'.$_ => $override->{$_}} keys %$override;
+ push @override,(-feature_limit => $self->settings->{features}{$label}{limit}||0);
+
my $hilite_callback = $args->{hilite_callback};
my $length = $segment->length;
@@ -1755,6 +1756,7 @@ sub create_track_args {
@override,
);
}
+
return @args;
}

0 comments on commit c709485

Please sign in to comment.