blib/conf/plugins/FBTableDumper.pm untested

filter: Statementstmt 0.0% 0 / 76 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 7 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 11 Podpod 0.0% 0 / 7 totaltotal 0.0% 0 / 117 CC 9 SCAR 37.8
CC
9
Cov
0%
dump
90.0
name
2.0
description
2.0
CRAP 43.7
1 package Bio::Graphics::Browser2::Plugin::FBTableDumper;
2 # FBTableDumper.pm v1 2006 V.Strelets at FlyBase.org
3 # derived from GFFDumper by L.Stein
4 use strict;
5 use Bio::Graphics::Browser2::Plugin;
6 use CGI qw(:standard *sup);
7  
8 use vars '$VERSION','@ISA';
9 $VERSION = '0.80';
10  
11 @ISA = qw/ Bio::Graphics::Browser2::Plugin /;
12  
13 sub name { "HTML table view" }
14 sub description {
15 p("FlyBase table view dumper");
16 }
17  
18 sub config_defaults {
19 my $self = shift;
20 return {
21 version => 2,
22 mode => 'selected',
23 disposition => 'view',
24 coords => 'absolute',
25 };
26 }
27  
28 sub reconfigure {
29 my $self = shift;
30 my $current_config = $self->configuration;
31 foreach my $p ( $self->config_param() ) {
32 $current_config->{$p} = $self->config_param($p);
33 }
34 }
35  
36 sub configure_form {
37 my $self = shift;
38 my $current_config = $self->configuration;
39 my $html = p('Dump',
40 popup_menu(-name => $self->config_name('mode'),
41 -values => ['selected','all'],
42 -default => $current_config->{mode},
43 -override => 1,
44 ),
45 '  features');
46 autoEscape(1);
47  
48  
49 $html;
50 }
51  
52 sub mime_type {
53 my $self = shift;
54 return 'text/html';
55 }
56  
57  
58 sub dump {
59 my $self = shift;
60 my ($segment, @more_feature_sets) = @_;
61 my $page_settings = $self->page_settings;
62 my $conf = $self->browser_config;
63 my $config = $self->configuration;
64 my $version = $config->{version} || 3;
65 my $mode = $config->{mode} || 'selected';
66 my $db = $self->database;
67 my $whole_segment = $db->segment(Accession => $segment->ref) ||
68 $db->segment($segment->ref);
69 my $coords = $config->{coords};
70 $segment->refseq($segment) if $coords eq 'relative';
71 my $date = localtime;
72 print "## FlyBase table view dump<br>\n";
73 print "## date $date<br>\n";
74 print "## sequence-region ",join(' ',$segment->ref,$segment->start,$segment->stop),"<br>\n";
75 print '<TABLE BORDER="0"><TR bgcolor="goldenrod"><TH>Seq.location</TH><TH>Symbol/Name/ID</TH><TH>Note(s)</TH></TR>';
76 my $iterator = $segment->get_seq_stream();
77 my %Out= ();
78 while ( my $f = $iterator->next_seq ) {
79 my $s = $f->gff_string(1); # the flag is for GFF3 subfeature recursion
80 chomp $s;
81 my($ref,$source,$method,$start,$stop,$score,$strand,$phase,$note) = split(/[\t]+/,$s);
82 my $id= ($note=~/ID=([^;]+)/i) ? $1 : '-';
83 next if( $id eq '-' );
84 next if( $note=~/Parent=/i );
85 my $name= ($note=~/Name=([^;]+)/i) ? $1 : $id;
86 if($note=~/Symbol=([^,;]+)/i) { $name.= ' '.$1; }
87 my $key= $source.':'.$method;
88 if( exists $Out{$key} ) { $Out{$key}.= "\t"; }
89 $Out{$key}.= '<TD align=left><small> '.$ref.':'.$start.'..'.$stop.'['.$strand.'] </small></TD>';
90 if( $id=~/^FB[a-z]{2}\d+$/ ) {
91 $name= '<A HREF="http://flybase.org/cgi-bin/fbidq.html?'.$id.'">'.$name.'</A>';
92 }
93 $Out{$key}.= '<TD><small> '.$name.' </small></TD>';
94 $note=~s/(\S);(\S)/$1; $2/g;
95 $Out{$key}.= '<TD align=left><small> '.$note.' </small></TD>';
96 }
97 foreach my $key ( sort keys %Out ) {
98 my($source,$method)= split(":",$key);
99 print '<TR><TD colspan=3 bgcolor="#DCDDDC" align=left> '.$source.':<B>'.$method."</B></TD></TR>\n";
100 my @strs= split("\t",$Out{$key});
101 foreach( @strs ) { print '<TR align=left valign=top>'.$_."</TR>\n"; }
102 }
103 print "</TABLE>\n";
104 return;
105 }
106  
107  
108 1;
109