Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added track filtering functionality as well as ability to select trac…
…ks by their source
- Loading branch information
Showing
11 changed files
with
457 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package Bio::Graphics::Browser::Plugin::SimpleTrackFinder; | ||
# $Id: SimpleTrackFinder.pm,v 1.1 2009-05-20 20:36:20 lstein Exp $ | ||
use strict; | ||
use CGI qw(:standard *table); | ||
use base 'Bio::Graphics::Browser::Plugin'; | ||
our $VERSION = '0.25'; | ||
|
||
sub name { "Simple Track Finder" } | ||
|
||
sub description { | ||
return p("The simple track finder filters the track table by the name of the track."); | ||
} | ||
|
||
sub type { 'trackfilter' } | ||
|
||
sub init { } | ||
|
||
sub config_defaults { | ||
my $self = shift; | ||
return { | ||
track_name => undef, | ||
}; | ||
} | ||
|
||
sub reconfigure { | ||
my $self = shift; | ||
my $current_config = $self->configuration; | ||
$current_config->{track_name} = $self->config_param('track_name'); | ||
} | ||
|
||
sub configure_form { | ||
my $self = shift; | ||
my $current_config = $self->configuration; | ||
my $name = $current_config->{track_name}; | ||
return | ||
b('Partial or full track name:'). | ||
textfield(-id => 'track_name_filter', | ||
-name => $self->config_name('track_name'), | ||
-default => $name, | ||
-override => 1, | ||
-onKeyDown=>'if (event.keyCode==13) doPluginUpdate()', | ||
). | ||
button(-value => 'Clear', | ||
-onClick => "\$('track_name_filter').clear(); doPluginUpdate()"); | ||
} | ||
|
||
sub filter_tracks { | ||
my $self = shift; | ||
my $tracks = shift; | ||
my $source = shift; | ||
|
||
my $config = $self->configuration; | ||
my $name = $config->{track_name} or return @$tracks; | ||
|
||
my @filtered = grep { | ||
my $key = $source->setting($_=>'key') || $_; | ||
$key =~ m/$name/i | ||
} @$tracks; | ||
warn "name = $name, filtered = @filtered"; | ||
return @filtered; | ||
} | ||
|
||
1; | ||
|
||
__END__ | ||
=head1 NAME | ||
Bio::Graphics::Browser::Plugin::SimpleTrackFinder - Limit list of tracks to those that match a name pattern | ||
=head1 SYNOPSIS | ||
In the appropriate gbrowse configuration file: | ||
track filter = SimpleTrackFinder | ||
=head1 DESCRIPTION | ||
=head1 OPTIONS | ||
=head1 BUGS | ||
None known yet. | ||
=head1 SEE ALSO | ||
L<Bio::Graphics::Browser::Plugin> | ||
=head1 AUTHOR | ||
Lincoln Stein E<lt>lincoln.stein@gmail.comE<gt>. | ||
Copyright (c) 2009 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. | ||
=cut |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
package Bio::Graphics::Browser::Plugin::SourceTrackFinder; | ||
# $Id: SourceTrackFinder.pm,v 1.1 2009-05-20 20:36:20 lstein Exp $ | ||
use strict; | ||
use CGI qw(:standard *table); | ||
use base 'Bio::Graphics::Browser::Plugin'; | ||
use Bio::Graphics::Browser::Util 'shellwords'; | ||
our $VERSION = '0.25'; | ||
|
||
sub name { "Source Track Finder" } | ||
|
||
sub description { | ||
return p("The source track finder filters the track table by the data and config source the track."); | ||
} | ||
|
||
sub type { 'trackfilter' } | ||
|
||
sub init { } | ||
|
||
sub config_defaults { | ||
my $self = shift; | ||
|
||
# this line gets all the options defined in the "[SourceTrackFinder:plugin]" stanza | ||
my %fields = map {$_=>undef} $self->get_fields; | ||
|
||
return \%fields; | ||
} | ||
|
||
|
||
# this method gets all the options defined in the "[SourceTrackFinder:plugin]" stanza | ||
sub get_fields { | ||
my $self = shift; | ||
return $self->browser_config->plugin_setting; | ||
} | ||
|
||
sub reconfigure { | ||
my $self = shift; | ||
my $current_config = $self->configuration; | ||
|
||
for my $f ($self->get_fields) { | ||
$current_config->{lc $f} = $self->config_param($f); | ||
} | ||
} | ||
|
||
sub configure_form { | ||
my $self = shift; | ||
my $current_config = $self->configuration; | ||
my $source = $self->browser_config; | ||
|
||
my @fields = $self->get_fields; | ||
my @elements; | ||
|
||
for my $f (@fields) { | ||
my @options = ('',shellwords($source->plugin_setting($f))); | ||
push @elements,b(ucfirst $f.':'); | ||
push @elements, | ||
popup_menu( | ||
-id => "plugin_$f", | ||
-class => "SourceTrackFinderPopup", | ||
-name => $self->config_name($f), | ||
-values => \@options, | ||
-default => $current_config->{$f}, | ||
-override => 1, | ||
-onChange => 'doPluginUpdate()', | ||
) | ||
} | ||
push @elements, | ||
button(-value => 'Clear', | ||
-onClick => q($$('.SourceTrackFinderPopup').each(function(m) {m.selectedIndex=0}); doPluginUpdate();) | ||
); | ||
return join ' ',@elements; | ||
|
||
|
||
} | ||
|
||
sub filter_tracks { | ||
my $self = shift; | ||
my $track_labels = shift; | ||
my $source = shift; | ||
|
||
my $config = $self->configuration; | ||
my @fields = $self->get_fields; | ||
my %filters = map {lc $_ => $config->{lc $_}} @fields; | ||
|
||
my @result; | ||
|
||
LABEL: | ||
for my $l (@$track_labels) { | ||
do {push @result,$l; next LABEL} if $l =~ /^(plugin|file|http|das)/; | ||
|
||
for my $f (keys %filters) { | ||
my %values = map {lc $_=>1} shellwords $source->fallback_setting($l=>$f); | ||
next LABEL if length $filters{$f} && !$values{lc $filters{$f}}; | ||
} | ||
|
||
push @result,$l; | ||
} | ||
return @result; | ||
} | ||
|
||
1; | ||
|
||
__END__ | ||
=head1 NAME | ||
Bio::Graphics::Browser::Plugin::SimpleTrackFinder - Limit list of tracks to those that match a name pattern | ||
=head1 SYNOPSIS | ||
In the appropriate gbrowse configuration file: | ||
track filter = SimpleTrackFinder | ||
=head1 DESCRIPTION | ||
=head1 OPTIONS | ||
=head1 BUGS | ||
None known yet. | ||
=head1 SEE ALSO | ||
L<Bio::Graphics::Browser::Plugin> | ||
=head1 AUTHOR | ||
Lincoln Stein E<lt>lincoln.stein@gmail.comE<gt>. | ||
Copyright (c) 2009 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. | ||
=cut |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.