3 # Copyright (C) 2006-2009 Martin A. Hansen.
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 # http://www.gnu.org/copyleft/gpl.html
21 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
26 use lib $ENV{ 'BP_PERL' };
35 use Maasha::BBrowser::Track;
36 use Maasha::BBrowser::Draw;
38 my ( $cgi, $cookie, @html );
41 $cookie = cookie_default( $cgi );;
43 push @html, Maasha::XHTML::html_header(
45 title => "Biopieces Genome Browser",
46 css_file => "bgb.css",
47 author => "Martin A. Hansen, mail\@maasha.dk",
48 description => "Biopieces Genome Browser",
49 keywords => [ qw( Biopieces biopiece genome browser viewer bacterium bacteria prokaryote prokaryotes ) ],
53 push @html, Maasha::XHTML::h1( txt => "Biopieces Genome Browser", class => 'center' );
54 push @html, Maasha::XHTML::form_beg( action => $cookie->{ 'SCRIPT' }, method => "get", enctype => "multipart/form-data" );
56 push @html, page( $cookie );
58 push @html, Maasha::XHTML::form_end;
59 push @html, Maasha::XHTML::body_end;
60 push @html, Maasha::XHTML::html_end;
62 # push @html, Maasha::XHTML::hdump( [ $cgi->Vars ] ); # DEBUG
63 # push @html, Maasha::XHTML::hdump( $cookie ); # DEBUG
65 print "$_\n" foreach @html;
68 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> SUBROUTINES <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
71 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> COOKIE <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
76 # Martin A. Hansen, November 2009.
78 # Set a cookie with values from the CGI object or defaults.
80 my ( $cgi, # CGI object
85 my ( $cookie, $path );
89 if ( $cgi->param( 'nav_search' ) )
91 if ( $cgi->param( 'nav_search' ) =~ /([0-9,]+)[ -]([0-9,]+)/ )
93 $cookie->{ 'NAV_START' } = $1;
94 $cookie->{ 'NAV_END' } = $2;
98 $cookie->{ 'SEARCH' } = $cgi->param( 'nav_search' );
100 $cgi->param( 'page', 'search' );
104 $cookie->{ 'SCRIPT' } = Maasha::Common::get_scriptname();
105 $cookie->{ 'DATA_DIR' } = "Data";
106 $cookie->{ 'LIST_PAGES' } = [ qw( user clade genome assembly contig browse ) ];
107 $cookie->{ 'PAGE' } = $cgi->param( 'page' ) || 'user';
108 $cookie->{ 'USER' } = $cgi->param( 'user' ) || '';
109 $cookie->{ 'CLADE' } = $cgi->param( 'clade' ) || '';
110 $cookie->{ 'GENOME' } = $cgi->param( 'genome' ) || '';
111 $cookie->{ 'ASSEMBLY' } = $cgi->param( 'assembly' ) || '';
112 $cookie->{ 'CONTIG' } = $cgi->param( 'contig' ) || '';
113 $cookie->{ 'Q_ID' } = $cgi->param( 'q_id' );
114 $cookie->{ 'S_BEG' } = $cgi->param( 's_beg' );
115 $cookie->{ 'S_END' } = $cgi->param( 's_end' );
116 $cookie->{ 'STRAND' } = $cgi->param( 'strand' );
117 $cookie->{ 'ZOOM_IN1' } = $cgi->param( 'zoom_in1' );
118 $cookie->{ 'ZOOM_IN2' } = $cgi->param( 'zoom_in2' );
119 $cookie->{ 'ZOOM_IN3' } = $cgi->param( 'zoom_in3' );
120 $cookie->{ 'ZOOM_OUT1' } = $cgi->param( 'zoom_out1' );
121 $cookie->{ 'ZOOM_OUT2' } = $cgi->param( 'zoom_out2' );
122 $cookie->{ 'ZOOM_OUT3' } = $cgi->param( 'zoom_out3' );
123 $cookie->{ 'MOVE_LEFT1' } = $cgi->param( 'move_left1' );
124 $cookie->{ 'MOVE_LEFT2' } = $cgi->param( 'move_left2' );
125 $cookie->{ 'MOVE_LEFT3' } = $cgi->param( 'move_left3' );
126 $cookie->{ 'MOVE_RIGHT1' } = $cgi->param( 'move_right1' );
127 $cookie->{ 'MOVE_RIGHT2' } = $cgi->param( 'move_right2' );
128 $cookie->{ 'MOVE_RIGHT3' } = $cgi->param( 'move_right3' );
130 $cookie->{ 'IMG_WIDTH' } = 1200;
131 $cookie->{ 'IMG_HEIGHT' } = 800;
132 $cookie->{ 'TRACK_OFFSET' } = 20;
133 $cookie->{ 'TRACK_SPACE' } = 20;
134 $cookie->{ 'RULER_FONT_SIZE' } = 10;
135 $cookie->{ 'RULER_COLOR' } = [ 0, 0, 0 ];
136 $cookie->{ 'SEQ_FONT_SIZE' } = 10;
137 $cookie->{ 'SEQ_COLOR' } = [ 0, 0, 0, ];
138 $cookie->{ 'FEAT_WIDTH' } = 5;
139 $cookie->{ 'FEAT_COLOR' } = [ 0, 0, 0 ];
140 $cookie->{ 'FEAT_MAX' } = 5000;
142 $path = "$cookie->{ 'DATA_DIR' }/Users";
144 $cookie->{ 'LIST_USER' } = Maasha::Filesys::ls_dirs_base( $path ) if -d $path;
146 $path .= "/$cookie->{ 'USER' }";
148 $cookie->{ 'LIST_CLADE' } = Maasha::Filesys::ls_dirs_base( $path ) if -d $path;
150 $path .= "/$cookie->{ 'CLADE' }";
152 $cookie->{ 'LIST_GENOME' } = Maasha::Filesys::ls_dirs_base( $path ) if -d $path;
154 $path .= "/$cookie->{ 'GENOME' }";
156 $cookie->{ 'LIST_ASSEMBLY' } = Maasha::Filesys::ls_dirs_base( $path ) if -d $path;
158 $path .= "/$cookie->{ 'ASSEMBLY' }";
160 $cookie->{ 'LIST_CONTIG' } = Maasha::Filesys::ls_dirs_base( $path ) if -d $path;
162 if ( $cookie->{ 'CONTIG' } )
164 cookie_start( $cookie );
165 cookie_end( $cookie );
166 cookie_zoom( $cookie );
167 cookie_move( $cookie );
170 $cookie->{ 'STRAND' } = '+' if defined $cookie->{ 'STRAND' } and $cookie->{ 'STRAND' } eq ' '; # FIXME ugly HTML fix
172 return wantarray ? %{ $cookie } : $cookie;
178 # Martin A. Hansen, November 2009.
180 # Decommify the cookie value for NAV_START and adjust it to
181 # to prevent negative values.
183 my ( $cookie, # cookie hash
188 if ( defined $cookie->{ 'NAV_START' } )
190 $cookie->{ 'NAV_START' } =~ tr/,//d;
191 $cookie->{ 'NAV_START' } = 0 if $cookie->{ 'NAV_START' } < 0;
195 $cookie->{ 'NAV_START' } = 0;
202 # Martin A. Hansen, November 2009.
204 # Decommify the cookie value for NAV_END and adjust it to prevent
205 # overshooting the max value for the contig size as determined
208 my ( $cookie, # cookie hash
215 $max = Maasha::Filesys::file_size( Maasha::BBrowser::Track::path_seq( $cookie ) );
217 if ( defined $cookie->{ 'NAV_END' } )
219 $cookie->{ 'NAV_END' } =~ tr/,//d;
220 $cookie->{ 'NAV_END' } = $max if $cookie->{ 'NAV_END' } > $max;
224 $cookie->{ 'NAV_END' } = $max;
231 # Martin A. Hansen, November 2009.
233 # Adjust the cookie values for NAV_START and NAV_END based
234 # on cookie ZOOM values.
236 my ( $cookie, # cookie hash
241 my ( $max, $dist, $new_dist, $dist_diff );
243 $max = Maasha::Filesys::file_size( Maasha::BBrowser::Track::path_seq( $cookie ) );
245 $dist = $cookie->{ 'NAV_END' } - $cookie->{ 'NAV_START' };
247 if ( defined $cookie->{ 'ZOOM_IN1' } ) {
248 $new_dist = $dist / 1.5;
249 } elsif ( defined $cookie->{ 'ZOOM_IN2' } ) {
250 $new_dist = $dist / 3;
251 } elsif ( defined $cookie->{ 'ZOOM_IN3' } ) {
252 $new_dist = $dist / 10;
253 } elsif ( defined $cookie->{ 'ZOOM_OUT1' } ) {
254 $new_dist = $dist * 1.5;
255 } elsif ( defined $cookie->{ 'ZOOM_OUT2' } ) {
256 $new_dist = $dist * 3;
257 } elsif ( defined $cookie->{ 'ZOOM_OUT3' } ) {
258 $new_dist = $dist * 10;
263 $dist_diff = $dist - $new_dist;
265 $cookie->{ 'NAV_START' } = int( $cookie->{ 'NAV_START' } + ( $dist_diff / 2 ) );
266 $cookie->{ 'NAV_END' } = int( $cookie->{ 'NAV_END' } - ( $dist_diff / 2 ) );
268 $cookie->{ 'NAV_START' } = 0 if $cookie->{ 'NAV_START' } < 0;
269 $cookie->{ 'NAV_END' } = $max if $cookie->{ 'NAV_END' } > $max;
276 # Martin A. Hansen, November 2009.
278 # Adjust the cookie values for NAV_START and NAV_END based
279 # on cookie MOVE values.
281 my ( $cookie, # cookie hash
284 my ( $max, $dist, $shift, $new_start, $new_end );
286 $max = Maasha::Filesys::file_size( Maasha::BBrowser::Track::path_seq( $cookie ) );
288 $dist = $cookie->{ 'NAV_END' } - $cookie->{ 'NAV_START' };
290 if ( defined $cookie->{ 'MOVE_LEFT1' } ) {
291 $shift = -1 * $dist * 0.10;
292 } elsif ( defined $cookie->{ 'MOVE_LEFT2' } ) {
293 $shift = -1 * $dist * 0.475;
294 } elsif ( defined $cookie->{ 'MOVE_LEFT3' } ) {
295 $shift = -1 * $dist * 0.95;
296 } elsif ( defined $cookie->{ 'MOVE_RIGHT1' } ) {
297 $shift = $dist * 0.10;
298 } elsif ( defined $cookie->{ 'MOVE_RIGHT2' } ) {
299 $shift = $dist * 0.475;
300 } elsif ( defined $cookie->{ 'MOVE_RIGHT3' } ) {
301 $shift = $dist * 0.95;
306 $new_start = int( $cookie->{ 'NAV_START' } + $shift );
307 $new_end = int( $cookie->{ 'NAV_END' } + $shift );
309 if ( $new_start > 0 and $new_end < $max )
311 $cookie->{ 'NAV_START' } = $new_start;
312 $cookie->{ 'NAV_END' } = $new_end;
320 # Martin A. Hansen, November 2009.
322 # Returns the href for a taxonomy path terminated at a given
323 # page using information stored in a cookie.
325 my ( $cookie, # cookie hash
331 my ( @href_list, %href_hash, $href );
335 $href_hash{ "user" } = $cookie->{ 'USER' } if $cookie->{ 'USER' };
336 last if $page eq 'user';
337 $href_hash{ "clade" } = $cookie->{ 'CLADE' } if $cookie->{ 'CLADE' };
338 last if $page eq 'clade';
339 $href_hash{ "genome" } = $cookie->{ 'GENOME' } if $cookie->{ 'GENOME' };
340 last if $page eq 'genome';
341 $href_hash{ "assembly" } = $cookie->{ 'ASSEMBLY' } if $cookie->{ 'ASSEMBLY' };
342 last if $page eq 'assembly';
343 $href_hash{ "contig" } = $cookie->{ 'CONTIG' } if $cookie->{ 'CONTIG' };
344 last if $page eq 'contig';
348 if ( defined $cookie->{ 'NAV_START' } and defined $cookie->{ 'NAV_END' } ) {
349 $href_hash{ "nav_search" } = "$cookie->{ 'NAV_START' }-$cookie->{ 'NAV_END' }";
352 $href_hash{ "s_beg" } = $cookie->{ 'S_BEG' } if defined $cookie->{ 'S_BEG' };
353 $href_hash{ "s_end" } = $cookie->{ 'S_END' } if defined $cookie->{ 'S_END' };
354 $href_hash{ "q_id" } = $cookie->{ 'Q_ID' } if defined $cookie->{ 'Q_ID' };
355 $href_hash{ "strand" } = $cookie->{ 'STRAND' } if defined $cookie->{ 'STRAND' };
357 push @href_list, "$cookie->{ 'SCRIPT' }?page=$page";
359 foreach $href ( keys %href_hash ) {
360 push @href_list, "$href=$href_hash{ $href }";
363 return join "&", @href_list;
369 # Martin A. Hansen, November 2009.
371 # Returns the next page in the taxonomy path.
373 my ( $cookie, # cookie hash
380 for ( $i = 0; $i < @{ $cookie->{ 'LIST_PAGES' } }; $i++ ) {
381 last if $cookie->{ 'PAGE' } eq $cookie->{ 'LIST_PAGES' }->[ $i ];
384 return $cookie->{ 'LIST_PAGES' }->[ $i + 1 ];
388 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> PAGES <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
393 # Martin A. Hansen, November 2009.
395 # Determines what page to render based on
396 # the cookie's PAGE setting.
398 my ( $cookie, # cookie hash
405 if ( $cookie->{ 'PAGE' } eq 'export' ) {
406 push @html, page_export( $cookie );
407 } elsif ( $cookie->{ 'PAGE' } eq 'search' ) {
408 push @html, page_search( $cookie );
409 } elsif ( $cookie->{ 'PAGE' } eq 'browse' ) {
410 push @html, page_browse( $cookie );
411 } elsif ( $cookie->{ 'PAGE' } eq 'dna' ) {
412 push @html, page_dna( $cookie );
414 push @html, page_taxonomy( $cookie );
417 return wantarray ? @html : \@html;
423 # Martin A. Hansen, November 2009.
425 # Renders the export page.
434 push @html, section_taxonomy_table( $cookie );
435 push @html, section_export( $cookie );
437 return wantarray ? @html : \@html;
443 # Martin A. Hansen, December 2009.
445 # Renders the search page.
454 push @html, section_taxonomy_table( $cookie );
455 push @html, section_search( $cookie );
457 return wantarray ? @html : \@html;
463 # Martin A. Hansen, November 2009.
465 # Renders the browse page.
474 push @html, section_taxonomy_table( $cookie );
475 push @html, section_navigate( $cookie );
476 push @html, section_browse( $cookie );
478 return wantarray ? @html : \@html;
484 # Martin A. Hansen, November 2009.
486 # Renders the DNA page.
495 push @html, section_taxonomy_table( $cookie );
496 push @html, section_dna( $cookie );
498 return wantarray ? @html : \@html;
504 # Martin A. Hansen, November 2009.
506 # Renders the browse page.
508 my ( $cookie, # cookie hash
515 push @html, section_taxonomy_table( $cookie );
516 push @html, section_taxonomy_select( $cookie );
518 return wantarray ? @html : \@html;
522 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> SECTIONS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
525 sub section_taxonomy_table
527 # Martin A. Hansen, November 2009.
529 # Returns a HTML section with a taxonomy table
530 # showing the location in the taxonomy and with
531 # links to browse the taxonomy.
533 my ( $cookie, # cookie hash
538 my ( $page, @row, @html, $href, $txt );
540 foreach $page ( @{ $cookie->{ 'LIST_PAGES' } } )
542 last if $page eq $cookie->{ 'PAGE' } or $page eq 'browse';
544 $href = cookie_href( $cookie, $page );
546 $txt = ": $cookie->{ uc $page }";
548 push @row, Maasha::XHTML::ln( txt => $page, href => $href, class => 'inline' );
549 push @row, Maasha::XHTML::p( txt => $txt, class => 'inline' );
552 push @html, Maasha::XHTML::table_beg( summary => "Taxonomy table", align => 'center', cellpadding => '5px' );
553 push @html, Maasha::XHTML::table_row_simple( tr => [ join( "\n", @row ) ], align => 'center' );
554 push @html, Maasha::XHTML::table_end;
556 return wantarray ? @html : \@html;
560 sub section_taxonomy_select
562 # Martin A. Hansen, November 2009.
564 # Returns a HTML section with selection choices
565 # for navigating the taxonomy tree.
567 my ( $cookie, # cookie hash
572 my ( $list, @html, $item, $href );
574 $list = "LIST_" . uc $cookie->{ 'PAGE' };
576 push @html, Maasha::XHTML::h2( txt => "Select $cookie->{ 'PAGE' }", class => 'center' );
578 push @html, Maasha::XHTML::table_beg( summary => "Taxonomy select table", align => 'center', cellpadding => '5px' );
580 foreach $item ( @{ $cookie->{ $list } } )
582 $cookie->{ uc $cookie->{ 'PAGE' } } = $item;
584 $href = cookie_href( $cookie, cookie_page_next( $cookie ) );
586 push @html, Maasha::XHTML::table_row_simple( tr => [ Maasha::XHTML::ln( txt => $item, href => $href ) ] );
589 push @html, Maasha::XHTML::table_end;
591 return wantarray ? @html : \@html;
597 # Martin A. Hansen, November 2009.
599 # Returns a HTML section for navigating in the browser window.
601 my ( $cookie, # cookie hash
606 my ( @html, $nav_val );
608 $nav_val = Maasha::Calc::commify( $cookie->{ 'NAV_START' } ) . "-" . Maasha::Calc::commify( $cookie->{ 'NAV_END' } );
610 push @html, Maasha::XHTML::table_beg( summary => "Navigation table", align => 'center' );
611 push @html, Maasha::XHTML::table_row_simple( tr => [
612 "Position or search term:",
613 Maasha::XHTML::text( name => "nav_search", value => $nav_val, size => 30 ),
614 Maasha::XHTML::submit( name => "nav_submit", value => "Submit" ),
616 push @html, Maasha::XHTML::table_end;
618 push @html, Maasha::XHTML::table_beg( summary => "Zoom table", align => 'center' );
619 push @html, Maasha::XHTML::table_row_simple( tr => [
620 Maasha::XHTML::p( txt => 'Move:' ),
621 Maasha::XHTML::submit( name => "move_left3", value => "<<<", title => "move 95% to the left" ),
622 Maasha::XHTML::submit( name => "move_left2", value => "<<", title => "move 47.5% to the left" ),
623 Maasha::XHTML::submit( name => "move_left1", value => "<", title => "move 10% to the left" ),
624 Maasha::XHTML::submit( name => "move_right1", value => ">", title => "move 10% to the rigth" ),
625 Maasha::XHTML::submit( name => "move_right2", value => ">>", title => "move 47.5% to the rigth" ),
626 Maasha::XHTML::submit( name => "move_right3", value => ">>>", title => "move 95% to the right" ),
627 Maasha::XHTML::p( txt => 'Zoom in:' ),
628 Maasha::XHTML::submit( name => "zoom_in1", value => "1.5x" ),
629 Maasha::XHTML::submit( name => "zoom_in2", value => "3x" ),
630 Maasha::XHTML::submit( name => "zoom_in3", value => "10x" ),
631 Maasha::XHTML::p( txt => 'Zoom out:' ),
632 Maasha::XHTML::submit( name => "zoom_out1", value => "1.5x" ),
633 Maasha::XHTML::submit( name => "zoom_out2", value => "3x" ),
634 Maasha::XHTML::submit( name => "zoom_out3", value => "10x" ),
636 push @html, Maasha::XHTML::table_end;
638 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "page", value => "browse" ) );
639 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "user", value => "$cookie->{ 'USER' }" ) );
640 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "clade", value => "$cookie->{ 'CLADE' }" ) );
641 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "genome", value => "$cookie->{ 'GENOME' }" ) );
642 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "assembly", value => "$cookie->{ 'ASSEMBLY' }" ) );
643 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "contig", value => "$cookie->{ 'CONTIG' }" ) );
645 return wantarray ? @html : \@html;
656 my ( @tracks, $i, @features, $feat, $elem, $file, $surface, $cr, @html, @img );
658 push @features, [ Maasha::BBrowser::Track::track_ruler( $cookie ) ];
659 push @features, [ Maasha::BBrowser::Track::track_seq( $cookie ) ];
661 @tracks = Maasha::BBrowser::Track::path_tracks( $cookie );
663 for ( $i = 0; $i < @tracks; $i++ )
665 $cookie->{ 'FEAT_COLOR' } = Maasha::BBrowser::Draw::palette( $i );
667 push @features, [ Maasha::BBrowser::Track::track_feature( $tracks[ $i ], $cookie ) ];
670 $file = "fisk.png"; # FIXME
672 $surface = Cairo::ImageSurface->create( 'argb32', $cookie->{ 'IMG_WIDTH' }, $cookie->{ 'TRACK_OFFSET' } );
673 $cr = Cairo::Context->create( $surface );
675 $cr->rectangle ( 0, 0, $cookie->{ 'IMG_WIDTH' }, $cookie->{ 'TRACK_OFFSET' } );
676 $cr->set_source_rgb ( 1, 1, 1 );
679 foreach $feat ( @features ) {
680 Maasha::BBrowser::Draw::draw_feature( $cr, $feat ) if $feat;
683 Maasha::BBrowser::Draw::file_png( $surface, $file );
685 push @img, Maasha::XHTML::img(
687 alt => "Browser Tracks",
688 height => $cookie->{ 'TRACK_OFFSET' },
689 width => $cookie->{ 'IMG_WIDTH' },
691 usemap => "#browser_map"
694 push @img, Maasha::XHTML::map_beg( name => "browser_map", id => "browser_map" );
696 foreach $feat ( @features )
698 foreach $elem ( @{ $feat } )
700 next if $elem->{ 'type' } eq 'text';
702 #$elem->{ 'strand' } = '+' if $elem->{ 'strand' } eq '+';
704 $cookie->{ 'Q_ID' } = $elem->{ 'q_id' };
705 $cookie->{ 'S_BEG' } = $elem->{ 's_beg' };
706 $cookie->{ 'S_END' } = $elem->{ 's_end' };
707 $cookie->{ 'STRAND' } = $elem->{ 'strand' };
709 push @img, Maasha::XHTML::area(
710 href => cookie_href( $cookie, "export" ),
711 # href => cookie_href( $cookie, "export" ) . "&q_id=$elem->{ 'q_id' }&s_beg=$elem->{ 's_beg' }&s_end=$elem->{ 's_end' }&strand=$elem->{ 'strand' }",
713 coords => "$elem->{ x1 }, $elem->{ y1 }, $elem->{ x2 }, $elem->{ y2 }", title => "$elem->{ 'title' }",
718 push @img, Maasha::XHTML::map_end();
720 push @html, Maasha::XHTML::p( txt => join( "\n", @img ) );
722 @html = Maasha::XHTML::div( txt => join( "\n", @html ), class => 'browse' );
724 return wantarray ? @html : \@html;
730 # Martin A. Hansen, November 2009.
732 # Returns a HTML section with export table.
734 my ( $cookie, # cookie hash
739 my ( @row_dna_contig, @html );
741 push @row_dna_contig, Maasha::XHTML::p( txt => qq(Export Feature: "$cookie->{ 'Q_ID' }" DNA from Contig: ), class => 'inline' );
742 push @row_dna_contig, Maasha::XHTML::p( txt => "$cookie->{ 'CONTIG' } Start: ", class => 'inline' );
743 push @row_dna_contig, Maasha::XHTML::text( name => "s_beg", value => Maasha::Calc::commify( $cookie->{ 'S_BEG' } ), size => 15 );
744 push @row_dna_contig, Maasha::XHTML::p( txt => "End: ", class => 'inline' );
745 push @row_dna_contig, Maasha::XHTML::text( name => "s_end", value => Maasha::Calc::commify( $cookie->{ 'S_END' } ), size => 15 );
746 push @row_dna_contig, Maasha::XHTML::p( txt => "Strand: ", class => 'inline' );
747 push @row_dna_contig, Maasha::XHTML::menu( name => "strand", options => [ qw( + - ) ], selected => $cookie->{ 'STRAND' } );
748 push @row_dna_contig, Maasha::XHTML::submit( name => "export", value => "Export", title => "Fetch DNA from this region" );
750 push @html, Maasha::XHTML::h2( txt => "Export", class => 'center' );
751 push @html, Maasha::XHTML::table_beg( summary => "Taxonomy select table", align => 'center' );
752 push @html, Maasha::XHTML::table_row_simple( tr => \@row_dna_contig );
753 push @html, Maasha::XHTML::table_end;
755 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "page", value => "dna" ) );
756 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "user", value => "$cookie->{ 'USER' }" ) );
757 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "clade", value => "$cookie->{ 'CLADE' }" ) );
758 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "genome", value => "$cookie->{ 'GENOME' }" ) );
759 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "assembly", value => "$cookie->{ 'ASSEMBLY' }" ) );
760 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "contig", value => "$cookie->{ 'CONTIG' }" ) );
762 return wantarray ? @html : \@html;
768 # Martin A. Hansen, November 2009.
770 # Returns a HTML section with export table.
772 my ( $cookie, # cookie hash
777 my ( $results, $result, $count, @html, $export, $browse );
779 $results = Maasha::BBrowser::Track::search_tracks( $cookie );
781 $count = scalar @{ $results };
783 push @html, Maasha::XHTML::h2( txt => "Search", class => 'center' );
784 push @html, Maasha::XHTML::p( txt => qq(Results for "$cookie->{ 'SEARCH' }": $count), class => 'center' );
788 push @html, Maasha::XHTML::table_beg( summary => "Search table", align => 'center', cellpadding => '5px' );
789 push @html, Maasha::XHTML::table_row_simple( tr => [ qw( S_ID S_BEG S_END Q_ID SCORE STRAND HITS ALIGN BLOCK_COUNT BLOCK_BEGS BLOCK_LENS BLOCK_TYPE) ] );
791 foreach $result ( @{ $results } )
793 $cookie->{ 'CONTIG' } = $result->{ 'S_ID' };
794 $cookie->{ 'NAV_START' } = $result->{ 'S_BEG' };
795 $cookie->{ 'NAV_END' } = $result->{ 'S_END' };
796 $cookie->{ 'S_BEG' } = $result->{ 'S_BEG' };
797 $cookie->{ 'S_END' } = $result->{ 'S_END' };
798 $cookie->{ 'STRAND' } = $result->{ 'STRAND' };
799 $cookie->{ 'Q_ID' } = $result->{ 'Q_ID' };
801 $browse = Maasha::XHTML::ln( txt => "browse", href => cookie_href( $cookie, "browse" ) );
802 $export = Maasha::XHTML::ln( txt => "export", href => cookie_href( $cookie, "export" ) );
804 push @html, Maasha::XHTML::table_row_advanced(
805 tr => [ { td => $result->{ 'S_ID' } },
806 { td => $result->{ 'S_BEG' }, align => 'right' },
807 { td => $result->{ 'S_END' }, align => 'right' },
808 { td => $result->{ 'Q_ID' } },
809 { td => $result->{ 'SCORE' }, align => 'right' },
810 { td => $result->{ 'STRAND' } },
811 { td => $result->{ 'HITS' }, align => 'right' },
812 { td => $result->{ 'ALIGN' } },
813 { td => $result->{ 'BLOCK_COUNT' }, align => 'right' },
814 { td => $result->{ 'BLOCK_BEGS' } },
815 { td => $result->{ 'BLOCK_LENS' } },
816 { td => $result->{ 'BLOCK_TYPE' } },
819 ], class => "monospace"
823 push @html, Maasha::XHTML::table_end;
826 return wantarray ? @html : \@html;
832 # Martin A. Hansen, November 2009.
834 # Returns a HTML section with extracted DNA.
836 my ( $cookie, # cookie hash
841 my ( @html, $beg, $end, $seq );
843 $beg = $cookie->{ 'S_BEG' };
844 $end = $cookie->{ 'S_END' };
848 $seq = ">$cookie->{ 'CONTIG' }_$beg" . "_$end" . "_$cookie->{ 'STRAND' }\n";
849 $seq .= Maasha::BBrowser::Track::dna_get( $cookie );
851 push @html, Maasha::XHTML::h2( txt => "DNA", class => 'center' );
852 push @html, Maasha::XHTML::pre( txt => $seq );
854 return wantarray ? @html : \@html;
858 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<