Permalink
Browse files

Restore h_feat & h_region functionality to gbrowse_img.

  • Loading branch information...
1 parent eefe6e3 commit a64c8a66d2f7aa279e5e76f191c1705f439ac279 @lstein lstein committed Dec 16, 2011
Showing with 40 additions and 14 deletions.
  1. +3 −0 Changes
  2. +31 −11 cgi-bin/gbrowse_img
  3. +6 −3 lib/Bio/Graphics/Browser2/RegionSearch.pm
View
@@ -1,3 +1,6 @@
+2.45
+ * Restore h_feat & h_region functionality to gbrowse_img.
+
2.44
* Modest performance improvements when rendering multiple tracks.
* Set absolute cap of 5000 features per track to avoid performance issues on NGS data.
View
@@ -1,11 +1,5 @@
#!/usr/bin/perl -w
-eval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}'
- if 0; # not running under some shell
-
-eval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}'
- if 0; # not running under some shell
-
# $Id: gbrowse_img,v 1.7 2009-08-31 19:46:38 lstein Exp $
use strict;
@@ -64,7 +58,6 @@ if ($fcgi) {
my $gbi = GBrowse_img->new($globals);
$gbi->run();
$gbi->destroy;
-# $fcgi->Finish();
}
}
@@ -208,6 +201,11 @@ sub render_image {
my $flip = param('flip') || 0;
my $embed = param('embed');
+ if (my @regions = param('h_region')) {
+ $render->state->{h_region} = \@regions;
+ }
+
+
my $convert_to_pdf;
if ($format eq 'PDF' && `which inkscape`) {
$convert_to_pdf++;
@@ -302,11 +300,10 @@ sub render_tracks {
my @labels = $render->expand_track_names($render->detail_tracks);
warn "labels = ",join ',',@labels if DEBUG;
-# my @types = (param('t'),param('type'),param('track'));
-# my @track_types = map { s/%%/-/g; $_ } # unescape %% as "-", damage done in gbrowse link generator
-# map { split /[ +-]/ } @types;
my @track_types = map {shellwords($_)} (param('t'),param('type'),param('track'));
+ my $h_callback = make_hilite_callback(param('h_feat'));
+
# If no tracks specified, we want to see all tracks with this feature
if (!@track_types) { @track_types = @labels; }
unshift @track_types,'_scale';
@@ -316,9 +313,10 @@ sub render_tracks {
labels => \@track_types,
external_features => $external,
section => 'detail',
- cache_extra => [$format],
+ cache_extra => [$format,param('h_feat'),param('h_region')],
image_class => $format,
flip => $flip,
+ hilite_callback => $h_callback || undef,
-key_style => 'between',
-suppress_key => 0,
}
@@ -380,6 +378,28 @@ sub consolidate_images {
: $self->_consolidate_gd ($width,$height,$gds,$orientation,$labels);
}
+sub make_hilite_callback {
+ my @feature_names = @_;
+ return unless @feature_names;
+ my %colors;
+ foreach (@feature_names) {
+ my ($name,$color) = split '@';
+ $color ||= 'yellow';
+ $colors{$name} = $color;
+ }
+ return sub {
+ my $feature = shift;
+ my $color;
+ # if we get here, we select the search term for highlighting
+ my %names = map {lc $_=> 1}
+ $feature->display_name,
+ eval{$feature->get_tag_values('Alias')};
+ return unless %names;
+ $color ||= $colors{$_} foreach keys %names;
+ return $color;
+ }
+}
+
sub _consolidate_gd {
my $self = shift;
my ($width,$height,$gds,$orientation,$labels) = @_;
@@ -396,6 +396,9 @@ sub _search_features_locally {
warn "dbs = @dbids" if DEBUG;
my %seenit;
+ # prevent uninit variable warnings here
+ $args->{-name} ||= '';
+
for my $dbid (@dbids) {
my $opts = $self->source->search_options($dbid);
next if $opts =~ /none/i && $args->{-name} !~ /^id:/;
@@ -409,18 +412,18 @@ sub _search_features_locally {
searchopts => $opts,
}
);
- my $features = $region->search_features($args);
+ my $features = $region->search_features($args);
warn $features && @$features ? "[$$] got @$features" : "[$$] got no features" if DEBUG;
next unless $features && @$features;
$features = $self->filter_features($dbid,$features);
$self->add_dbid_to_features($dbid,$features);
push @found,@$features;
-
+
if ($dbid eq $default_dbid && $shortcircuit) {
warn "hit @found in the default database, so short-circuiting" if DEBUG;
last;
}
-
+
}
return \@found;

0 comments on commit a64c8a6

Please sign in to comment.