+ push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "page", value => "dna" ) );
+ push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "user", value => $cookie->{ 'USER' } ) );
+ push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "clade", value => $cookie->{ 'CLADE' } ) );
+ push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "genome", value => $cookie->{ 'GENOME' } ) );
+ push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "assembly", value => $cookie->{ 'ASSEMBLY' } ) );
+ push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "contig", value => $cookie->{ 'CONTIG' } ) );
+
+ return wantarray ? @html : \@html;
+}
+
+
+sub section_export_pdf
+{
+ # Martin A. Hansen, March 2010.
+
+ # Returns a HTML section with export table.
+
+ my ( $cookie, # cookie hash
+ ) = @_;
+
+ # Returns a list.
+
+ my ( @tracks, @track_list, $i, $file, @html );
+
+ push @tracks, [ Maasha::BGB::Track::track_ruler( $cookie ) ];
+ push @tracks, [ Maasha::BGB::Track::track_seq( $cookie ) ];
+
+ @track_list = Maasha::BGB::Track::list_track_dir( $cookie->{ 'USER' }, $cookie->{ 'CLADE' }, $cookie->{ 'GENOME' }, $cookie->{ 'ASSEMBLY' }, $cookie->{ 'CONTIG' } );
+
+ for ( $i = 0; $i < @track_list; $i++ )
+ {
+ $cookie->{ 'FEAT_COLOR' } = Maasha::BGB::Draw::palette( $i );
+
+ push @tracks, [ Maasha::BGB::Track::track_feature( $track_list[ $i ], $cookie ) ];
+ }
+
+ unshift @tracks, [ Maasha::BGB::Track::track_grid( $cookie ) ];
+
+ $file = "$cookie->{ 'SESSION_DIR' }/$cookie->{ 'USER' }/BGB_export.pdf";
+
+ Maasha::BGB::Draw::render_pdf_file( $file, $cookie->{ 'IMG_WIDTH' }, $cookie->{ 'TRACK_OFFSET' }, \@tracks );
+
+ push @html, Maasha::XHTML::p( txt => Maasha::XHTML::ln( txt => "BGB_export.pdf", href => $file ), class => 'center' );
+
+ return wantarray ? @html : \@html;
+}
+
+
+sub section_export_svg
+{
+ # Martin A. Hansen, March 2010.
+
+ # Export view in SVG format.
+
+ my ( $cookie, # cookie hash
+ ) = @_;
+
+ # Returns a list.
+
+ my ( @tracks, @track_list, $i, $file, @html );
+
+ push @tracks, [ Maasha::BGB::Track::track_ruler( $cookie ) ];
+ push @tracks, [ Maasha::BGB::Track::track_seq( $cookie ) ];
+
+ @track_list = Maasha::BGB::Track::list_track_dir( $cookie->{ 'USER' }, $cookie->{ 'CLADE' }, $cookie->{ 'GENOME' }, $cookie->{ 'ASSEMBLY' }, $cookie->{ 'CONTIG' } );
+
+ for ( $i = 0; $i < @track_list; $i++ )
+ {
+ $cookie->{ 'FEAT_COLOR' } = Maasha::BGB::Draw::palette( $i );
+
+ push @tracks, [ Maasha::BGB::Track::track_feature( $track_list[ $i ], $cookie ) ];
+ }
+
+ unshift @tracks, [ Maasha::BGB::Track::track_grid( $cookie ) ];
+
+ $file = "$cookie->{ 'SESSION_DIR' }/$cookie->{ 'USER' }/BGB_export.svg";
+
+ Maasha::BGB::Draw::render_svg_file( $file, $cookie->{ 'IMG_WIDTH' }, $cookie->{ 'TRACK_OFFSET' }, \@tracks );
+
+ push @html, Maasha::XHTML::p( txt => Maasha::XHTML::ln( txt => "BGB_export.svg", href => $file ), class => 'center' );
+
+ return wantarray ? @html : \@html;
+}
+
+
+sub section_search
+{
+ # Martin A. Hansen, November 2009.
+
+ # Returns a HTML section with export table.
+
+ my ( $cookie, # cookie hash
+ ) = @_;
+
+ # Returns a list.
+
+ my ( $results, $result, $count, @html, $export, $browse );
+
+ $results = Maasha::BGB::Track::search_tracks( $cookie );
+
+ $count = scalar @{ $results };
+
+ push @html, Maasha::XHTML::h2( txt => "Search", class => 'center' );
+ push @html, Maasha::XHTML::p( txt => qq(Results for "$cookie->{ 'SEARCH' }": $count), class => 'center' );
+
+ if ( $count > 0 )
+ {
+ push @html, Maasha::XHTML::table_beg( summary => "Search table", align => 'center', cellpadding => '5px' );
+ 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) ] );
+
+ foreach $result ( @{ $results } )
+ {
+ $cookie->{ 'CONTIG' } = $result->{ 'S_ID' };
+ $cookie->{ 'NAV_START' } = $result->{ 'S_BEG' };
+ $cookie->{ 'NAV_END' } = $result->{ 'S_END' };
+ $cookie->{ 'S_BEG' } = $result->{ 'S_BEG' };
+ $cookie->{ 'S_END' } = $result->{ 'S_END' };
+ $cookie->{ 'STRAND' } = $result->{ 'STRAND' };
+ $cookie->{ 'Q_ID' } = $result->{ 'Q_ID' };
+
+ $browse = Maasha::XHTML::ln(
+ txt => "browse",
+ href => join( "&", "$cookie->{ 'SCRIPT' }?page=browse",
+ "session_id=$cookie->{ 'SESSION_ID' }",
+ "user=$cookie->{ 'USER' }",
+ "clade=$cookie->{ 'CLADE' }",
+ "genome=$cookie->{ 'GENOME' }",
+ "assembly=$cookie->{ 'ASSEMBLY' }",
+ "contig=$cookie->{ 'CONTIG' }",
+ "nav_start=$cookie->{ 'NAV_START' }",
+ "nav_end=$cookie->{ 'NAV_END' }",
+ ),
+ );
+
+
+ $export = Maasha::XHTML::ln(
+ txt => "export",
+ href => join( "&", "$cookie->{ 'SCRIPT' }?page=export",
+ "session_id=$cookie->{ 'SESSION_ID' }",
+ "user=$cookie->{ 'USER' }",
+ "clade=$cookie->{ 'CLADE' }",
+ "genome=$cookie->{ 'GENOME' }",
+ "assembly=$cookie->{ 'ASSEMBLY' }",
+ "contig=$cookie->{ 'CONTIG' }",
+ "s_beg=$cookie->{ 'S_BEG' }",
+ "s_end=$cookie->{ 'S_END' }",
+ "strand=$cookie->{ 'STRAND' }",
+ ),
+ );
+
+ push @html, Maasha::XHTML::table_row_advanced(
+ tr => [ { td => $result->{ 'S_ID' } },
+ { td => $result->{ 'S_BEG' }, align => 'right' },
+ { td => $result->{ 'S_END' }, align => 'right' },
+ { td => $result->{ 'Q_ID' } },
+ { td => $result->{ 'SCORE' }, align => 'right' },
+ { td => $result->{ 'STRAND' } },
+ { td => $result->{ 'HITS' }, align => 'right' },
+ { td => $result->{ 'ALIGN' } },
+ { td => $result->{ 'BLOCK_COUNT' }, align => 'right' },
+ { td => $result->{ 'BLOCK_BEGS' } },
+ { td => $result->{ 'BLOCK_LENS' } },
+ { td => $result->{ 'BLOCK_TYPE' } },
+ { td => $browse },
+ { td => $export },
+ ], class => "monospace"
+ );
+ }
+
+ push @html, Maasha::XHTML::table_end;
+ }
+
+ return wantarray ? @html : \@html;
+}
+
+
+sub section_dna
+{
+ # Martin A. Hansen, November 2009.
+
+ # Returns a HTML section with extracted DNA.
+
+ my ( $cookie, # cookie hash
+ ) = @_;
+
+ # Returns a list.
+
+ my ( @html, $beg, $end, $seq );
+
+ $beg = $cookie->{ 'S_BEG' };
+ $end = $cookie->{ 'S_END' };
+ $beg =~ tr/,//d;
+ $end =~ tr/,//d;
+
+ $seq = join ";", ">$cookie->{ 'GENOME' }", $cookie->{ 'ASSEMBLY' }, $cookie->{ 'CONTIG' }, $beg, $end, "$cookie->{ 'STRAND' }\n";
+ $seq .= Maasha::BGB::Track::dna_get( $cookie );
+
+ push @html, Maasha::XHTML::h2( txt => "DNA", class => 'center' );
+ push @html, Maasha::XHTML::pre( txt => $seq );