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' };
36 use Maasha::BGB::Session;
37 use Maasha::BGB::Track;
38 use Maasha::BGB::Draw;
40 my ( $cgi, $cookie, @html );
43 $cookie = cookie_default( $cgi );;
45 push @html, Maasha::XHTML::html_header(
47 title => 'Biopieces Genome Browser',
48 css_file => 'bgb.css',
49 author => 'Martin A. Hansen, mail@maasha.dk',
50 description => 'Biopieces Genome Browser',
51 keywords => [ qw( Biopieces biopiece genome browser viewer bacterium bacteria prokaryote prokaryotes ) ],
55 push @html, Maasha::XHTML::h1( txt => "Biopieces Genome Browser", class => 'center' );
56 push @html, Maasha::XHTML::form_beg( action => $cookie->{ 'SCRIPT' }, method => "post", enctype => "multipart/form-data" );
58 push @html, page( $cookie );
60 push @html, Maasha::XHTML::form_end;
61 push @html, Maasha::XHTML::body_end;
62 push @html, Maasha::XHTML::html_end;
64 # push @html, Maasha::XHTML::hdump( { $cgi->Vars } ); # DEBUG
65 # push @html, Maasha::XHTML::hdump( $cookie ); # DEBUG
66 # push @html, Maasha::XHTML::hdump( \%ENV ); # DEBUG
68 print "$_\n" foreach @html;
70 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> SUBROUTINES <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
73 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> COOKIE <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
78 # Martin A. Hansen, November 2009.
80 # Set a cookie with values from the CGI object or defaults.
82 my ( $cgi, # CGI object
87 my ( $cookie, $session );
91 if ( $cgi->param( 'nav_search' ) )
93 if ( $cgi->param( 'nav_search' ) =~ /([0-9,]+)[ -]([0-9,]+)/ )
95 $cookie->{ 'NAV_START' } = $1;
96 $cookie->{ 'NAV_END' } = $2;
100 $cookie->{ 'SEARCH' } = $cgi->param( 'nav_search' );
102 $cgi->param( 'page', 'search' );
106 $cookie->{ 'SCRIPT' } = Maasha::Common::get_scriptname();
107 $cookie->{ 'DATA_DIR' } = "Data";
108 $cookie->{ 'SESSION_DIR' } = "Sessions";
109 $cookie->{ 'LIST_PAGES' } = [ qw( clade genome assembly contig browse ) ];
110 $cookie->{ 'USER' } = $cgi->param( 'user' );
111 $cookie->{ 'PASSWORD' } = $cgi->param( 'password' );
112 $cookie->{ 'SESSION_ID' } = $cgi->param( 'session_id' );
114 $session = session_restore( $cookie );
116 cookie_login( $cookie );
118 # session_id_check( $cookie, $session );
120 if ( $cookie->{ 'LOGIN_ERROR' } or $cookie->{ 'SESSION_ERROR' } )
122 $cookie->{ 'PAGE' } = 'login';
124 elsif ( $cookie->{ 'LOGIN' } )
126 if ( $cgi->param( 'genome' ) ) {
127 $cookie->{ 'PAGE' } = 'browse';
129 $cookie->{ 'PAGE' } = $session->{ 'PAGE' } || 'clade';
132 elsif ( not defined $cookie->{ 'USER' } )
134 $cookie->{ 'PAGE' } = 'login';
138 $cookie->{ 'PAGE' } = $cgi->param( 'page' ) || 'login';
141 $cookie->{ 'TRACK_STATUS' } = $session->{ 'TRACK_STATUS' };
142 $cookie->{ 'CLADE' } = $cgi->param( 'clade' ) || $session->{ 'CLADE' };
143 $cookie->{ 'GENOME' } = $cgi->param( 'genome' ) || $session->{ 'GENOME' };
144 $cookie->{ 'ASSEMBLY' } = $cgi->param( 'assembly' ) || $session->{ 'ASSEMBLY' };
145 $cookie->{ 'CONTIG' } = $cgi->param( 'contig' ) || $session->{ 'CONTIG' };
146 $cookie->{ 'Q_ID' } = $cgi->param( 'q_id' ) || $session->{ 'Q_ID' };
147 $cookie->{ 'NAV_START' } ||= defined $cgi->param( 'nav_start' ) ? $cgi->param( 'nav_start' ) : $session->{ 'NAV_START' };
148 $cookie->{ 'NAV_END' } ||= defined $cgi->param( 'nav_end' ) ? $cgi->param( 'nav_end' ) : $session->{ 'NAV_END' };
149 $cookie->{ 'NAV_CENTER' } = $cgi->param( 'nav_center' );
150 $cookie->{ 'S_BEG' } = $cgi->param( 's_beg' ) || $session->{ 'S_BEG' };
151 $cookie->{ 'S_END' } = $cgi->param( 's_end' ) || $session->{ 'S_END' };
152 $cookie->{ 'STRAND' } = $cgi->param( 'strand' ) || $session->{ 'STRAND' };
153 $cookie->{ 'TRACK' } = $cgi->param( 'track' );
154 $cookie->{ 'ZOOM_IN1' } = $cgi->param( 'zoom_in1' );
155 $cookie->{ 'ZOOM_IN2' } = $cgi->param( 'zoom_in2' );
156 $cookie->{ 'ZOOM_IN3' } = $cgi->param( 'zoom_in3' );
157 $cookie->{ 'ZOOM_OUT1' } = $cgi->param( 'zoom_out1' );
158 $cookie->{ 'ZOOM_OUT2' } = $cgi->param( 'zoom_out2' );
159 $cookie->{ 'ZOOM_OUT3' } = $cgi->param( 'zoom_out3' );
160 $cookie->{ 'MOVE_LEFT1' } = $cgi->param( 'move_left1' );
161 $cookie->{ 'MOVE_LEFT2' } = $cgi->param( 'move_left2' );
162 $cookie->{ 'MOVE_LEFT3' } = $cgi->param( 'move_left3' );
163 $cookie->{ 'MOVE_RIGHT1' } = $cgi->param( 'move_right1' );
164 $cookie->{ 'MOVE_RIGHT2' } = $cgi->param( 'move_right2' );
165 $cookie->{ 'MOVE_RIGHT3' } = $cgi->param( 'move_right3' );
167 $cookie->{ 'IMG_WIDTH' } = 1200; # Width of browser image in pixels
168 $cookie->{ 'IMG_HEIGHT' } = 800; # Height of browser image in pixels
169 $cookie->{ 'WIGGLE_HEIGHT' } = 75; # Height of Wiggle tracks in pixels
170 $cookie->{ 'TRACK_OFFSET' } = 20;
171 $cookie->{ 'TRACK_SPACE' } = 20;
172 $cookie->{ 'RULER_FONT_SIZE' } = 10; # Size of ruler font in pixels
173 $cookie->{ 'RULER_COLOR' } = [ 0, 0, 0 ];
174 $cookie->{ 'SEQ_FONT_SIZE' } = 10;
175 $cookie->{ 'SEQ_COLOR' } = [ 0, 0, 0, ];
176 $cookie->{ 'FEAT_WIDTH' } = 5;
177 $cookie->{ 'FEAT_COLOR' } = [ 0, 0, 0 ];
178 # $cookie->{ 'FEAT_MAX' } = 5000; # TODO: Reduntant?
180 # $cookie->{ 'LIST_USER' } = Maasha::BGB::Track::list_users(); # TODO: Redundant?
182 if ( $cookie->{ 'USER' } and not $cookie->{ 'LOGIN_ERROR' } )
184 $cookie->{ 'LIST_CLADE' } = Maasha::BGB::Track::list_clades( $cookie->{ 'USER' } );
185 $cookie->{ 'LIST_GENOME' } = Maasha::BGB::Track::list_genomes( $cookie->{ 'USER' }, $cookie->{ 'CLADE' } );
186 $cookie->{ 'LIST_ASSEMBLY' } = Maasha::BGB::Track::list_assemblies( $cookie->{ 'USER' }, $cookie->{ 'CLADE' }, $cookie->{ 'GENOME' } );
187 $cookie->{ 'LIST_CONTIG' } = Maasha::BGB::Track::list_contigs( $cookie->{ 'USER' }, $cookie->{ 'CLADE' }, $cookie->{ 'GENOME' }, $cookie->{ 'ASSEMBLY' } );
189 if ( $cookie->{ 'CONTIG' } )
191 cookie_start( $cookie );
192 cookie_end( $cookie );
193 cookie_zoom( $cookie );
194 cookie_move( $cookie );
195 cookie_center( $cookie );
196 cookie_track_status( $cookie );
200 $cookie->{ 'STRAND' } = '+' if defined $cookie->{ 'STRAND' } and $cookie->{ 'STRAND' } eq ' '; # FIXME ugly HTML fix
202 session_store( $cookie, $session );
204 return wantarray ? %{ $cookie } : $cookie;
210 # Martin A. Hansen, March 2010.
212 # Restores session and returns this.
214 my ( $cookie, # cookie hash
221 if ( defined $cookie->{ 'USER' } and -d "$cookie->{ 'SESSION_DIR' }/$cookie->{ 'USER' }" ) {
222 $session = Maasha::BGB::Session::session_restore( "$cookie->{ 'SESSION_DIR' }/$cookie->{ 'USER' }/session.json" );
225 return wantarray ? %{ $session } : $session;
231 # Martin A. Hansen, March 2010.
233 # Store a session updated with cookie information to session file.
235 my ( $cookie, # cookie hash
236 $session, # session hash
243 if ( defined $cookie->{ 'USER' } and $cookie->{ 'USER' } ne '' and -d "$cookie->{ 'SESSION_DIR' }/$cookie->{ 'USER' }" )
245 $new_session->{ 'PASSWORD' } = $session->{ 'PASSWORD' };
246 $new_session->{ 'SESSION_ID' } = $session->{ 'SESSION_ID' };
247 $new_session->{ 'TIME' } = Maasha::Common::time_stamp();
248 $new_session->{ 'PAGE' } = $cookie->{ 'PAGE' };
250 if ( $cookie->{ 'PAGE' } eq 'browse' )
252 $new_session->{ 'CLADE' } = $cookie->{ 'CLADE' };
253 $new_session->{ 'GENOME' } = $cookie->{ 'GENOME' };
254 $new_session->{ 'ASSEMBLY' } = $cookie->{ 'ASSEMBLY' };
255 $new_session->{ 'CONTIG' } = $cookie->{ 'CONTIG' };
256 $new_session->{ 'NAV_START' } = $cookie->{ 'NAV_START' };
257 $new_session->{ 'NAV_END' } = $cookie->{ 'NAV_END' };
259 elsif ( $cookie->{ 'PAGE' } eq 'contig' )
261 $new_session->{ 'CLADE' } = $cookie->{ 'CLADE' };
262 $new_session->{ 'GENOME' } = $cookie->{ 'GENOME' };
263 $new_session->{ 'ASSEMBLY' } = $cookie->{ 'ASSEMBLY' };
265 elsif ( $cookie->{ 'PAGE' } eq 'assembly' )
267 $new_session->{ 'CLADE' } = $cookie->{ 'CLADE' };
268 $new_session->{ 'GENOME' } = $cookie->{ 'GENOME' };
270 elsif ( $cookie->{ 'PAGE' } eq 'genome' )
272 $new_session->{ 'CLADE' } = $cookie->{ 'CLADE' };
274 elsif ( $cookie->{ 'PAGE' } eq 'export' )
276 $new_session->{ 'CLADE' } = $cookie->{ 'CLADE' };
277 $new_session->{ 'GENOME' } = $cookie->{ 'GENOME' };
278 $new_session->{ 'ASSEMBLY' } = $cookie->{ 'ASSEMBLY' };
279 $new_session->{ 'CONTIG' } = $cookie->{ 'CONTIG' };
280 $new_session->{ 'Q_ID' } = $cookie->{ 'Q_ID' };
281 $new_session->{ 'S_BEG' } = $cookie->{ 'S_BEG' };
282 $new_session->{ 'S_END' } = $cookie->{ 'S_END' };
283 $new_session->{ 'STRAND' } = $cookie->{ 'STRAND' };
286 $new_session->{ 'TRACK_STATUS' } = $cookie->{ 'TRACK_STATUS' };
288 Maasha::BGB::Session::session_store( "$cookie->{ 'SESSION_DIR' }/$cookie->{ 'USER' }/session.json", $new_session );
295 # Martin A. Hansen, March 2010.
297 # Check that the session id in the cookie and session match.
298 # Sets SESSION_ERROR flag in cookie if not matching.
300 my ( $cookie, # cookie hash
301 $session, # session hash
306 if ( defined $cookie->{ 'SESSION_ID' } and defined $session->{ 'SESSION_ID' } )
308 if ( $cookie->{ 'SESSION_ID' } ne $session->{ 'SESSION_ID' } ) {
309 $cookie->{ 'SESSION_ERROR' } = 1;
311 $cookie->{ 'SESSION_ERROR' } = 0;
319 # Martin A. Hansen, December 2009.
321 # Check a user and password from CGI against the password file and
322 # set the session ID, if found, in the cookie.
324 my ( $cookie, # cookie hash
331 if ( defined $cookie->{ 'PASSWORD' } )
333 if ( defined $cookie->{ 'USER' } and -d "$cookie->{ 'SESSION_DIR' }/$cookie->{ 'USER' }" )
335 $session = Maasha::BGB::Session::session_restore( "$cookie->{ 'SESSION_DIR' }/$cookie->{ 'USER' }/session.json" );
337 if ( $session->{ 'PASSWORD' } eq Digest::MD5::md5_hex( $cookie->{ 'PASSWORD' } ) )
339 $cookie->{ 'TIME' } = Maasha::Common::time_stamp();
340 $cookie->{ 'SESSION_ID' } ||= Maasha::BGB::Session::session_new();
341 $cookie->{ 'LOGIN' } = 1;
342 $cookie->{ 'LOGIN_ERROR' } = 0;
346 $cookie->{ 'LOGIN_ERROR' } = 1;
351 $cookie->{ 'LOGIN_ERROR' } = 1;
359 # Martin A. Hansen, November 2009.
361 # Decommify the cookie value for NAV_START and adjust it to
362 # to prevent negative values.
364 my ( $cookie, # cookie hash
369 if ( defined $cookie->{ 'NAV_START' } )
371 $cookie->{ 'NAV_START' } =~ tr/,//d;
372 $cookie->{ 'NAV_START' } = 0 if $cookie->{ 'NAV_START' } < 0;
376 $cookie->{ 'NAV_START' } = 0;
383 # Martin A. Hansen, November 2009.
385 # Decommify the cookie value for NAV_END and adjust it to prevent
386 # overshooting the max value for the contig size as determined
389 my ( $cookie, # cookie hash
396 $max = Maasha::Filesys::file_size( Maasha::BGB::Track::path_seq( $cookie ) );
398 if ( defined $cookie->{ 'NAV_END' } )
400 $cookie->{ 'NAV_END' } =~ tr/,//d;
401 $cookie->{ 'NAV_END' } = $max if $cookie->{ 'NAV_END' } > $max;
405 $cookie->{ 'NAV_END' } = $max;
412 # Martin A. Hansen, November 2009.
414 # Adjust the cookie values for NAV_START and NAV_END based
415 # on cookie ZOOM values.
417 my ( $cookie, # cookie hash
422 my ( $max, $dist, $new_dist, $dist_diff );
424 $max = Maasha::Filesys::file_size( Maasha::BGB::Track::path_seq( $cookie ) );
426 $dist = $cookie->{ 'NAV_END' } - $cookie->{ 'NAV_START' };
428 if ( defined $cookie->{ 'ZOOM_IN1' } ) {
429 $new_dist = $dist / 1.5;
430 } elsif ( defined $cookie->{ 'ZOOM_IN2' } ) {
431 $new_dist = $dist / 3;
432 } elsif ( defined $cookie->{ 'ZOOM_IN3' } ) {
433 $new_dist = $dist / 10;
434 } elsif ( defined $cookie->{ 'ZOOM_OUT1' } ) {
435 $new_dist = $dist * 1.5;
436 } elsif ( defined $cookie->{ 'ZOOM_OUT2' } ) {
437 $new_dist = $dist * 3;
438 } elsif ( defined $cookie->{ 'ZOOM_OUT3' } ) {
439 $new_dist = $dist * 10;
444 $dist_diff = $dist - $new_dist;
446 $cookie->{ 'NAV_START' } = int( $cookie->{ 'NAV_START' } + ( $dist_diff / 2 ) );
447 $cookie->{ 'NAV_END' } = int( $cookie->{ 'NAV_END' } - ( $dist_diff / 2 ) );
449 $cookie->{ 'NAV_START' } = 0 if $cookie->{ 'NAV_START' } < 0;
450 $cookie->{ 'NAV_END' } = $max if $cookie->{ 'NAV_END' } > $max;
457 # Martin A. Hansen, November 2009.
459 # Adjust the cookie values for NAV_START and NAV_END based
460 # on cookie MOVE values.
462 my ( $cookie, # cookie hash
467 my ( $max, $dist, $shift, $new_start, $new_end );
469 $max = Maasha::Filesys::file_size( Maasha::BGB::Track::path_seq( $cookie ) );
471 $dist = $cookie->{ 'NAV_END' } - $cookie->{ 'NAV_START' };
473 if ( defined $cookie->{ 'MOVE_LEFT1' } ) {
474 $shift = -1 * $dist * 0.10;
475 } elsif ( defined $cookie->{ 'MOVE_LEFT2' } ) {
476 $shift = -1 * $dist * 0.475;
477 } elsif ( defined $cookie->{ 'MOVE_LEFT3' } ) {
478 $shift = -1 * $dist * 0.95;
479 } elsif ( defined $cookie->{ 'MOVE_RIGHT1' } ) {
480 $shift = $dist * 0.10;
481 } elsif ( defined $cookie->{ 'MOVE_RIGHT2' } ) {
482 $shift = $dist * 0.475;
483 } elsif ( defined $cookie->{ 'MOVE_RIGHT3' } ) {
484 $shift = $dist * 0.95;
489 $new_start = int( $cookie->{ 'NAV_START' } + $shift );
490 $new_end = int( $cookie->{ 'NAV_END' } + $shift );
492 if ( $new_start > 0 and $new_end < $max )
494 $cookie->{ 'NAV_START' } = $new_start;
495 $cookie->{ 'NAV_END' } = $new_end;
503 # Martin A. Hansen, March 2010.
505 # Adjust the cookie values for NAV_START and NAV_END based
506 # on cookie CENTER value if defined.
508 my ( $cookie, # cookie hash
513 my ( $l_dist, $r_dist );
515 if ( defined $cookie->{ 'NAV_CENTER' } )
517 $l_dist = $cookie->{ 'NAV_CENTER' } - $cookie->{ 'NAV_START' };
518 $r_dist = $cookie->{ 'NAV_END' } - $cookie->{ 'NAV_CENTER' };
520 if ( $l_dist > $r_dist ) {
521 $cookie->{ 'NAV_START' } = $cookie->{ 'NAV_END' } - 2 * $r_dist;
523 $cookie->{ 'NAV_END' } = $cookie->{ 'NAV_START' } + 2 * $l_dist;
529 sub cookie_track_status
531 # Martin A. Hansen, March 2010.
535 my ( $cookie, # cookie hash
540 my ( $clade, $genome, $assembly, $track );
542 $clade = $cookie->{ 'CLADE' };
543 $genome = $cookie->{ 'GENOME' };
544 $assembly = $cookie->{ 'ASSEMBLY' };
545 $track = $cookie->{ 'TRACK' };
549 if ( $cookie->{ 'TRACK_STATUS' }->{ $clade }->{ $genome }->{ $assembly }->{ $track } ) {
550 $cookie->{ 'TRACK_STATUS' }->{ $clade }->{ $genome }->{ $assembly }->{ $track } = 0;
552 $cookie->{ 'TRACK_STATUS' }->{ $clade }->{ $genome }->{ $assembly }->{ $track } = 1;
558 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> PAGES <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
563 # Martin A. Hansen, November 2009.
565 # Determines what page to render based on
566 # the cookie's PAGE setting.
568 my ( $cookie, # cookie hash
575 if ( $cookie->{ 'SESSION_ID' } ) {
576 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "session_id", value => $cookie->{ 'SESSION_ID' } ) );
579 if ( $cookie->{ 'PAGE' } eq 'login' ) {
580 push @html, page_login( $cookie );
581 } elsif ( $cookie->{ 'PAGE' } eq 'search' ) {
582 push @html, page_search( $cookie );
583 } elsif ( $cookie->{ 'PAGE' } eq 'browse' ) {
584 push @html, page_browse( $cookie );
585 } elsif ( $cookie->{ 'PAGE' } eq 'dna' ) {
586 push @html, page_dna( $cookie );
587 } elsif ( $cookie->{ 'PAGE' } eq 'export' ) {
588 push @html, page_export( $cookie );
589 } elsif ( $cookie->{ 'PAGE' } eq 'clade' ) {
590 push @html, page_clade( $cookie );
591 } elsif ( $cookie->{ 'PAGE' } eq 'genome' ) {
592 push @html, page_genome( $cookie );
593 } elsif ( $cookie->{ 'PAGE' } eq 'assembly' ) {
594 push @html, page_assembly( $cookie );
595 } elsif ( $cookie->{ 'PAGE' } eq 'contig' ) {
596 push @html, page_contig( $cookie );
599 return wantarray ? @html : \@html;
605 # Martin A. Hansen, December 2009.
607 # Renders the login page.
616 push @html, section_login( $cookie );
618 return wantarray ? @html : \@html;
624 # Martin A. Hansen, December 2009.
626 # Renders the search page.
635 push @html, section_taxonomy_table( $cookie );
636 push @html, section_search( $cookie );
638 return wantarray ? @html : \@html;
644 # Martin A. Hansen, November 2009.
646 # Renders the browse page.
655 push @html, section_taxonomy_table( $cookie );
656 push @html, section_navigate( $cookie );
657 push @html, section_browse( $cookie );
658 push @html, section_linkout( $cookie );
660 return wantarray ? @html : \@html;
666 # Martin A. Hansen, November 2009.
668 # Renders the DNA page.
677 push @html, section_taxonomy_table( $cookie );
678 push @html, section_dna( $cookie );
680 return wantarray ? @html : \@html;
686 # Martin A. Hansen, November 2009.
688 # Renders the export page.
697 push @html, section_taxonomy_table( $cookie );
698 push @html, section_export( $cookie );
700 return wantarray ? @html : \@html;
706 # Martin A. Hansen, March 2010.
708 # Renders the clade selection page.
710 my ( $cookie, # cookie hash
717 push @html, section_taxonomy_table( $cookie );
718 push @html, section_clade( $cookie );
720 return wantarray ? @html : \@html;
726 # Martin A. Hansen, March 2010.
728 # Renders the genome selection page.
730 my ( $cookie, # cookie hash
737 push @html, section_taxonomy_table( $cookie );
738 push @html, section_genome( $cookie );
740 return wantarray ? @html : \@html;
746 # Martin A. Hansen, March 2010.
748 # Renders the clade selection page.
750 my ( $cookie, # cookie hash
757 push @html, section_taxonomy_table( $cookie );
758 push @html, section_assembly( $cookie );
760 return wantarray ? @html : \@html;
766 # Martin A. Hansen, November 2009.
768 # Renders the browse page.
770 my ( $cookie, # cookie hash
777 push @html, section_taxonomy_table( $cookie );
778 push @html, section_contig( $cookie );
780 return wantarray ? @html : \@html;
784 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> SECTIONS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
789 # Martin A. Hansen, December 2009.
791 # Returns a HTML section with a login menu.
793 my ( $cookie, # cookie hash
798 my ( $user, $password, $login, @html );
800 $user = Maasha::XHTML::text( name => "user", value => "", size => 20 );
801 $password = Maasha::XHTML::password( name => "password", value => "", size => 20 );
802 $login = Maasha::XHTML::submit( name => "login_submit", value => "Login" );
804 push @html, Maasha::XHTML::h2( txt => "Login", class => 'center' );
806 push @html, Maasha::XHTML::table_beg( summary => "Login table", align => 'center' );
807 push @html, Maasha::XHTML::table_row_simple( tr => [ "User:", $user ] );
808 push @html, Maasha::XHTML::table_row_simple( tr => [ "Password:", $password ] );
809 push @html, Maasha::XHTML::table_row_simple( tr => [ "", $login ] );
810 push @html, Maasha::XHTML::table_end;
812 if ( defined $cookie->{ 'CLADE' } and
813 defined $cookie->{ 'GENOME' } and
814 defined $cookie->{ 'ASSEMBLY' } and
815 defined $cookie->{ 'CONTIG' } and
816 defined $cookie->{ 'NAV_START' } and
817 defined $cookie->{ 'NAV_END' }
820 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "clade", value => $cookie->{ 'CLADE' } ) );
821 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "genome", value => $cookie->{ 'GENOME' } ) );
822 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "assembly", value => $cookie->{ 'ASSEMBLY' } ) );
823 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "contig", value => $cookie->{ 'CONTIG' } ) );
824 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "nav_start", value => $cookie->{ 'NAV_START' } ) );
825 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "nav_end", value => $cookie->{ 'NAV_END' } ) );
828 if ( $cookie->{ 'LOGIN_ERROR' } ) {
829 push @html, Maasha::XHTML::h3( txt => "Bad user or password - please retry", class => 'error' );
832 return wantarray ? @html : \@html;
836 sub section_taxonomy_table
838 # Martin A. Hansen, November 2009.
840 # Returns a HTML section with a taxonomy table
841 # showing the location in the taxonomy and with
842 # links to browse the taxonomy.
844 my ( $cookie, # cookie hash
849 my ( $page, @row, @html, $href, $txt );
851 foreach $page ( @{ $cookie->{ 'LIST_PAGES' } } )
853 last if $page eq $cookie->{ 'PAGE' } or $page eq 'browse';
855 $href = "$cookie->{ 'SCRIPT' }?page=$page";
856 $href .= "&session_id=$cookie->{ 'SESSION_ID' }";
857 $href .= "&user=$cookie->{ 'USER' }";
858 $href .= "&clade=$cookie->{ 'CLADE' }" if $page !~ /clade/;
859 $href .= "&genome=$cookie->{ 'GENOME' }" if $page !~ /clade|genome/;
860 $href .= "&assembly=$cookie->{ 'ASSEMBLY' }" if $page !~ /clade|genome|assembly/;
861 $href .= "&contig=$cookie->{ 'CONTIG' }" if $page !~ /clade|genome|assembly|contig/;
863 $txt = ": $cookie->{ uc $page }";
865 push @row, Maasha::XHTML::ln( txt => $page, href => $href, class => 'inline' );
866 push @row, Maasha::XHTML::p( txt => $txt, class => 'inline' );
869 push @html, Maasha::XHTML::table_beg( summary => "Taxonomy table", align => 'center', cellpadding => '5px' );
870 push @html, Maasha::XHTML::table_row_simple( tr => [ join( "\n", @row ) ], align => 'center' );
871 push @html, Maasha::XHTML::table_end;
873 return wantarray ? @html : \@html;
879 # Martin A. Hansen, March 2010.
881 # Returns a HTML section with clade selection choices
882 # for navigating the taxonomy tree.
884 my ( $cookie, # cookie hash
889 my ( @html, $clade, $href );
891 push @html, Maasha::XHTML::h2( txt => "Select clade", class => 'center' );
893 push @html, Maasha::XHTML::table_beg( summary => "Taxonomy select table", align => 'center', cellpadding => '5px' );
895 foreach $clade ( @{ $cookie->{ 'LIST_CLADE' } } )
897 $href = "$cookie->{ 'SCRIPT' }?page=genome";
898 $href .= "&session_id=$cookie->{ 'SESSION_ID' }";
899 $href .= "&user=$cookie->{ 'USER' }";
900 $href .= "&clade=$clade";
902 push @html, Maasha::XHTML::table_row_simple( tr => [ Maasha::XHTML::ln( txt => $clade, href => $href ) ] );
905 push @html, Maasha::XHTML::table_end;
907 return wantarray ? @html : \@html;
913 # Martin A. Hansen, March 2010.
915 # Returns a HTML section with genome selection choices
916 # for navigating the taxonomy tree.
918 my ( $cookie, # cookie hash
923 my ( @html, $genome, $href );
925 push @html, Maasha::XHTML::h2( txt => "Select genome", class => 'center' );
927 push @html, Maasha::XHTML::table_beg( summary => "Taxonomy select table", align => 'center', cellpadding => '5px' );
929 foreach $genome ( @{ $cookie->{ 'LIST_GENOME' } } )
931 $href = "$cookie->{ 'SCRIPT' }?page=assembly";
932 $href .= "&session_id=$cookie->{ 'SESSION_ID' }";
933 $href .= "&user=$cookie->{ 'USER' }";
934 $href .= "&clade=$cookie->{ 'CLADE' }";
935 $href .= "&genome=$genome";
937 push @html, Maasha::XHTML::table_row_simple( tr => [ Maasha::XHTML::ln( txt => $genome, href => $href ) ] );
940 push @html, Maasha::XHTML::table_end;
942 return wantarray ? @html : \@html;
948 # Martin A. Hansen, March 2010.
950 # Returns a HTML section with assembly selection choices
951 # for navigating the taxonomy tree.
953 my ( $cookie, # cookie hash
958 my ( @html, $assembly, $href );
960 push @html, Maasha::XHTML::h2( txt => "Select assembly", class => 'center' );
962 push @html, Maasha::XHTML::table_beg( summary => "Taxonomy select table", align => 'center', cellpadding => '5px' );
964 foreach $assembly ( @{ $cookie->{ 'LIST_ASSEMBLY' } } )
966 $href = "$cookie->{ 'SCRIPT' }?page=contig";
967 $href .= "&session_id=$cookie->{ 'SESSION_ID' }";
968 $href .= "&user=$cookie->{ 'USER' }";
969 $href .= "&clade=$cookie->{ 'CLADE' }";
970 $href .= "&genome=$cookie->{ 'GENOME' }";
971 $href .= "&assembly=$assembly";
973 push @html, Maasha::XHTML::table_row_simple( tr => [ Maasha::XHTML::ln( txt => $assembly, href => $href ) ] );
976 push @html, Maasha::XHTML::table_end;
978 return wantarray ? @html : \@html;
984 # Martin A. Hansen, March 2010.
986 # Returns a HTML section with contig selection choices
987 # for navigating the taxonomy tree.
989 my ( $cookie, # cookie hash
994 my ( @html, $contig, $href );
996 push @html, Maasha::XHTML::h2( txt => "Select contig", class => 'center' );
998 push @html, Maasha::XHTML::table_beg( summary => "Taxonomy select table", align => 'center', cellpadding => '5px' );
1000 foreach $contig ( @{ $cookie->{ 'LIST_CONTIG' } } )
1002 $href = "$cookie->{ 'SCRIPT' }?page=browse";
1003 $href .= "&session_id=$cookie->{ 'SESSION_ID' }";
1004 $href .= "&user=$cookie->{ 'USER' }";
1005 $href .= "&clade=$cookie->{ 'CLADE' }";
1006 $href .= "&genome=$cookie->{ 'GENOME' }";
1007 $href .= "&assembly=$cookie->{ 'ASSEMBLY' }";
1008 $href .= "&contig=$contig";
1010 push @html, Maasha::XHTML::table_row_simple( tr => [ Maasha::XHTML::ln( txt => $contig, href => $href ) ] );
1013 push @html, Maasha::XHTML::table_end;
1015 return wantarray ? @html : \@html;
1019 sub section_navigate
1021 # Martin A. Hansen, November 2009.
1023 # Returns a HTML section for navigating in the browser window.
1025 my ( $cookie, # cookie hash
1030 my ( @html, $nav_val );
1032 $nav_val = Maasha::Calc::commify( $cookie->{ 'NAV_START' } ) . "-" . Maasha::Calc::commify( $cookie->{ 'NAV_END' } );
1034 push @html, Maasha::XHTML::table_beg( summary => "Navigation table", align => 'center' );
1035 push @html, Maasha::XHTML::table_row_simple( tr => [
1036 "Position or search term:",
1037 Maasha::XHTML::text( name => "nav_search", value => $nav_val, size => 30 ),
1038 Maasha::XHTML::submit( name => "nav_submit", value => "Submit" ),
1040 push @html, Maasha::XHTML::table_end;
1042 push @html, Maasha::XHTML::table_beg( summary => "Zoom table", align => 'center' );
1043 push @html, Maasha::XHTML::table_row_simple( tr => [
1044 Maasha::XHTML::p( txt => 'Move:' ),
1045 Maasha::XHTML::submit( name => "move_left3", value => "<<<", title => "move 95% to the left" ),
1046 Maasha::XHTML::submit( name => "move_left2", value => "<<", title => "move 47.5% to the left" ),
1047 Maasha::XHTML::submit( name => "move_left1", value => "<", title => "move 10% to the left" ),
1048 Maasha::XHTML::submit( name => "move_right1", value => ">", title => "move 10% to the rigth" ),
1049 Maasha::XHTML::submit( name => "move_right2", value => ">>", title => "move 47.5% to the rigth" ),
1050 Maasha::XHTML::submit( name => "move_right3", value => ">>>", title => "move 95% to the right" ),
1051 Maasha::XHTML::p( txt => 'Zoom in:' ),
1052 Maasha::XHTML::submit( name => "zoom_in1", value => "1.5x" ),
1053 Maasha::XHTML::submit( name => "zoom_in2", value => "3x" ),
1054 Maasha::XHTML::submit( name => "zoom_in3", value => "10x" ),
1055 Maasha::XHTML::p( txt => 'Zoom out:' ),
1056 Maasha::XHTML::submit( name => "zoom_out1", value => "1.5x" ),
1057 Maasha::XHTML::submit( name => "zoom_out2", value => "3x" ),
1058 Maasha::XHTML::submit( name => "zoom_out3", value => "10x" ),
1060 push @html, Maasha::XHTML::table_end;
1062 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "page", value => "browse" ) );
1063 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "user", value => $cookie->{ 'USER' } ) );
1064 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "clade", value => $cookie->{ 'CLADE' } ) );
1065 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "genome", value => $cookie->{ 'GENOME' } ) );
1066 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "assembly", value => $cookie->{ 'ASSEMBLY' } ) );
1067 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "contig", value => $cookie->{ 'CONTIG' } ) );
1069 return wantarray ? @html : \@html;
1075 # Martin A. Hansen, March 2010.
1077 # Returns a HTML section for a static link based on information in the cookie.
1079 my ( $cookie, # cookie hash
1084 my ( $link, @html );
1086 $link = Maasha::XHTML::ln(
1088 href => join( "&", "$cookie->{ 'SCRIPT' }?page=browse",
1089 "clade=$cookie->{ 'CLADE' }",
1090 "genome=$cookie->{ 'GENOME' }",
1091 "assembly=$cookie->{ 'ASSEMBLY' }",
1092 "contig=$cookie->{ 'CONTIG' }",
1093 "nav_start=$cookie->{ 'NAV_START' }",
1094 "nav_end=$cookie->{ 'NAV_END' }",
1096 title => "Static link to this view",
1099 push @html, Maasha::XHTML::p( txt => $link, class => 'center' );
1101 return wantarray ? @html : \@html;
1112 my ( @track_list, $i, @tracks, $track, $elem, $surface, $cr, $png_data, @html, @img, $x1, $y1, $x2, $y2, $factor, $center );
1114 push @tracks, [ Maasha::BGB::Track::track_ruler( $cookie ) ];
1115 push @tracks, [ Maasha::BGB::Track::track_seq( $cookie ) ];
1117 @track_list = Maasha::BGB::Track::list_track_dir( $cookie->{ 'USER' }, $cookie->{ 'CLADE' }, $cookie->{ 'GENOME' }, $cookie->{ 'ASSEMBLY' }, $cookie->{ 'CONTIG' } );
1119 for ( $i = 0; $i < @track_list; $i++ )
1121 $cookie->{ 'FEAT_COLOR' } = Maasha::BGB::Draw::palette( $i );
1123 push @tracks, [ Maasha::BGB::Track::track_feature( $track_list[ $i ], $cookie ) ];
1126 $surface = Cairo::ImageSurface->create( 'argb32', $cookie->{ 'IMG_WIDTH' }, $cookie->{ 'TRACK_OFFSET' } );
1127 $cr = Cairo::Context->create( $surface );
1129 $cr->rectangle( 0, 0, $cookie->{ 'IMG_WIDTH' }, $cookie->{ 'TRACK_OFFSET' } );
1130 $cr->set_source_rgb( 1, 1, 1 );
1133 foreach $track ( @tracks ) {
1134 Maasha::BGB::Draw::draw_feature( $cr, $track ) if $track;
1137 $png_data = Maasha::BGB::Draw::base64_png( $surface );
1139 push @img, Maasha::XHTML::img(
1140 src => "data:image/png;base64,$png_data",
1141 alt => "Browser Tracks",
1142 height => $cookie->{ 'TRACK_OFFSET' },
1143 width => $cookie->{ 'IMG_WIDTH' },
1144 id => "browser_map",
1145 usemap => "#browser_map"
1148 push @img, Maasha::XHTML::map_beg( name => "browser_map", id => "browser_map" );
1150 $factor = ( $cookie->{ 'NAV_END' } - $cookie->{ 'NAV_START' } + 1 ) / $cookie->{ 'IMG_WIDTH' };
1152 for ( $i = 0; $i < $cookie->{ 'IMG_WIDTH' }; $i += 5 )
1159 $center = int( $cookie->{ 'NAV_START' } + $factor * $i );
1161 push @img, Maasha::XHTML::area(
1162 href => join( "&", "$cookie->{ 'SCRIPT' }?page=browse",
1163 "session_id=$cookie->{ 'SESSION_ID' }",
1164 "user=$cookie->{ 'USER' }",
1165 "clade=$cookie->{ 'CLADE' }",
1166 "genome=$cookie->{ 'GENOME' }",
1167 "assembly=$cookie->{ 'ASSEMBLY' }",
1168 "contig=$cookie->{ 'CONTIG' }",
1169 "nav_start=$cookie->{ 'NAV_START' }",
1170 "nav_end=$cookie->{ 'NAV_END' }",
1171 "nav_center=$center",
1174 coords => "$x1, $y1, $x2, $y2",
1175 title => "Center on " . Maasha::Calc::commify( $center ),
1179 foreach $track ( @tracks )
1181 foreach $elem ( @{ $track } )
1183 next if $elem->{ 'type' } =~ /text|wiggle/;
1185 if ( $elem->{ 'type' } eq 'track_name' )
1187 $x1 = $elem->{ 'x1' };
1188 $y1 = $elem->{ 'y1' } - 10;
1189 $x2 = $elem->{ 'x1' } + 6 * length $elem->{ 'txt' };
1190 $y2 = $elem->{ 'y1' };
1192 if ( Maasha::BGB::Track::track_hide( $cookie, $elem->{ 'track' } ) )
1194 push @img, Maasha::XHTML::area(
1195 href => join( "&", "$cookie->{ 'SCRIPT' }?page=browse",
1196 "session_id=$cookie->{ 'SESSION_ID' }",
1197 "user=$cookie->{ 'USER' }",
1198 "clade=$cookie->{ 'CLADE' }",
1199 "genome=$cookie->{ 'GENOME' }",
1200 "assembly=$cookie->{ 'ASSEMBLY' }",
1201 "contig=$cookie->{ 'CONTIG' }",
1202 "track=$elem->{ 'track' }",
1205 coords => "$x1, $y1, $x2, $y2",
1206 title => qq(Show track: $elem->{ 'txt' }),
1211 push @img, Maasha::XHTML::area(
1212 href => join( "&", "$cookie->{ 'SCRIPT' }?page=browse",
1213 "session_id=$cookie->{ 'SESSION_ID' }",
1214 "user=$cookie->{ 'USER' }",
1215 "clade=$cookie->{ 'CLADE' }",
1216 "genome=$cookie->{ 'GENOME' }",
1217 "assembly=$cookie->{ 'ASSEMBLY' }",
1218 "contig=$cookie->{ 'CONTIG' }",
1219 "track=$elem->{ 'track' }",
1222 coords => "$x1, $y1, $x2, $y2",
1223 title => qq(Hide track: $elem->{ 'txt' }),
1229 push @img, Maasha::XHTML::area(
1230 href => join( "&", "$cookie->{ 'SCRIPT' }?page=export",
1231 "session_id=$cookie->{ 'SESSION_ID' }",
1232 "user=$cookie->{ 'USER' }",
1233 "clade=$cookie->{ 'CLADE' }",
1234 "genome=$cookie->{ 'GENOME' }",
1235 "assembly=$cookie->{ 'ASSEMBLY' }",
1236 "contig=$cookie->{ 'CONTIG' }",
1237 "s_beg=$elem->{ 's_beg' }",
1238 "s_end=$elem->{ 's_end' }",
1239 "strand=$elem->{ 'strand' }",
1240 "q_id=$elem->{ 'q_id' }",
1243 coords => "$elem->{ x1 }, $elem->{ y1 }, $elem->{ x2 }, $elem->{ y2 }",
1244 title => "$elem->{ 'title' }",
1250 push @img, Maasha::XHTML::map_end();
1252 push @html, Maasha::XHTML::p( txt => join( "\n", @img ) );
1254 @html = Maasha::XHTML::div( txt => join( "\n", @html ), class => 'browse' );
1256 return wantarray ? @html : \@html;
1262 # Martin A. Hansen, November 2009.
1264 # Returns a HTML section with export table.
1266 my ( $cookie, # cookie hash
1271 my ( $feat, @row_dna_contig, @html );
1273 $feat = $cookie->{ 'Q_ID' } || "[no name]";
1275 push @row_dna_contig, Maasha::XHTML::p( txt => qq(Export Feature: "$feat" DNA from Contig: ), class => 'inline' );
1276 push @row_dna_contig, Maasha::XHTML::p( txt => "$cookie->{ 'CONTIG' } Start: ", class => 'inline' );
1277 push @row_dna_contig, Maasha::XHTML::text( name => "s_beg", value => Maasha::Calc::commify( $cookie->{ 'S_BEG' } ), size => 15 );
1278 push @row_dna_contig, Maasha::XHTML::p( txt => "End: ", class => 'inline' );
1279 push @row_dna_contig, Maasha::XHTML::text( name => "s_end", value => Maasha::Calc::commify( $cookie->{ 'S_END' } ), size => 15 );
1280 push @row_dna_contig, Maasha::XHTML::p( txt => "Strand: ", class => 'inline' );
1281 push @row_dna_contig, Maasha::XHTML::menu( name => "strand", options => [ qw( + - ) ], selected => $cookie->{ 'STRAND' } );
1282 push @row_dna_contig, Maasha::XHTML::submit( name => "export", value => "Export", title => "Fetch DNA from this region" );
1284 push @html, Maasha::XHTML::h2( txt => "Export", class => 'center' );
1285 push @html, Maasha::XHTML::table_beg( summary => "Taxonomy select table", align => 'center' );
1286 push @html, Maasha::XHTML::table_row_simple( tr => \@row_dna_contig );
1287 push @html, Maasha::XHTML::table_end;
1289 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "page", value => "dna" ) );
1290 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "user", value => $cookie->{ 'USER' } ) );
1291 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "clade", value => $cookie->{ 'CLADE' } ) );
1292 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "genome", value => $cookie->{ 'GENOME' } ) );
1293 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "assembly", value => $cookie->{ 'ASSEMBLY' } ) );
1294 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "contig", value => $cookie->{ 'CONTIG' } ) );
1296 return wantarray ? @html : \@html;
1302 # Martin A. Hansen, November 2009.
1304 # Returns a HTML section with export table.
1306 my ( $cookie, # cookie hash
1311 my ( $results, $result, $count, @html, $export, $browse );
1313 $results = Maasha::BGB::Track::search_tracks( $cookie );
1315 $count = scalar @{ $results };
1317 push @html, Maasha::XHTML::h2( txt => "Search", class => 'center' );
1318 push @html, Maasha::XHTML::p( txt => qq(Results for "$cookie->{ 'SEARCH' }": $count), class => 'center' );
1322 push @html, Maasha::XHTML::table_beg( summary => "Search table", align => 'center', cellpadding => '5px' );
1323 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) ] );
1325 foreach $result ( @{ $results } )
1327 $cookie->{ 'CONTIG' } = $result->{ 'S_ID' };
1328 $cookie->{ 'NAV_START' } = $result->{ 'S_BEG' };
1329 $cookie->{ 'NAV_END' } = $result->{ 'S_END' };
1330 $cookie->{ 'S_BEG' } = $result->{ 'S_BEG' };
1331 $cookie->{ 'S_END' } = $result->{ 'S_END' };
1332 $cookie->{ 'STRAND' } = $result->{ 'STRAND' };
1333 $cookie->{ 'Q_ID' } = $result->{ 'Q_ID' };
1335 $browse = Maasha::XHTML::ln(
1337 href => join( "&", "$cookie->{ 'SCRIPT' }?page=browse",
1338 "session_id=$cookie->{ 'SESSION_ID' }",
1339 "user=$cookie->{ 'USER' }",
1340 "clade=$cookie->{ 'CLADE' }",
1341 "genome=$cookie->{ 'GENOME' }",
1342 "assembly=$cookie->{ 'ASSEMBLY' }",
1343 "contig=$cookie->{ 'CONTIG' }",
1344 "nav_start=$cookie->{ 'NAV_START' }",
1345 "nav_end=$cookie->{ 'NAV_END' }",
1350 $export = Maasha::XHTML::ln(
1352 href => join( "&", "$cookie->{ 'SCRIPT' }?page=export",
1353 "session_id=$cookie->{ 'SESSION_ID' }",
1354 "user=$cookie->{ 'USER' }",
1355 "clade=$cookie->{ 'CLADE' }",
1356 "genome=$cookie->{ 'GENOME' }",
1357 "assembly=$cookie->{ 'ASSEMBLY' }",
1358 "contig=$cookie->{ 'CONTIG' }",
1359 "s_beg=$cookie->{ 'S_BEG' }",
1360 "s_end=$cookie->{ 'S_END' }",
1361 "strand=$cookie->{ 'STRAND' }",
1365 push @html, Maasha::XHTML::table_row_advanced(
1366 tr => [ { td => $result->{ 'S_ID' } },
1367 { td => $result->{ 'S_BEG' }, align => 'right' },
1368 { td => $result->{ 'S_END' }, align => 'right' },
1369 { td => $result->{ 'Q_ID' } },
1370 { td => $result->{ 'SCORE' }, align => 'right' },
1371 { td => $result->{ 'STRAND' } },
1372 { td => $result->{ 'HITS' }, align => 'right' },
1373 { td => $result->{ 'ALIGN' } },
1374 { td => $result->{ 'BLOCK_COUNT' }, align => 'right' },
1375 { td => $result->{ 'BLOCK_BEGS' } },
1376 { td => $result->{ 'BLOCK_LENS' } },
1377 { td => $result->{ 'BLOCK_TYPE' } },
1380 ], class => "monospace"
1384 push @html, Maasha::XHTML::table_end;
1387 return wantarray ? @html : \@html;
1393 # Martin A. Hansen, November 2009.
1395 # Returns a HTML section with extracted DNA.
1397 my ( $cookie, # cookie hash
1402 my ( @html, $beg, $end, $seq );
1404 $beg = $cookie->{ 'S_BEG' };
1405 $end = $cookie->{ 'S_END' };
1409 $seq = join ";", ">$cookie->{ 'GENOME' }", $cookie->{ 'ASSEMBLY' }, $cookie->{ 'CONTIG' }, $beg, $end, "$cookie->{ 'STRAND' }\n";
1410 $seq .= Maasha::BGB::Track::dna_get( $cookie );
1412 push @html, Maasha::XHTML::h2( txt => "DNA", class => 'center' );
1413 push @html, Maasha::XHTML::pre( txt => $seq );
1415 return wantarray ? @html : \@html;
1419 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<