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' } = defined $cgi->param( 's_beg' ) ? $cgi->param( 's_beg' ) : $session->{ 'S_BEG' };
151 $cookie->{ 'S_END' } = defined $cgi->param( '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 # TODO: Redundant?
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' } );
186 if ( $cookie->{ 'CLADE' } )
188 $cookie->{ 'LIST_GENOME' } = Maasha::BGB::Track::list_genomes( $cookie->{ 'USER' }, $cookie->{ 'CLADE' } );
190 if ( $cookie->{ 'GENOME' } )
192 $cookie->{ 'LIST_ASSEMBLY' } = Maasha::BGB::Track::list_assemblies( $cookie->{ 'USER' }, $cookie->{ 'CLADE' }, $cookie->{ 'GENOME' } );
194 if ( $cookie->{ 'ASSEMBLY' } )
196 $cookie->{ 'LIST_CONTIG' } = Maasha::BGB::Track::list_contigs( $cookie->{ 'USER' }, $cookie->{ 'CLADE' }, $cookie->{ 'GENOME' }, $cookie->{ 'ASSEMBLY' } );
201 if ( $cookie->{ 'CONTIG' } )
203 cookie_start( $cookie );
204 cookie_end( $cookie );
205 cookie_zoom( $cookie );
206 cookie_move( $cookie );
207 cookie_center( $cookie );
208 cookie_track_status( $cookie );
212 $cookie->{ 'STRAND' } = '+' if defined $cookie->{ 'STRAND' } and $cookie->{ 'STRAND' } eq ' '; # FIXME ugly HTML fix
214 session_store( $cookie, $session );
216 return wantarray ? %{ $cookie } : $cookie;
222 # Martin A. Hansen, March 2010.
224 # Restores session and returns this.
226 my ( $cookie, # cookie hash
233 if ( defined $cookie->{ 'USER' } and -d "$cookie->{ 'SESSION_DIR' }/$cookie->{ 'USER' }" ) {
234 $session = Maasha::BGB::Session::session_restore( "$cookie->{ 'SESSION_DIR' }/$cookie->{ 'USER' }/session.json" );
237 return wantarray ? %{ $session } : $session;
243 # Martin A. Hansen, March 2010.
245 # Store a session updated with cookie information to session file.
247 my ( $cookie, # cookie hash
248 $session, # session hash
255 if ( defined $cookie->{ 'USER' } and $cookie->{ 'USER' } ne '' and -d "$cookie->{ 'SESSION_DIR' }/$cookie->{ 'USER' }" )
257 $new_session->{ 'PASSWORD' } = $session->{ 'PASSWORD' };
258 $new_session->{ 'SESSION_ID' } = $session->{ 'SESSION_ID' };
259 $new_session->{ 'TIME' } = Maasha::Common::time_stamp();
260 $new_session->{ 'PAGE' } = $cookie->{ 'PAGE' };
262 if ( $cookie->{ 'PAGE' } =~ /browse|export_pdf|export_svg/ )
264 $new_session->{ 'CLADE' } = $cookie->{ 'CLADE' };
265 $new_session->{ 'GENOME' } = $cookie->{ 'GENOME' };
266 $new_session->{ 'ASSEMBLY' } = $cookie->{ 'ASSEMBLY' };
267 $new_session->{ 'CONTIG' } = $cookie->{ 'CONTIG' };
268 $new_session->{ 'NAV_START' } = $cookie->{ 'NAV_START' };
269 $new_session->{ 'NAV_END' } = $cookie->{ 'NAV_END' };
271 elsif ( $cookie->{ 'PAGE' } eq 'contig' )
273 $new_session->{ 'CLADE' } = $cookie->{ 'CLADE' };
274 $new_session->{ 'GENOME' } = $cookie->{ 'GENOME' };
275 $new_session->{ 'ASSEMBLY' } = $cookie->{ 'ASSEMBLY' };
277 elsif ( $cookie->{ 'PAGE' } eq 'assembly' )
279 $new_session->{ 'CLADE' } = $cookie->{ 'CLADE' };
280 $new_session->{ 'GENOME' } = $cookie->{ 'GENOME' };
282 elsif ( $cookie->{ 'PAGE' } eq 'genome' )
284 $new_session->{ 'CLADE' } = $cookie->{ 'CLADE' };
286 elsif ( $cookie->{ 'PAGE' } =~ /export|dna/ )
288 $new_session->{ 'CLADE' } = $cookie->{ 'CLADE' };
289 $new_session->{ 'GENOME' } = $cookie->{ 'GENOME' };
290 $new_session->{ 'ASSEMBLY' } = $cookie->{ 'ASSEMBLY' };
291 $new_session->{ 'CONTIG' } = $cookie->{ 'CONTIG' };
292 $new_session->{ 'Q_ID' } = $cookie->{ 'Q_ID' };
293 $new_session->{ 'S_BEG' } = $cookie->{ 'S_BEG' };
294 $new_session->{ 'S_END' } = $cookie->{ 'S_END' };
295 $new_session->{ 'STRAND' } = $cookie->{ 'STRAND' };
298 $new_session->{ 'TRACK_STATUS' } = $cookie->{ 'TRACK_STATUS' };
300 Maasha::BGB::Session::session_store( "$cookie->{ 'SESSION_DIR' }/$cookie->{ 'USER' }/session.json", $new_session );
307 # Martin A. Hansen, March 2010.
309 # Check that the session id in the cookie and session match.
310 # Sets SESSION_ERROR flag in cookie if not matching.
312 my ( $cookie, # cookie hash
313 $session, # session hash
318 if ( defined $cookie->{ 'SESSION_ID' } and defined $session->{ 'SESSION_ID' } )
320 if ( $cookie->{ 'SESSION_ID' } ne $session->{ 'SESSION_ID' } ) {
321 $cookie->{ 'SESSION_ERROR' } = 1;
323 $cookie->{ 'SESSION_ERROR' } = 0;
331 # Martin A. Hansen, December 2009.
333 # Check a user and password from CGI against the password file and
334 # set the session ID, if found, in the cookie.
336 my ( $cookie, # cookie hash
343 if ( defined $cookie->{ 'PASSWORD' } )
345 if ( defined $cookie->{ 'USER' } and -d "$cookie->{ 'SESSION_DIR' }/$cookie->{ 'USER' }" )
347 $session = Maasha::BGB::Session::session_restore( "$cookie->{ 'SESSION_DIR' }/$cookie->{ 'USER' }/session.json" );
349 if ( $session->{ 'PASSWORD' } eq Digest::MD5::md5_hex( $cookie->{ 'PASSWORD' } ) )
351 $cookie->{ 'TIME' } = Maasha::Common::time_stamp();
352 $cookie->{ 'SESSION_ID' } ||= Maasha::BGB::Session::session_new();
353 $cookie->{ 'LOGIN' } = 1;
354 $cookie->{ 'LOGIN_ERROR' } = 0;
358 $cookie->{ 'LOGIN_ERROR' } = 1;
363 $cookie->{ 'LOGIN_ERROR' } = 1;
371 # Martin A. Hansen, November 2009.
373 # Decommify the cookie value for NAV_START and adjust it to
374 # to prevent negative values.
376 my ( $cookie, # cookie hash
381 if ( defined $cookie->{ 'NAV_START' } )
383 $cookie->{ 'NAV_START' } =~ tr/,//d;
384 $cookie->{ 'NAV_START' } = 0 if $cookie->{ 'NAV_START' } < 0;
388 $cookie->{ 'NAV_START' } = 0;
395 # Martin A. Hansen, November 2009.
397 # Decommify the cookie value for NAV_END and adjust it to prevent
398 # overshooting the max value for the contig size as determined
401 my ( $cookie, # cookie hash
408 $max = Maasha::Filesys::file_size( Maasha::BGB::Track::path_seq( $cookie ) );
410 if ( defined $cookie->{ 'NAV_END' } )
412 $cookie->{ 'NAV_END' } =~ tr/,//d;
413 $cookie->{ 'NAV_END' } = $max if $cookie->{ 'NAV_END' } > $max;
417 $cookie->{ 'NAV_END' } = $max;
424 # Martin A. Hansen, November 2009.
426 # Adjust the cookie values for NAV_START and NAV_END based
427 # on cookie ZOOM values.
429 my ( $cookie, # cookie hash
434 my ( $max, $dist, $new_dist, $dist_diff );
436 $max = Maasha::Filesys::file_size( Maasha::BGB::Track::path_seq( $cookie ) );
438 $dist = $cookie->{ 'NAV_END' } - $cookie->{ 'NAV_START' };
440 if ( defined $cookie->{ 'ZOOM_IN1' } ) {
441 $new_dist = $dist / 1.5;
442 } elsif ( defined $cookie->{ 'ZOOM_IN2' } ) {
443 $new_dist = $dist / 3;
444 } elsif ( defined $cookie->{ 'ZOOM_IN3' } ) {
445 $new_dist = $dist / 10;
446 } elsif ( defined $cookie->{ 'ZOOM_OUT1' } ) {
447 $new_dist = $dist * 1.5;
448 } elsif ( defined $cookie->{ 'ZOOM_OUT2' } ) {
449 $new_dist = $dist * 3;
450 } elsif ( defined $cookie->{ 'ZOOM_OUT3' } ) {
451 $new_dist = $dist * 10;
456 $dist_diff = $dist - $new_dist;
458 $cookie->{ 'NAV_START' } = int( $cookie->{ 'NAV_START' } + ( $dist_diff / 2 ) );
459 $cookie->{ 'NAV_END' } = int( $cookie->{ 'NAV_END' } - ( $dist_diff / 2 ) );
461 $cookie->{ 'NAV_START' } = 0 if $cookie->{ 'NAV_START' } < 0;
462 $cookie->{ 'NAV_END' } = $max if $cookie->{ 'NAV_END' } > $max;
469 # Martin A. Hansen, November 2009.
471 # Adjust the cookie values for NAV_START and NAV_END based
472 # on cookie MOVE values.
474 my ( $cookie, # cookie hash
479 my ( $max, $dist, $shift, $new_start, $new_end );
481 $max = Maasha::Filesys::file_size( Maasha::BGB::Track::path_seq( $cookie ) );
483 $dist = $cookie->{ 'NAV_END' } - $cookie->{ 'NAV_START' };
485 if ( defined $cookie->{ 'MOVE_LEFT1' } ) {
486 $shift = -1 * $dist * 0.10;
487 } elsif ( defined $cookie->{ 'MOVE_LEFT2' } ) {
488 $shift = -1 * $dist * 0.475;
489 } elsif ( defined $cookie->{ 'MOVE_LEFT3' } ) {
490 $shift = -1 * $dist * 0.95;
491 } elsif ( defined $cookie->{ 'MOVE_RIGHT1' } ) {
492 $shift = $dist * 0.10;
493 } elsif ( defined $cookie->{ 'MOVE_RIGHT2' } ) {
494 $shift = $dist * 0.475;
495 } elsif ( defined $cookie->{ 'MOVE_RIGHT3' } ) {
496 $shift = $dist * 0.95;
501 $new_start = int( $cookie->{ 'NAV_START' } + $shift );
502 $new_end = int( $cookie->{ 'NAV_END' } + $shift );
504 if ( $new_start > 0 and $new_end < $max )
506 $cookie->{ 'NAV_START' } = $new_start;
507 $cookie->{ 'NAV_END' } = $new_end;
515 # Martin A. Hansen, March 2010.
517 # Adjust the cookie values for NAV_START and NAV_END based
518 # on cookie CENTER value if defined.
520 my ( $cookie, # cookie hash
525 my ( $l_dist, $r_dist );
527 if ( defined $cookie->{ 'NAV_CENTER' } )
529 $l_dist = $cookie->{ 'NAV_CENTER' } - $cookie->{ 'NAV_START' };
530 $r_dist = $cookie->{ 'NAV_END' } - $cookie->{ 'NAV_CENTER' };
532 if ( $l_dist > $r_dist ) {
533 $cookie->{ 'NAV_START' } = $cookie->{ 'NAV_END' } - 2 * $r_dist;
535 $cookie->{ 'NAV_END' } = $cookie->{ 'NAV_START' } + 2 * $l_dist;
541 sub cookie_track_status
543 # Martin A. Hansen, March 2010.
547 my ( $cookie, # cookie hash
552 my ( $clade, $genome, $assembly, $track );
554 $clade = $cookie->{ 'CLADE' };
555 $genome = $cookie->{ 'GENOME' };
556 $assembly = $cookie->{ 'ASSEMBLY' };
557 $track = $cookie->{ 'TRACK' };
561 if ( $cookie->{ 'TRACK_STATUS' }->{ $clade }->{ $genome }->{ $assembly }->{ $track } ) {
562 $cookie->{ 'TRACK_STATUS' }->{ $clade }->{ $genome }->{ $assembly }->{ $track } = 0;
564 $cookie->{ 'TRACK_STATUS' }->{ $clade }->{ $genome }->{ $assembly }->{ $track } = 1;
570 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> PAGES <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
575 # Martin A. Hansen, November 2009.
577 # Determines what page to render based on
578 # the cookie's PAGE setting.
580 my ( $cookie, # cookie hash
587 if ( $cookie->{ 'SESSION_ID' } ) {
588 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "session_id", value => $cookie->{ 'SESSION_ID' } ) );
591 if ( $cookie->{ 'PAGE' } eq 'login' ) {
592 push @html, page_login( $cookie );
593 } elsif ( $cookie->{ 'PAGE' } eq 'search' ) {
594 push @html, page_search( $cookie );
595 } elsif ( $cookie->{ 'PAGE' } eq 'browse' ) {
596 push @html, page_browse( $cookie );
597 } elsif ( $cookie->{ 'PAGE' } eq 'dna' ) {
598 push @html, page_dna( $cookie );
599 } elsif ( $cookie->{ 'PAGE' } eq 'export' ) {
600 push @html, page_export( $cookie );
601 } elsif ( $cookie->{ 'PAGE' } eq 'export_pdf' ) {
602 push @html, page_export_pdf( $cookie );
603 } elsif ( $cookie->{ 'PAGE' } eq 'export_svg' ) {
604 push @html, page_export_svg( $cookie );
605 } elsif ( $cookie->{ 'PAGE' } eq 'clade' ) {
606 push @html, page_clade( $cookie );
607 } elsif ( $cookie->{ 'PAGE' } eq 'genome' ) {
608 push @html, page_genome( $cookie );
609 } elsif ( $cookie->{ 'PAGE' } eq 'assembly' ) {
610 push @html, page_assembly( $cookie );
611 } elsif ( $cookie->{ 'PAGE' } eq 'contig' ) {
612 push @html, page_contig( $cookie );
615 return wantarray ? @html : \@html;
621 # Martin A. Hansen, December 2009.
623 # Renders the login page.
632 push @html, section_login( $cookie );
634 return wantarray ? @html : \@html;
640 # Martin A. Hansen, December 2009.
642 # Renders the search page.
651 push @html, section_taxonomy_table( $cookie );
652 push @html, section_search( $cookie );
654 return wantarray ? @html : \@html;
660 # Martin A. Hansen, November 2009.
662 # Renders the browse page.
671 push @html, section_taxonomy_table( $cookie );
672 push @html, section_navigate( $cookie );
673 push @html, section_browse( $cookie );
674 push @html, section_linkout( $cookie );
676 return wantarray ? @html : \@html;
682 # Martin A. Hansen, November 2009.
684 # Renders the DNA page.
693 push @html, section_taxonomy_table( $cookie );
694 push @html, section_dna( $cookie );
696 return wantarray ? @html : \@html;
702 # Martin A. Hansen, November 2009.
704 # Renders the export page.
713 push @html, section_taxonomy_table( $cookie );
714 push @html, section_export( $cookie );
716 return wantarray ? @html : \@html;
722 # Martin A. Hansen, March 2010.
724 # Renders the export PDF page.
733 push @html, section_taxonomy_table( $cookie );
734 push @html, section_export_pdf( $cookie );
736 return wantarray ? @html : \@html;
742 # Martin A. Hansen, March 2010.
744 # Renders the export SVG page.
753 push @html, section_taxonomy_table( $cookie );
754 push @html, section_export_svg( $cookie );
756 return wantarray ? @html : \@html;
762 # Martin A. Hansen, March 2010.
764 # Renders the clade selection page.
766 my ( $cookie, # cookie hash
773 push @html, section_taxonomy_table( $cookie );
774 push @html, section_clade( $cookie );
776 return wantarray ? @html : \@html;
782 # Martin A. Hansen, March 2010.
784 # Renders the genome selection page.
786 my ( $cookie, # cookie hash
793 push @html, section_taxonomy_table( $cookie );
794 push @html, section_genome( $cookie );
796 return wantarray ? @html : \@html;
802 # Martin A. Hansen, March 2010.
804 # Renders the clade selection page.
806 my ( $cookie, # cookie hash
813 push @html, section_taxonomy_table( $cookie );
814 push @html, section_assembly( $cookie );
816 return wantarray ? @html : \@html;
822 # Martin A. Hansen, November 2009.
824 # Renders the browse page.
826 my ( $cookie, # cookie hash
833 push @html, section_taxonomy_table( $cookie );
834 push @html, section_contig( $cookie );
836 return wantarray ? @html : \@html;
840 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> SECTIONS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
845 # Martin A. Hansen, December 2009.
847 # Returns a HTML section with a login menu.
849 my ( $cookie, # cookie hash
854 my ( $user, $password, $login, @html );
856 $user = Maasha::XHTML::text( name => "user", value => "", size => 20 );
857 $password = Maasha::XHTML::password( name => "password", value => "", size => 20 );
858 $login = Maasha::XHTML::submit( name => "login_submit", value => "Login" );
860 push @html, Maasha::XHTML::h2( txt => "Login", class => 'center' );
862 push @html, Maasha::XHTML::table_beg( summary => "Login table", align => 'center' );
863 push @html, Maasha::XHTML::table_row_simple( tr => [ "User:", $user ] );
864 push @html, Maasha::XHTML::table_row_simple( tr => [ "Password:", $password ] );
865 push @html, Maasha::XHTML::table_row_simple( tr => [ "", $login ] );
866 push @html, Maasha::XHTML::table_end;
868 if ( defined $cookie->{ 'CLADE' } and
869 defined $cookie->{ 'GENOME' } and
870 defined $cookie->{ 'ASSEMBLY' } and
871 defined $cookie->{ 'CONTIG' } and
872 defined $cookie->{ 'NAV_START' } and
873 defined $cookie->{ 'NAV_END' }
876 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "clade", value => $cookie->{ 'CLADE' } ) );
877 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "genome", value => $cookie->{ 'GENOME' } ) );
878 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "assembly", value => $cookie->{ 'ASSEMBLY' } ) );
879 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "contig", value => $cookie->{ 'CONTIG' } ) );
880 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "nav_start", value => $cookie->{ 'NAV_START' } ) );
881 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "nav_end", value => $cookie->{ 'NAV_END' } ) );
884 if ( $cookie->{ 'LOGIN_ERROR' } ) {
885 push @html, Maasha::XHTML::h3( txt => "Bad user or password - please retry", class => 'error' );
888 return wantarray ? @html : \@html;
892 sub section_taxonomy_table
894 # Martin A. Hansen, November 2009.
896 # Returns a HTML section with a taxonomy table
897 # showing the location in the taxonomy and with
898 # links to browse the taxonomy.
900 my ( $cookie, # cookie hash
905 my ( $page, @row, @html, $href, $txt );
907 foreach $page ( @{ $cookie->{ 'LIST_PAGES' } } )
909 last if $page eq $cookie->{ 'PAGE' } or $page eq 'browse';
911 $href = "$cookie->{ 'SCRIPT' }?page=$page";
912 $href .= "&session_id=$cookie->{ 'SESSION_ID' }";
913 $href .= "&user=$cookie->{ 'USER' }";
914 $href .= "&clade=$cookie->{ 'CLADE' }" if $page !~ /clade/;
915 $href .= "&genome=$cookie->{ 'GENOME' }" if $page !~ /clade|genome/;
916 $href .= "&assembly=$cookie->{ 'ASSEMBLY' }" if $page !~ /clade|genome|assembly/;
917 $href .= "&contig=$cookie->{ 'CONTIG' }" if $page !~ /clade|genome|assembly|contig/;
919 $txt = ": $cookie->{ uc $page }";
921 push @row, Maasha::XHTML::ln( txt => $page, href => $href, class => 'inline' );
922 push @row, Maasha::XHTML::p( txt => $txt, class => 'inline' );
925 push @html, Maasha::XHTML::table_beg( summary => "Taxonomy table", align => 'center', cellpadding => '5px' );
926 push @html, Maasha::XHTML::table_row_simple( tr => [ join( "\n", @row ) ], align => 'center' );
927 push @html, Maasha::XHTML::table_end;
929 return wantarray ? @html : \@html;
935 # Martin A. Hansen, March 2010.
937 # Returns a HTML section with clade selection choices
938 # for navigating the taxonomy tree.
940 my ( $cookie, # cookie hash
945 my ( @html, $clade, $href );
947 push @html, Maasha::XHTML::h2( txt => "Select clade", class => 'center' );
949 push @html, Maasha::XHTML::table_beg( summary => "Taxonomy select table", align => 'center', cellpadding => '5px' );
951 foreach $clade ( @{ $cookie->{ 'LIST_CLADE' } } )
953 $href = "$cookie->{ 'SCRIPT' }?page=genome";
954 $href .= "&session_id=$cookie->{ 'SESSION_ID' }";
955 $href .= "&user=$cookie->{ 'USER' }";
956 $href .= "&clade=$clade";
958 push @html, Maasha::XHTML::table_row_simple( tr => [ Maasha::XHTML::ln( txt => $clade, href => $href ) ] );
961 push @html, Maasha::XHTML::table_end;
963 return wantarray ? @html : \@html;
969 # Martin A. Hansen, March 2010.
971 # Returns a HTML section with genome selection choices
972 # for navigating the taxonomy tree.
974 my ( $cookie, # cookie hash
979 my ( @html, $genome, $href );
981 push @html, Maasha::XHTML::h2( txt => "Select genome", class => 'center' );
983 push @html, Maasha::XHTML::table_beg( summary => "Taxonomy select table", align => 'center', cellpadding => '5px' );
985 foreach $genome ( @{ $cookie->{ 'LIST_GENOME' } } )
987 $href = "$cookie->{ 'SCRIPT' }?page=assembly";
988 $href .= "&session_id=$cookie->{ 'SESSION_ID' }";
989 $href .= "&user=$cookie->{ 'USER' }";
990 $href .= "&clade=$cookie->{ 'CLADE' }";
991 $href .= "&genome=$genome";
993 push @html, Maasha::XHTML::table_row_simple( tr => [ Maasha::XHTML::ln( txt => $genome, href => $href ) ] );
996 push @html, Maasha::XHTML::table_end;
998 return wantarray ? @html : \@html;
1002 sub section_assembly
1004 # Martin A. Hansen, March 2010.
1006 # Returns a HTML section with assembly selection choices
1007 # for navigating the taxonomy tree.
1009 my ( $cookie, # cookie hash
1014 my ( @html, $assembly, $href );
1016 push @html, Maasha::XHTML::h2( txt => "Select assembly", class => 'center' );
1018 push @html, Maasha::XHTML::table_beg( summary => "Taxonomy select table", align => 'center', cellpadding => '5px' );
1020 foreach $assembly ( @{ $cookie->{ 'LIST_ASSEMBLY' } } )
1022 $href = "$cookie->{ 'SCRIPT' }?page=contig";
1023 $href .= "&session_id=$cookie->{ 'SESSION_ID' }";
1024 $href .= "&user=$cookie->{ 'USER' }";
1025 $href .= "&clade=$cookie->{ 'CLADE' }";
1026 $href .= "&genome=$cookie->{ 'GENOME' }";
1027 $href .= "&assembly=$assembly";
1029 push @html, Maasha::XHTML::table_row_simple( tr => [ Maasha::XHTML::ln( txt => $assembly, href => $href ) ] );
1032 push @html, Maasha::XHTML::table_end;
1034 return wantarray ? @html : \@html;
1040 # Martin A. Hansen, March 2010.
1042 # Returns a HTML section with contig selection choices
1043 # for navigating the taxonomy tree.
1045 my ( $cookie, # cookie hash
1050 my ( @html, $contig, $href );
1052 push @html, Maasha::XHTML::h2( txt => "Select contig", class => 'center' );
1054 push @html, Maasha::XHTML::table_beg( summary => "Taxonomy select table", align => 'center', cellpadding => '5px' );
1056 foreach $contig ( @{ $cookie->{ 'LIST_CONTIG' } } )
1058 $href = "$cookie->{ 'SCRIPT' }?page=browse";
1059 $href .= "&session_id=$cookie->{ 'SESSION_ID' }";
1060 $href .= "&user=$cookie->{ 'USER' }";
1061 $href .= "&clade=$cookie->{ 'CLADE' }";
1062 $href .= "&genome=$cookie->{ 'GENOME' }";
1063 $href .= "&assembly=$cookie->{ 'ASSEMBLY' }";
1064 $href .= "&contig=$contig";
1066 push @html, Maasha::XHTML::table_row_simple( tr => [ Maasha::XHTML::ln( txt => $contig, href => $href ) ] );
1069 push @html, Maasha::XHTML::table_end;
1071 return wantarray ? @html : \@html;
1075 sub section_navigate
1077 # Martin A. Hansen, November 2009.
1079 # Returns a HTML section for navigating in the browser window.
1081 my ( $cookie, # cookie hash
1086 my ( @html, $nav_val );
1088 $nav_val = Maasha::Calc::commify( $cookie->{ 'NAV_START' } ) . "-" . Maasha::Calc::commify( $cookie->{ 'NAV_END' } );
1090 push @html, Maasha::XHTML::table_beg( summary => "Navigation table", align => 'center' );
1091 push @html, Maasha::XHTML::table_row_simple( tr => [
1092 "Position or search term:",
1093 Maasha::XHTML::text( name => "nav_search", value => $nav_val, size => 30 ),
1094 Maasha::XHTML::submit( name => "nav_submit", value => "Submit" ),
1096 push @html, Maasha::XHTML::table_end;
1098 push @html, Maasha::XHTML::table_beg( summary => "Zoom table", align => 'center' );
1099 push @html, Maasha::XHTML::table_row_simple( tr => [
1100 Maasha::XHTML::p( txt => 'Move:' ),
1101 Maasha::XHTML::submit( name => "move_left3", value => "<<<", title => "move 95% to the left" ),
1102 Maasha::XHTML::submit( name => "move_left2", value => "<<", title => "move 47.5% to the left" ),
1103 Maasha::XHTML::submit( name => "move_left1", value => "<", title => "move 10% to the left" ),
1104 Maasha::XHTML::submit( name => "move_right1", value => ">", title => "move 10% to the rigth" ),
1105 Maasha::XHTML::submit( name => "move_right2", value => ">>", title => "move 47.5% to the rigth" ),
1106 Maasha::XHTML::submit( name => "move_right3", value => ">>>", title => "move 95% to the right" ),
1107 Maasha::XHTML::p( txt => 'Zoom in:' ),
1108 Maasha::XHTML::submit( name => "zoom_in1", value => "1.5x" ),
1109 Maasha::XHTML::submit( name => "zoom_in2", value => "3x" ),
1110 Maasha::XHTML::submit( name => "zoom_in3", value => "10x" ),
1111 Maasha::XHTML::p( txt => 'Zoom out:' ),
1112 Maasha::XHTML::submit( name => "zoom_out1", value => "1.5x" ),
1113 Maasha::XHTML::submit( name => "zoom_out2", value => "3x" ),
1114 Maasha::XHTML::submit( name => "zoom_out3", value => "10x" ),
1116 push @html, Maasha::XHTML::table_end;
1118 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "page", value => "browse" ) );
1119 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "user", value => $cookie->{ 'USER' } ) );
1120 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "clade", value => $cookie->{ 'CLADE' } ) );
1121 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "genome", value => $cookie->{ 'GENOME' } ) );
1122 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "assembly", value => $cookie->{ 'ASSEMBLY' } ) );
1123 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "contig", value => $cookie->{ 'CONTIG' } ) );
1125 return wantarray ? @html : \@html;
1131 # Martin A. Hansen, March 2010.
1133 # Returns a HTML section for a static link based on information in the cookie.
1135 my ( $cookie, # cookie hash
1140 my ( $link_out, $link_pdf, $link_svg, @html );
1142 $link_out = Maasha::XHTML::ln(
1144 href => join( "&", "$cookie->{ 'SCRIPT' }?page=browse",
1145 "clade=$cookie->{ 'CLADE' }",
1146 "genome=$cookie->{ 'GENOME' }",
1147 "assembly=$cookie->{ 'ASSEMBLY' }",
1148 "contig=$cookie->{ 'CONTIG' }",
1149 "nav_start=$cookie->{ 'NAV_START' }",
1150 "nav_end=$cookie->{ 'NAV_END' }",
1152 title => "Static link to this view",
1155 $link_pdf = Maasha::XHTML::ln(
1157 href => join( "&", "$cookie->{ 'SCRIPT' }?page=export_pdf",
1158 "session_id=$cookie->{ 'SESSION_ID' }",
1159 "user=$cookie->{ 'USER' }",
1160 "clade=$cookie->{ 'CLADE' }",
1161 "genome=$cookie->{ 'GENOME' }",
1162 "assembly=$cookie->{ 'ASSEMBLY' }",
1163 "contig=$cookie->{ 'CONTIG' }",
1164 "nav_start=$cookie->{ 'NAV_START' }",
1165 "nav_end=$cookie->{ 'NAV_END' }",
1167 title => "Export view in PDF",
1170 $link_svg = Maasha::XHTML::ln(
1172 href => join( "&", "$cookie->{ 'SCRIPT' }?page=export_svg",
1173 "session_id=$cookie->{ 'SESSION_ID' }",
1174 "user=$cookie->{ 'USER' }",
1175 "clade=$cookie->{ 'CLADE' }",
1176 "genome=$cookie->{ 'GENOME' }",
1177 "assembly=$cookie->{ 'ASSEMBLY' }",
1178 "contig=$cookie->{ 'CONTIG' }",
1179 "nav_start=$cookie->{ 'NAV_START' }",
1180 "nav_end=$cookie->{ 'NAV_END' }",
1182 title => "Export view in SVG",
1185 push @html, Maasha::XHTML::p( txt => "$link_out $link_pdf $link_svg", class => 'center' );
1187 return wantarray ? @html : \@html;
1198 my ( @track_list, $i, @tracks, $track, $elem, $png_data, @html, @img, $x1, $y1, $x2, $y2, $factor, $center );
1200 push @tracks, [ Maasha::BGB::Track::track_ruler( $cookie ) ];
1201 push @tracks, [ Maasha::BGB::Track::track_seq( $cookie ) ];
1203 @track_list = Maasha::BGB::Track::list_track_dir( $cookie->{ 'USER' }, $cookie->{ 'CLADE' }, $cookie->{ 'GENOME' }, $cookie->{ 'ASSEMBLY' }, $cookie->{ 'CONTIG' } );
1205 for ( $i = 0; $i < @track_list; $i++ )
1207 $cookie->{ 'FEAT_COLOR' } = Maasha::BGB::Draw::palette( $i );
1209 push @tracks, [ Maasha::BGB::Track::track_feature( $track_list[ $i ], $cookie ) ];
1212 unshift @tracks, [ Maasha::BGB::Track::track_grid( $cookie ) ];
1214 $png_data = Maasha::BGB::Draw::render_png( $cookie->{ 'IMG_WIDTH' }, $cookie->{ 'TRACK_OFFSET' }, \@tracks );
1216 push @img, Maasha::XHTML::img(
1217 src => "data:image/png;base64,$png_data",
1218 alt => "Browser Tracks",
1219 height => $cookie->{ 'TRACK_OFFSET' },
1220 width => $cookie->{ 'IMG_WIDTH' },
1221 id => "browser_map",
1222 usemap => "#browser_map"
1225 push @img, Maasha::XHTML::map_beg( name => "browser_map", id => "browser_map" );
1227 $factor = ( $cookie->{ 'NAV_END' } - $cookie->{ 'NAV_START' } + 1 ) / $cookie->{ 'IMG_WIDTH' };
1229 for ( $i = 0; $i < $cookie->{ 'IMG_WIDTH' }; $i += 5 )
1236 $center = int( $cookie->{ 'NAV_START' } + $factor * $i );
1238 push @img, Maasha::XHTML::area(
1239 href => join( "&", "$cookie->{ 'SCRIPT' }?page=browse",
1240 "session_id=$cookie->{ 'SESSION_ID' }",
1241 "user=$cookie->{ 'USER' }",
1242 "clade=$cookie->{ 'CLADE' }",
1243 "genome=$cookie->{ 'GENOME' }",
1244 "assembly=$cookie->{ 'ASSEMBLY' }",
1245 "contig=$cookie->{ 'CONTIG' }",
1246 "nav_start=$cookie->{ 'NAV_START' }",
1247 "nav_end=$cookie->{ 'NAV_END' }",
1248 "nav_center=$center",
1251 coords => "$x1, $y1, $x2, $y2",
1252 title => "Center on " . Maasha::Calc::commify( $center ),
1256 foreach $track ( @tracks )
1258 foreach $elem ( @{ $track } )
1260 next if $elem->{ 'type' } =~ /grid|text|wiggle/;
1262 if ( $elem->{ 'type' } eq 'track_name' )
1264 $x1 = $elem->{ 'x1' };
1265 $y1 = $elem->{ 'y1' } - 10;
1266 $x2 = $elem->{ 'x1' } + 6 * length $elem->{ 'txt' };
1267 $y2 = $elem->{ 'y1' };
1269 if ( Maasha::BGB::Track::track_hide( $cookie, $elem->{ 'track' } ) )
1271 push @img, Maasha::XHTML::area(
1272 href => join( "&", "$cookie->{ 'SCRIPT' }?page=browse",
1273 "session_id=$cookie->{ 'SESSION_ID' }",
1274 "user=$cookie->{ 'USER' }",
1275 "clade=$cookie->{ 'CLADE' }",
1276 "genome=$cookie->{ 'GENOME' }",
1277 "assembly=$cookie->{ 'ASSEMBLY' }",
1278 "contig=$cookie->{ 'CONTIG' }",
1279 "track=$elem->{ 'track' }",
1282 coords => "$x1, $y1, $x2, $y2",
1283 title => qq(Show track: $elem->{ 'txt' }),
1288 push @img, Maasha::XHTML::area(
1289 href => join( "&", "$cookie->{ 'SCRIPT' }?page=browse",
1290 "session_id=$cookie->{ 'SESSION_ID' }",
1291 "user=$cookie->{ 'USER' }",
1292 "clade=$cookie->{ 'CLADE' }",
1293 "genome=$cookie->{ 'GENOME' }",
1294 "assembly=$cookie->{ 'ASSEMBLY' }",
1295 "contig=$cookie->{ 'CONTIG' }",
1296 "track=$elem->{ 'track' }",
1299 coords => "$x1, $y1, $x2, $y2",
1300 title => qq(Hide track: $elem->{ 'txt' }),
1306 push @img, Maasha::XHTML::area(
1307 href => join( "&", "$cookie->{ 'SCRIPT' }?page=export",
1308 "session_id=$cookie->{ 'SESSION_ID' }",
1309 "user=$cookie->{ 'USER' }",
1310 "clade=$cookie->{ 'CLADE' }",
1311 "genome=$cookie->{ 'GENOME' }",
1312 "assembly=$cookie->{ 'ASSEMBLY' }",
1313 "contig=$cookie->{ 'CONTIG' }",
1314 "s_beg=$elem->{ 's_beg' }",
1315 "s_end=$elem->{ 's_end' }",
1316 "strand=$elem->{ 'strand' }",
1317 "q_id=$elem->{ 'q_id' }",
1320 coords => "$elem->{ x1 }, $elem->{ y1 }, $elem->{ x2 }, $elem->{ y2 }",
1321 title => "$elem->{ 'title' }",
1327 push @img, Maasha::XHTML::map_end();
1329 push @html, Maasha::XHTML::p( txt => join( "\n", @img ) );
1331 @html = Maasha::XHTML::div( txt => join( "\n", @html ), class => 'browse' );
1333 return wantarray ? @html : \@html;
1339 # Martin A. Hansen, November 2009.
1341 # Returns a HTML section with export table.
1343 my ( $cookie, # cookie hash
1348 my ( $feat, @row_dna_contig, @html );
1350 $feat = $cookie->{ 'Q_ID' } || "[no name]";
1352 push @row_dna_contig, Maasha::XHTML::p( txt => qq(Export Feature: "$feat" DNA from Contig: ), class => 'inline' );
1353 push @row_dna_contig, Maasha::XHTML::p( txt => "$cookie->{ 'CONTIG' } Start: ", class => 'inline' );
1354 push @row_dna_contig, Maasha::XHTML::text( name => "s_beg", value => Maasha::Calc::commify( $cookie->{ 'S_BEG' } ), size => 15 );
1355 push @row_dna_contig, Maasha::XHTML::p( txt => "End: ", class => 'inline' );
1356 push @row_dna_contig, Maasha::XHTML::text( name => "s_end", value => Maasha::Calc::commify( $cookie->{ 'S_END' } ), size => 15 );
1357 push @row_dna_contig, Maasha::XHTML::p( txt => "Strand: ", class => 'inline' );
1358 push @row_dna_contig, Maasha::XHTML::menu( name => "strand", options => [ qw( + - ) ], selected => $cookie->{ 'STRAND' } );
1359 push @row_dna_contig, Maasha::XHTML::submit( name => "export", value => "Export", title => "Fetch DNA from this region" );
1361 push @html, Maasha::XHTML::h2( txt => "Export", class => 'center' );
1362 push @html, Maasha::XHTML::table_beg( summary => "Taxonomy select table", align => 'center' );
1363 push @html, Maasha::XHTML::table_row_simple( tr => \@row_dna_contig );
1364 push @html, Maasha::XHTML::table_end;
1366 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "page", value => "dna" ) );
1367 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "user", value => $cookie->{ 'USER' } ) );
1368 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "clade", value => $cookie->{ 'CLADE' } ) );
1369 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "genome", value => $cookie->{ 'GENOME' } ) );
1370 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "assembly", value => $cookie->{ 'ASSEMBLY' } ) );
1371 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "contig", value => $cookie->{ 'CONTIG' } ) );
1373 return wantarray ? @html : \@html;
1377 sub section_export_pdf
1379 # Martin A. Hansen, March 2010.
1381 # Returns a HTML section with export table.
1383 my ( $cookie, # cookie hash
1388 my ( @tracks, @track_list, $i, $file, @html );
1390 push @tracks, [ Maasha::BGB::Track::track_ruler( $cookie ) ];
1391 push @tracks, [ Maasha::BGB::Track::track_seq( $cookie ) ];
1393 @track_list = Maasha::BGB::Track::list_track_dir( $cookie->{ 'USER' }, $cookie->{ 'CLADE' }, $cookie->{ 'GENOME' }, $cookie->{ 'ASSEMBLY' }, $cookie->{ 'CONTIG' } );
1395 for ( $i = 0; $i < @track_list; $i++ )
1397 $cookie->{ 'FEAT_COLOR' } = Maasha::BGB::Draw::palette( $i );
1399 push @tracks, [ Maasha::BGB::Track::track_feature( $track_list[ $i ], $cookie ) ];
1402 unshift @tracks, [ Maasha::BGB::Track::track_grid( $cookie ) ];
1404 $file = "$cookie->{ 'SESSION_DIR' }/$cookie->{ 'USER' }/BGB_export.pdf";
1406 Maasha::BGB::Draw::render_pdf_file( $file, $cookie->{ 'IMG_WIDTH' }, $cookie->{ 'TRACK_OFFSET' }, \@tracks );
1408 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::ln( txt => "BGB_export.pdf", href => $file ), class => 'center' );
1410 return wantarray ? @html : \@html;
1414 sub section_export_svg
1416 # Martin A. Hansen, March 2010.
1418 # Export view in SVG format.
1420 my ( $cookie, # cookie hash
1425 my ( @tracks, @track_list, $i, $file, @html );
1427 push @tracks, [ Maasha::BGB::Track::track_ruler( $cookie ) ];
1428 push @tracks, [ Maasha::BGB::Track::track_seq( $cookie ) ];
1430 @track_list = Maasha::BGB::Track::list_track_dir( $cookie->{ 'USER' }, $cookie->{ 'CLADE' }, $cookie->{ 'GENOME' }, $cookie->{ 'ASSEMBLY' }, $cookie->{ 'CONTIG' } );
1432 for ( $i = 0; $i < @track_list; $i++ )
1434 $cookie->{ 'FEAT_COLOR' } = Maasha::BGB::Draw::palette( $i );
1436 push @tracks, [ Maasha::BGB::Track::track_feature( $track_list[ $i ], $cookie ) ];
1439 unshift @tracks, [ Maasha::BGB::Track::track_grid( $cookie ) ];
1441 $file = "$cookie->{ 'SESSION_DIR' }/$cookie->{ 'USER' }/BGB_export.svg";
1443 Maasha::BGB::Draw::render_svg_file( $file, $cookie->{ 'IMG_WIDTH' }, $cookie->{ 'TRACK_OFFSET' }, \@tracks );
1445 push @html, Maasha::XHTML::p( txt => Maasha::XHTML::ln( txt => "BGB_export.svg", href => $file ), class => 'center' );
1447 return wantarray ? @html : \@html;
1453 # Martin A. Hansen, November 2009.
1455 # Returns a HTML section with export table.
1457 my ( $cookie, # cookie hash
1462 my ( $results, $result, $count, @html, $export, $browse );
1464 $results = Maasha::BGB::Track::search_tracks( $cookie );
1466 $count = scalar @{ $results };
1468 push @html, Maasha::XHTML::h2( txt => "Search", class => 'center' );
1469 push @html, Maasha::XHTML::p( txt => qq(Results for "$cookie->{ 'SEARCH' }": $count), class => 'center' );
1473 push @html, Maasha::XHTML::table_beg( summary => "Search table", align => 'center', cellpadding => '5px' );
1474 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) ] );
1476 foreach $result ( @{ $results } )
1478 $cookie->{ 'CONTIG' } = $result->{ 'S_ID' };
1479 $cookie->{ 'NAV_START' } = $result->{ 'S_BEG' };
1480 $cookie->{ 'NAV_END' } = $result->{ 'S_END' };
1481 $cookie->{ 'S_BEG' } = $result->{ 'S_BEG' };
1482 $cookie->{ 'S_END' } = $result->{ 'S_END' };
1483 $cookie->{ 'STRAND' } = $result->{ 'STRAND' };
1484 $cookie->{ 'Q_ID' } = $result->{ 'Q_ID' };
1486 $browse = Maasha::XHTML::ln(
1488 href => join( "&", "$cookie->{ 'SCRIPT' }?page=browse",
1489 "session_id=$cookie->{ 'SESSION_ID' }",
1490 "user=$cookie->{ 'USER' }",
1491 "clade=$cookie->{ 'CLADE' }",
1492 "genome=$cookie->{ 'GENOME' }",
1493 "assembly=$cookie->{ 'ASSEMBLY' }",
1494 "contig=$cookie->{ 'CONTIG' }",
1495 "nav_start=$cookie->{ 'NAV_START' }",
1496 "nav_end=$cookie->{ 'NAV_END' }",
1501 $export = Maasha::XHTML::ln(
1503 href => join( "&", "$cookie->{ 'SCRIPT' }?page=export",
1504 "session_id=$cookie->{ 'SESSION_ID' }",
1505 "user=$cookie->{ 'USER' }",
1506 "clade=$cookie->{ 'CLADE' }",
1507 "genome=$cookie->{ 'GENOME' }",
1508 "assembly=$cookie->{ 'ASSEMBLY' }",
1509 "contig=$cookie->{ 'CONTIG' }",
1510 "s_beg=$cookie->{ 'S_BEG' }",
1511 "s_end=$cookie->{ 'S_END' }",
1512 "strand=$cookie->{ 'STRAND' }",
1516 push @html, Maasha::XHTML::table_row_advanced(
1517 tr => [ { td => $result->{ 'S_ID' } },
1518 { td => $result->{ 'S_BEG' }, align => 'right' },
1519 { td => $result->{ 'S_END' }, align => 'right' },
1520 { td => $result->{ 'Q_ID' } },
1521 { td => $result->{ 'SCORE' }, align => 'right' },
1522 { td => $result->{ 'STRAND' } },
1523 { td => $result->{ 'HITS' }, align => 'right' },
1524 { td => $result->{ 'ALIGN' } },
1525 { td => $result->{ 'BLOCK_COUNT' }, align => 'right' },
1526 { td => $result->{ 'BLOCK_BEGS' } },
1527 { td => $result->{ 'BLOCK_LENS' } },
1528 { td => $result->{ 'BLOCK_TYPE' } },
1531 ], class => "monospace"
1535 push @html, Maasha::XHTML::table_end;
1538 return wantarray ? @html : \@html;
1544 # Martin A. Hansen, November 2009.
1546 # Returns a HTML section with extracted DNA.
1548 my ( $cookie, # cookie hash
1553 my ( @html, $beg, $end, $seq );
1555 $beg = $cookie->{ 'S_BEG' };
1556 $end = $cookie->{ 'S_END' };
1560 $seq = join ";", ">$cookie->{ 'GENOME' }", $cookie->{ 'ASSEMBLY' }, $cookie->{ 'CONTIG' }, $beg, $end, "$cookie->{ 'STRAND' }\n";
1561 $seq .= Maasha::BGB::Track::dna_get( $cookie );
1563 push @html, Maasha::XHTML::h2( txt => "DNA", class => 'center' );
1564 push @html, Maasha::XHTML::pre( txt => $seq );
1566 return wantarray ? @html : \@html;
1570 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<