GBrowse
view release on metacpan or search on metacpan
conf/plugins/TrackDumper.pm view on Meta::CPAN
package Bio::Graphics::Browser2::Plugin::TrackDumper;
# $Id: TrackDumper.pm,v 1.3 2009-01-30 22:06:19 lstein Exp $
# test plugin
use strict;
use Bio::Graphics::Browser2::Plugin;
use Bio::Graphics::Browser2::TrackDumper;
use CGI qw(:standard *sup);
use vars '$VERSION','@ISA';
$VERSION = '1.00';
@ISA = qw/ Bio::Graphics::Browser2::Plugin /;
sub name { "Track Data" }
sub description {
p("The Track dumper plugin dumps out the currently selected tracks and their configuration in",
a({-href=>'http://www.sequenceontology.org/gff3.shtml'},'GFF Version 3 format.'),
"The information can be edited and then uploaded to this, or another GBrowse instance to create new tracks.",
"This plugin was written by Lincoln Stein & Sheldon McKay.");
}
sub config_defaults {
my $self = shift;
return {
version => 3,
mode => 'selected',
disposition => 'save',
coords => 'absolute',
region => 'selected',
embed => 0,
print_config=> 1,
};
}
sub reconfigure {
my $self = shift;
my $current_config = $self->configuration;
my @keys = keys %{$self->config_defaults};
foreach my $p ( @keys ) {
$current_config->{$p} = $self->config_param($p);
}
}
sub configure_form {
my $self = shift;
my $current_config = $self->configuration;
my $html = p('Dump',
popup_menu(-name => $self->config_name('mode'),
-values => ['selected','all'],
-default => $current_config->{mode},
-override => 1,
),
' features using GFF version',
popup_menu(-name => $self->config_name('version'),
-values => [2,2.5,3],
-labels => { 2 => '2',
2.5 => '2.5*',
3 => '3'},
-default => $current_config->{version},
-override => 1),
popup_menu(-name=>$self->config_name('region'),
-default=>$current_config->{region},
-override=>1,
-values => ['selected','all'],
-labels=>{all => 'Across entire genome',
selected => 'Across currently visible region'})
);
autoEscape(0);
$html .= p(
radio_group(-name=>$self->config_name('disposition'),
-values => ['view','save','edit'],
-labels => {view => 'View',
save => 'Save to File',
edit => 'Edit'.sup('**'),
}
));
$html .= p(
checkbox(-name=>$self->config_name('embed'),
-checked=>$current_config->{embed},
-override=>1,
-label=>'Embed DNA sequence in the file')
);
$html .= p(
checkbox(-name=>$self->config_name('print_config'),
-checked=>$current_config->{print_config},
-override=>1,
-label=>'Include track configuration data')
);
autoEscape(1);
my $href = a( {-href => 'javascript:void(0)', -onclick => "alert('" .
"\\'Target\\' syntax in the group field:\\n" .
"GFF2: Target class:name start stop\\n" .
"GFF2.5: Target class:name ; tstart start ; tstop stop\\n')"},
"similarity target" );
$html .= p(sup('*'),
"GFF2.5 is GFF2 with a special syntax for $href"
) .
p(sup('**'),
"To edit, install a helper application for MIME type",
cite('application/x-gff2'),'or',
cite('application/x-gff3')
);
$html;
}
sub mime_type {
my $self = shift;
my $config = $self->configuration;
my $ps = $self->page_settings;
my $base = join '_',@{$ps}{qw(ref start stop)};
my $gff = $config->{version} < 3 ? 'gff2' : 'gff3';
return $config->{disposition} eq 'view' ? 'text/plain'
:$config->{disposition} eq 'save' ? ('application/octet-stream',"$base.$gff")
:$config->{disposition} eq 'edit' ? "application/x-${gff}"
:'text/plain';
}
sub dump {
( run in 1.237 second using v1.01-cache-2.11-cpan-364913b4093 )