Permalink
Browse files

* Implemented a new caching scheme for communicating with renderfarm …

…slaves.

    This will improve performance, but requires Bio::Graphics version 1.05.
* Reverted to older versions of prototype and scriptaculous due to Google
    Chrome incompatibilities.
* Preferred way to separate labels is now to use the "l" option and separate
    labels with "%1E", as in "l=mdc-1%1Esma-23%1Eunknown genes"
* Work around race conditions in the 05.deferredrendering regression tests.
     May still fail if system is under lots of load during test.
  • Loading branch information...
1 parent 7649dc7 commit 21357b4d0cd3ec861f103fe79c71f3761a4f9545 @lstein lstein committed May 7, 2010
View
5 Changes
@@ -2,7 +2,10 @@
This will improve performance, but requires Bio::Graphics version 1.05.
* Reverted to older versions of prototype and scriptaculous due to Google
Chrome incompatibilities.
- * Can separate labels with ' ', '+' or "%20" when calling the URL via a label=label1+label2+label3.
+ * Preferred way to separate labels is now to use the "l" option and separate
+ labels with "%1E", as in "l=mdc-1%1Esma-23%1Eunknown genes"
+ * Work around race conditions in the 05.deferredrendering regression tests.
+ May still fail if system is under lots of load during test.
2.04 * Can set the subtracks to be displayed by default using the new "select default" option.
* New syntax for select option:
select = type ;
View
21 DISCLAIMER
@@ -1,11 +1,12 @@
-The Generic Genome Browser package and all associated files are
-Copyright (c) 2002 Cold Spring Harbor Laboratory and University of
-California, Berkeley.
+The Generic Genome Browser package versions between 1.0 and 1.8 and
+all associated files are Copyright (c) 2002 Cold Spring Harbor
+Laboratory and University of California, Berkeley. Versions 1.9 and
+higher are copyright (c) 2010 Ontario Institute for Cancer Research.
-This library is free software; you can redistribute it and/or modify
-it under the same terms as Perl itself. See the Artistic License file
-in the main Perl distribution for specific terms and conditions of
-use. In addition, the following disclaimers apply:
+This package and its accompanying libraries is free software; you can
+redistribute it and/or modify it under the terms of the GPL (either
+version 1, or at your option, any later version) or the Artistic
+License 2.0. Refer to LICENSE for the full license text.
CSHL makes no representations whatsoever as to the SOFTWARE contained
herein. It is experimental in nature and is provided WITHOUT WARRANTY
@@ -20,6 +21,6 @@ nature, which may arise from your Institution's respective use,
handling or storage of the SOFTWARE.
If publications result from research using this SOFTWARE, we ask that
-CSHL and University of California, Berkeley be acknowledged and/or
-credit be given to CSHL/Berkeley scientists, as scientifically
-appropriate.
+CSHL, University of California, Berkeley and the Ontario Institute for
+Cancer Research be acknowledged and/or credit be given to
+CSHL/Berkeley/OICR scientists, as scientifically appropriate.
View
4 LICENSE
@@ -1,3 +1,7 @@
+This package and its accompanying libraries is free software; you may
+redistribute it and/or modify it under the terms of either of these
+licenses:
+
a) the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any
later version, or
View
13 README
@@ -131,9 +131,19 @@ www.gmod.org.
Lincoln Stein & the GMOD team
lincoln.stein@gmail.com
-October 2008
+April 2010
+--- COPYRIGHT AND LICENSING ---
+
+Copyright (c) 2002 Cold Spring Harbor Laboratory and University of California, Berkeley
+Copyright (c) 2010 Ontario Institute for Cancer Research
+
+This package and its accompanying libraries is free software; you can
+redistribute it and/or modify it under the terms of the GPL (either
+version 1, or at your option, any later version) or the Artistic
+License 2.0. Refer to LICENSE for the full license text.
+
--- AUTHORS ---
This project has had many authors. Some of the most prominent are:
@@ -147,6 +157,7 @@ Sheldon McKay <mckays@cshl.edu>
Nathan O. Siemers <Nathan.Siemers@bms.com>
Ian Davies <i.davies2@rogers.com>
Lincoln Stein <lincoln.stein@gmail.com>
+Peter Ruzanov <peter.ruzanov@oicr.on.ca>
Special thanks go to the authors of the translations, who include:
View
4 htdocs/js/controller.js
@@ -64,9 +64,11 @@ var GBrowseController = Class.create({
this.globals.set(name, obj[name])
}
+ var me = this;
+
//generate *_url accessors
var mk_url_accessor = function( conf_name, acc_name) {
- Controller[acc_name] = function(relpath) { this.globals.get(conf_name) + '/' + relpath }
+ me[acc_name] = function(relpath) { return this.globals.get(conf_name) + '/' + relpath; }
};
mk_url_accessor( 'buttons', 'button_url' );
mk_url_accessor( 'balloons', 'balloon_url' );
View
11 lib/Bio/Graphics/Browser2/DataLoader.pm
@@ -205,15 +205,20 @@ sub category {
sub backend {
my $self = shift;
- my $backend = $self->setting('userdb_adaptor') || $self->guess_backend;
+ my $backend = $self->setting('userdb_adaptor');
+ $backend = $self->guess_backend if $backend && $backend eq 'auto';
+ unless ($backend) {
+ $backend = $self->guess_backend;
+ warn "No userdb_adaptor option set in GBrowse.conf. Will try to use $backend.";
+ }
return $backend;
}
sub guess_backend {
my $self = shift;
my %db_drivers = map {$_=>1} DBI->available_drivers(1);
- return 'DBI::SQLite' if $db_drivers{SQLite} && eval "require Bio::DB::SeqFeature::Store::DBI::SQLite";
- return 'berkeleydb' if eval "require Bio::DB::SeqFeature::Store::berkeleydb; 1";
+ return 'DBI::SQLite' if $db_drivers{SQLite} && eval "require Bio::DB::SeqFeature::Store::DBI::SQLite; 1";
+ return 'berkeleydb' if eval "require Bio::DB::SeqFeature::Store::berkeleydb; 1";
return 'DBI::mysql' if $db_drivers{mysql};
return 'memory';
}
View
13 lib/Bio/Graphics/Browser2/DataSource.pm
@@ -356,6 +356,19 @@ sub i18n_style {
%lang_options;
}
+# return true if we should show a coverage summary for this
+# track at the current length
+sub show_summary {
+ my $self = shift;
+ my ($label,$length) = @_;
+ my $c = $self->semantic_fallback_setting($label=>'show_summary',$length);
+ return 0 unless defined $c;
+ return 0 unless $c <= $length;
+ my $db = $self->open_database($label,$length) or return;
+ return 0 unless $db->can('feature_summary');
+ return 1;
+}
+
sub clear_usertracks {
my $self = shift;
delete $self->{_user_tracks};
View
1 lib/Bio/Graphics/Browser2/GFFPrinter.pm
@@ -100,7 +100,6 @@ sub print_gff3 {
$self->dump_track($labels->[0]);
return;
}
-
my $segment= $self->get_segment;
my $types = $labels ? $self->labels_to_types($labels,eval{$segment->length}) : undef;
my $files = $labels ? $self->labels_to_files($labels,eval{$segment->length}) : undef;
View
4 lib/Bio/Graphics/Browser2/Region.pm
@@ -199,7 +199,7 @@ sub search_db {
my $args = shift;
my ($features);
if (my $name = $args->{-search_term}) {
- $name =~ tr/a-zA-Z0-9.'"_*?:+-//cd; # remove rude characters
+ $name =~ tr/a-zA-Z0-9.'"_*?: ;+-//cd; # remove rude characters
my ($ref,$start,$stop,$class,$id) = $self->parse_feature_name($name);
$features = $self->lookup_features($ref,$start,$stop,$class,$name,$id);
}
@@ -376,7 +376,7 @@ sub _feature_keyword_search {
# Need to untaint the searchterm. We are very lenient about
# what is accepted here because we wil be quote-metaing it later.
- $searchterm =~ /([\w .,~!@\#$%^&*()-+=<>?\/]+)/;
+ $searchterm =~ /([\w .,~!@\#$%^&*()-+=<>?:;\/]+)/;
$searchterm = $1;
my $db = $self->db;
View
52 lib/Bio/Graphics/Browser2/Render.pm
@@ -33,6 +33,7 @@ use constant MAX_SEGMENT => 1_000_000;
use constant TOO_MANY_SEGMENTS => 5_000;
use constant OVERVIEW_RATIO => 1.0;
use constant GROUP_SEPARATOR => "\x1d";
+use constant LABEL_SEPARATOR => "\x1e";
my %PLUGINS; # cache initialized plugins
my $FCGI_REQUEST; # stash fastCGI request handle
@@ -1254,21 +1255,14 @@ sub handle_gff_dump {
my %actions = map {$_=>1} split /\s+/,$gff_action;
my $segment = param('q') || param('segment') || undef;
- my @labels = (param('type'),param('t'));
+
+ my @labels = $self->split_labels_correctly(param('l'));
+ @labels = $self->split_labels((param('type'),param('t'))) unless @labels;
+ @labels = $self->visible_tracks unless @labels;
my $title = join('+',@labels);
$title .= ":$segment" if $segment;
-# unless ($segment) {
-# my $s = $self->segment;
-# $segment = $s->seq_id.':'.$s->start.'..'.$s->end;
-# }
-
-
- unless (@labels) {
- @labels = $self->visible_tracks;
- }
-
my $dumper = Bio::Graphics::Browser2::GFFPrinter->new(
-data_source => $self->data_source(),
-stylesheet => $actions{trackdef} || 'no',
@@ -2070,8 +2064,13 @@ sub update_tracks {
$self->add_remote_tracks(\@unescaped);
}
- # selected tracks can be set by the 'label' parameter
- if (my @l = param('label')) {
+ # selected tracks can be set by the 'l', 'label' or 't' parameter
+ # the preferred parameter is 'l', because it implements correct
+ # semantics for the label separator
+ if (my @l = param('l')) {
+ $self->set_tracks($self->split_labels_correctly(@l));
+ }
+ elsif (@l = param('label')) {
$self->set_tracks($self->split_labels(@l));
} #... the 't' parameter
elsif (my @t = param('t')) {
@@ -2084,11 +2083,11 @@ sub update_tracks {
$self->set_tracks($self->data_source->track_source_to_label(@ts));
}
- if (my @selected = $self->split_labels(param('enable'))) {
+ if (my @selected = $self->split_labels_correctly(param('enable'))) {
$state->{features}{$_}{visible} = 1 foreach @selected;
}
- if (my @selected = $self->split_labels(param('disable'))) {
+ if (my @selected = $self->split_labels_correctly(param('disable'))) {
$state->{features}{$_}{visible} = 0 foreach @selected;
}
@@ -2778,6 +2777,14 @@ sub regionview_bounds {
return ($regionview_start, $regionview_end);
}
+# this version handles labels with embedded hyphens correctly
+sub split_labels_correctly {
+ my $self = shift;
+ return map {split LABEL_SEPARATOR,$_} @_;
+}
+
+# this version does not handle labels with embedded "+" or "-"
+# unless the hyphen is escaped with %01d
sub split_labels {
my $self = shift;
my @results;
@@ -2789,16 +2796,7 @@ sub split_labels {
push @results,$_;
next;
}
-
- # if the label contains a space, then split on the space
- if (/\s/) {
- push @results, split /\s+/,$_;
- next;
- }
-
- # else split on "+" and "-" symbols
push @results, split /[+-]/;
-
}
my $group_separator = GROUP_SEPARATOR;
@@ -3456,17 +3454,15 @@ sub general_help {
sub join_selected_tracks {
my $self = shift;
my $state = $self->state;
- my $group_separator = GROUP_SEPARATOR;
my @selected = $self->visible_tracks;
for (@selected) { # escape hyphens
if ((my $filter = $state->{features}{$_}{filter}{values})) {
my @subtracks = grep {$filter->{$_}} keys %{$filter};
$_ .= "/@subtracks";
}
- s/-/$group_separator/g;
}
- return join '-',@selected;
+ return join LABEL_SEPARATOR,@selected;
}
sub bookmark_link {
@@ -3479,7 +3475,7 @@ sub bookmark_link {
$q->param(-name=>$_, -value=>$settings->{$_});
}
$q->param(-name=>'id', -value=>$settings->{userid}); # slight inconsistency here
- $q->param(-name=>'label',-value=>$self->join_selected_tracks);
+ $q->param(-name=>'l', -value=>$self->join_selected_tracks);
$q->param(-name=>'h_region',-value=>$settings->{h_region}) if $settings->{h_region};
my @h_feat= map {"$_\@$settings->{h_feat}{$_}"} keys %{$settings->{h_feat}};
View
22 lib/Bio/Graphics/Browser2/Render/HTML.pm
@@ -720,30 +720,30 @@ sub galaxy_form {
$URL .= "/".$source->name;
}
- my $action = $galaxy_url =~ /\?/ ? "$galaxy_url&URL=$URL" : "$galaxy_url?URL=$URL";
-
- my $html = start_multipart_form(-name => 'galaxyform',
- -action => $action,
- -method => 'POST');
-
+
# Make sure to include all necessary parameters in URL to ensure that gbrowse will retrieve the data
# when Galaxy posts the URL.
my $dbkey = $source->global_setting('galaxy build name') || $source->name;
- my $labels = join('+',map {escape($_)} $self->detail_tracks);
+ my $labels = $self->join_selected_tracks;
my $seg = $segment->seq_id.':'.$segment->start.'..'.$segment->end;
+ my $action = $galaxy_url =~ /\?/ ? "$galaxy_url&URL=$URL" : "$galaxy_url?URL=$URL";
+ my $html = start_multipart_form(-name => 'galaxyform',
+ -action => $action,
+ -method => 'POST');
+
$html .= hidden(-name=>'dbkey',-value=>$dbkey);
- $html .= hidden(-name=>'gbgff',-value=>1);
+ $html .= hidden(-name=>'gbgff',-value=>'save gff3');
$html .= hidden(-name=>'id', -value=>$settings->{userid});
$html .= hidden(-name=>'q',-value=>$seg);
- $html .= hidden(-name=>'t',-value=>$labels);
+ $html .= hidden(-name=>'l',-value=>$labels);
$html .= hidden(-name=>'s',-value=>0);
$html .= hidden(-name=>'d',-value=>'edit');
$html .= hidden(-name=>'m',-value=>'application/x-gff3');
$html .= endform();
- return $html;
+ return $html;
}
sub render_track_filter {
@@ -906,7 +906,7 @@ sub render_track_table {
my %ids = map {$_=>{id=>"${_}_check"}} @track_labels;
- my @checkboxes = checkbox_group(-name => 'label',
+ my @checkboxes = checkbox_group(-name => 'l',
-values => \@track_labels,
-labels => \%labels,
-defaults => \@defaults,
View
66 lib/Bio/Graphics/Browser2/RenderPanels.pm
@@ -877,7 +877,10 @@ sub render_scale_bar {
-bgcolor => $source->global_setting('detail bgcolor') || 'wheat',
-pad_bottom => 0,
-label_font => $image_class->gdMediumBoldFont,
- -label => $segment->seq_id.': '.$self->source->unit_label($segment->length),
+ -label => eval{$segment->seq_id.
+ ': '
+ .$self->source->unit_label($segment->length)
+ }||'', # intermittent bug here with undefined $segment
);
}
@@ -1531,16 +1534,28 @@ sub add_features_to_track {
my (%iterators,%iterator2dbid);
for my $db (keys %db2db) {
my @labels = keys %{$db2label{$db}};
- my @types_in_this_db = map { $source->label2type($_,$length) } @labels;
- next unless @types_in_this_db;
-
- warn "[$$] RenderPanels->get_iterator(@types_in_this_db)" if DEBUG;
- my $iterator = $self->get_iterator($db2db{$db},
- $segment,
- \@types_in_this_db)
- or next;
- $iterators{$iterator} = $iterator;
- $iterator2dbid{$iterator} = $source->db2id($db);
+
+ my (@full_types,@summary_types);
+ for my $l (@labels) {
+ my @types = $source->label2type($l,$length) or next;
+ if ($source->show_summary($l,$length)) {
+ push @summary_types,@types;
+ } else {
+ push @full_types,@types;
+ }
+ }
+
+ warn "[$$] RenderPanels->get_iterator(@full_types)" if DEBUG;
+ warn "[$$] RenderPanels->get_summary_iterator(@summary_types)" if DEBUG;
+ if (@summary_types && (my $iterator = $self->get_summary_iterator($db2db{$db},$segment,\@summary_types))) {
+ $iterators{$iterator} = $iterator;
+ $iterator2dbid{$iterator} = $source->db2id($db);
+ }
+
+ if (@full_types && (my $iterator = $self->get_iterator($db2db{$db},$segment,\@full_types))) {
+ $iterators{$iterator} = $iterator;
+ $iterator2dbid{$iterator} = $source->db2id($db);
+ }
}
my (%groups,%feature_count,%group_pattern,%group_field);
@@ -1745,6 +1760,25 @@ sub get_iterator {
return $db_segment->get_feature_stream(-type=>$feature_types);
}
+sub get_summary_iterator {
+ my $self = shift;
+ my ($db,$segment,$feature_types) = @_;
+
+ if (eval {$db->can_summarize}) {
+ my @args = (-type => $feature_types,
+ -seq_id => $segment->seq_id,
+ -start => $segment->start,
+ -end => $segment->end,
+ -bins => $self->settings->{width},
+ -iterator=>1,
+ );
+ return $db->feature_summary(@args);
+ } else {
+ return;
+ }
+}
+
+
=head2 add_feature_file
Internal use: render a feature file into a panel
@@ -1923,9 +1957,17 @@ sub create_track_args {
|| {}; # user-set override settings for tracks
my @override = map {'-'.$_ => $override->{$_}} keys %$override;
-
push @override,(-feature_limit => $override->{limit}) if $override->{limit};
+ if ($source->show_summary($label,$length)) {
+ warn "HERE I AM";
+ push @override,(-glyph => 'wiggle_density',
+ -height => 14,
+ -bgcolor => 'black',
+ -autoscale => 'local'
+ );
+ }
+
my $hilite_callback = $args->{hilite_callback};
my @default_args = (-glyph => 'generic');
View
2 lib/Bio/Graphics/Karyotype.pm
@@ -188,7 +188,7 @@ sub image_map {
sub feature2link {
my $self = shift;
my $feature = shift;
- my $url = url(-path_info=>1)."?name=";
+ my $url = url(-absolute=>1,-path_info=>1)."?name=";
my $match_id = eval {$feature->primary_id};
my $class = eval {$feature->class};
my $name = $feature->display_name || '';
View
23 t/03.render.t
@@ -15,7 +15,7 @@ use FindBin '$Bin';
use lib "$Bin/testdata";
use TemplateCopy; # for the template_copy() function
-use constant TEST_COUNT => 139;
+use constant TEST_COUNT => 138;
use constant CONF_FILE => "$Bin/testdata/conf/GBrowse.conf";
my $PID;
@@ -25,13 +25,15 @@ BEGIN {
# we include the t dir (where a copy of Test.pm is located)
# as a fallback
eval { require Test; };
+ use Bio::Graphics::FeatureFile;
if( $@ ) {
use lib 't';
}
use Test;
plan test => TEST_COUNT;
$PID = $$;
- rmtree '/tmp/gbrowse_testing';
+ rmtree('/tmp/gbrowse_testing');
+ rmtree(Bio::Graphics::FeatureFile->cachedir);
}
END {
rmtree '/tmp/gbrowse_testing' if $$ == $PID;
@@ -40,11 +42,8 @@ END {
$SIG{SEGV} = $SIG{HUP} = $SIG{INT} = $SIG{TERM} = \&cleanup;
%ENV = ();
-$ENV{GBROWSE_DOCS} = $Bin;
-$ENV{TMPDIR} = '/tmp/gbrowse_testing';
-
-chdir $Bin;
use lib "$Bin/../lib";
+
use Bio::Graphics::Browser2;
use Bio::Graphics::Browser2::Render::HTML;
use Bio::Graphics::Browser2::Render::Slave;
@@ -56,6 +55,10 @@ my @servers = (Bio::Graphics::Browser2::Render::Slave->new(LocalPort=>'dynamic')
Bio::Graphics::Browser2::Render::Slave->new(LocalPort=>'dynamic'), # cleavage sites
);
+chdir $Bin;
+$ENV{GBROWSE_DOCS} = $Bin;
+$ENV{TMPDIR} = '/tmp/gbrowse_testing';
+
# rewrite the template config files
for ('volvox_final.conf','yeast_chr1.conf') {
template_copy("testdata/conf/templates/$_",
@@ -452,18 +455,14 @@ $png =~ s!/gbrowse/i!/tmp/gbrowse_testing/images!;
ok (-e $png);
# test different ways of splitting labels
-$CGI::Q = new CGI('name=ctgA:1..20000;label=Clones Motifs BindingSites TransChip');
+$CGI::Q = new CGI('name=ctgA:1..20000;l=Clones%1EMotifs%1EBindingSites%1ETransChip');
$render->update_state;
ok(join(' ',sort $render->detail_tracks),"BindingSites Clones Motifs TransChip");
-$CGI::Q = new CGI('name=ctgA:1..20000;label=Clones+Motifs+BindingSites');
+$CGI::Q = new CGI('name=ctgA:1..20000;label=Clones-Motifs-BindingSites');
$render->update_state;
ok(join(' ',sort $render->detail_tracks),"BindingSites Clones Motifs");
-$CGI::Q = new CGI('name=ctgA:1..20000;label=Clones%20Motifs%20BindingSites%20TransChip');
-$render->update_state;
-ok(join(' ',sort $render->detail_tracks),"BindingSites Clones Motifs TransChip");
-
### check user tracks
my $usertracks = $render->user_tracks;
ok($usertracks);
View
8 t/05.deferredrendering.t
@@ -30,13 +30,19 @@ BEGIN {
$PID = $$;
+ use Bio::Graphics::FeatureFile;
rmtree '/tmp/gbrowse_testing';
+ rmtree(Bio::Graphics::FeatureFile->cachedir);
}
END {
rmtree '/tmp/gbrowse_testing' if $$ == $PID;
}
# %ENV = ();
+%ENV = ();
+$ENV{GBROWSE_DOCS} = $Bin;
+$ENV{TMPDIR} = '/tmp/gbrowse_testing';
+
chdir $Bin;
use lib "$Bin/../lib";
@@ -110,7 +116,7 @@ while (time()-$time < 10) {
$status_counts{$requests->{$label}->status}++;
}
last if ($status_counts{AVAILABLE}||0) == 5;
- usleep(0.1);
+ usleep(0.2);
}
# each track should start with either EMPTY or PENDING and end with AVAILABLE
View
2 t/testdata/conf/GBrowse.conf
@@ -22,6 +22,8 @@ language_path = languages
templates_path = templates
moby_path = MobyServices
+userdb_adaptor = auto
+
# session settings
session driver = driver:file;serializer:default
session args = Directory /tmp/gbrowse_testing/sessions

0 comments on commit 21357b4

Please sign in to comment.