]> git.donarmstrong.com Git - biopieces.git/blobdiff - www/cgi-bin/index.cgi
KISS browser working, but slow
[biopieces.git] / www / cgi-bin / index.cgi
index 15bb1de9e455e397b43061fd49e697849b4b6be1..1b327bc46eeb479037eed886f00e8d06fb08b797 100755 (executable)
@@ -54,18 +54,18 @@ $script = Maasha::Common::get_scriptname();
 push @html, Maasha::XHTML::html_header(
     cgi_header  => 1,
     title       => "KISS Genome Browser",
-#    css_file    => "test.css",
+    css_file    => "kiss.css",
     author      => "Martin A. Hansen, mail\@maasha.dk",
     description => "Biopieces bacterial genome browser - KISS",
     keywords    => [ qw( KISS Biopieces biopiece genome browser viewer bacterium bacteria prokaryote prokaryotes ) ],
     no_cache    => 1,
 );
 
-push @html, Maasha::XHTML::h1( txt => "KISS Genome Browser", class => "center" );
+push @html, Maasha::XHTML::h1( txt => "KISS Genome Browser", class => 'center' );
 push @html, Maasha::XHTML::form_beg( action => $script, method => "get", enctype => "multipart/form-data" );
 
 push @html, sec_navigate( $cgi );
-push @html, sec_browse( $dbh, $cgi->param( 'nav_start' ), $cgi->param( 'nav_end' ) );
+push @html, sec_browse( $dbh, $cgi );
 
 push @html, Maasha::XHTML::form_end;
 push @html, Maasha::XHTML::body_end;
@@ -101,7 +101,7 @@ sub sec_navigate
     $def_start     = nav_def_start( $cgi );
     $def_end       = nav_def_end( $cgi );
 
-    push @html, Maasha::XHTML::table_beg( summary => "Navigation table" );
+    push @html, Maasha::XHTML::table_beg( summary => "Navigation table", align => 'center' );
     push @html, Maasha::XHTML::table_row_simple( tr => [ qw( Clade Genome Assembly Contig Start End ) ], align => 'center' );
     push @html, Maasha::XHTML::table_row_simple( tr => [
         Maasha::XHTML::menu( name => "nav_clade",    options => $list_clade,    selected => $def_clade ),
@@ -114,7 +114,7 @@ sub sec_navigate
     ] );
     push @html, Maasha::XHTML::table_end;
 
-    push @html, Maasha::XHTML::table_beg( summary => "Zoom table" );
+    push @html, Maasha::XHTML::table_beg( summary => "Zoom table", align => 'center' );
     push @html, Maasha::XHTML::table_row_simple( tr => [
         Maasha::XHTML::p( txt => 'Move:' ),
         Maasha::XHTML::submit( name => "move_left3",  value => "<<<", title => "move 95% to the left" ),
@@ -134,22 +134,26 @@ sub sec_navigate
     ] );
     push @html, Maasha::XHTML::table_end;
 
+    @html = Maasha::XHTML::div( txt => join( "\n", @html ), class => 'navigate' );
+
     return wantarray ? @html : \@html;
 }
 
 
 sub sec_browse
 {
-    my ( $dbh,     # Database handle
-         $start,   # Browse start position
-         $end,     # Browse end position
+    my ( $dbh,   # Database handle
+         $cgi,   # CGI object
        ) = @_;
 
     # Returns a list.
 
-    my ( $t0, $t1, $ruler, $index, $index_beg, $index_len, $fh, $seq, $dna, $table, $entries, $features, $surface, $cr, $file, @html );
+    my ( $t0, $t1, @stats, $start, $end, $ruler, $index, $index_beg, $index_len, $fh, $seq, $dna, $table, $entries, $features, $surface, $cr, $file, @html, @img );
+
+    $start = $cgi->param( 'nav_start' );
+    $end   = $cgi->param( 'nav_end' );
 
-    $ruler = Maasha::KISS::Track::track_ruler( 1200, 25, $start, $end );
+    $ruler = Maasha::KISS::Track::track_ruler( 1200, 25, $start, $end, 10, 'black' );
 
     $index = Maasha::Fasta::index_retrieve( "$ENV{ 'BP_DATA' }/genomes/S_aur_COL/fasta/S_aur_COL.index" );
 
@@ -161,7 +165,7 @@ sub sec_browse
 
     close $fh;
 
-    $dna = Maasha::KISS::Track::track_seq( 1200, 50, $seq ) if length $seq <= 220;
+    $dna = Maasha::KISS::Track::track_seq( 1200, 50, $seq, 10, 'black' ) if length $seq <= 220;
 
     $table = 'Solexa';
 
@@ -169,9 +173,8 @@ sub sec_browse
     $entries = Maasha::KISS::IO::kiss_sql_get( $dbh, $table, $start, $end );
     $t1 = Time::HiRes::gettimeofday();
 
-    push @html, Maasha::XHTML::p( txt => "Feature count: " . Maasha::Calc::commify( scalar @$entries ) );
-
-    push @html, Maasha::XHTML::p( txt => "Time SQL: " . ( $t1 - $t0 ) );
+    push @stats, "Feature count: " . Maasha::Calc::commify( scalar @$entries );
+    push @stats, "Time SQL: " . sprintf( "%.4f", $t1 - $t0 );
 
     $t0 = Time::HiRes::gettimeofday();
 
@@ -188,7 +191,7 @@ sub sec_browse
     # push @html, Maasha::KISS::Draw::hdump( $entries );
     # push @html, Maasha::KISS::Draw::hdump( $features );
 
-    push @html, Maasha::XHTML::p( txt => "Time Track: " . ( $t1 - $t0 ) );
+    push @stats, "Time Track: " . sprintf( "%.4f", $t1 - $t0 );
 
     $file = "fisk.png";
 
@@ -197,18 +200,29 @@ sub sec_browse
 
     $t0 = Time::HiRes::gettimeofday();
 
-    Maasha::KISS::Draw::track_text( $cr, $ruler, "black" ) if $ruler;
-    Maasha::KISS::Draw::track_text( $cr, $dna, "black" )   if $dna;
-
-    Maasha::KISS::Draw::track_feature( $cr, $features, 'green' ) if $features;
+    Maasha::KISS::Draw::draw_feature( $cr, $ruler )    if $ruler;
+    Maasha::KISS::Draw::draw_feature( $cr, $dna )      if $dna;
+    Maasha::KISS::Draw::draw_feature( $cr, $features ) if $features;
 
     Maasha::KISS::Draw::file_png( $surface, $file );
 
     $t1 = Time::HiRes::gettimeofday();
 
-    push @html, Maasha::XHTML::p( txt => "Time Draw: " . ( $t1 - $t0 ) );
+    push @stats, "Time Draw: " . sprintf( "%.4f", $t1 - $t0 );
+
+    push @html, Maasha::XHTML::p( txt => join( " ", @stats ) );
+
+    push @img, Maasha::XHTML::img( src => $file, alt => "Browser Tracks", height => 800, width => 1200, id => "browser_map", usemap => "#browser_map" );
+
+    push @img, Maasha::XHTML::map_beg( name => "browser_map", id => "browser_map" );
+
+    map { push @img, Maasha::XHTML::area( href => "www.dmi.dk", shape => "rect", coords => "$_->{ x1 }, $_->{ y1 }, $_->{ x2 }, $_->{ y2 }", title => "$_->{ title }" ) } @{ $features };
+
+    push @img, Maasha::XHTML::map_beg();
+
+    push @html, Maasha::XHTML::p( txt => join( "\n", @img ) );
 
-    push @html, Maasha::XHTML::p( txt => Maasha::XHTML::img( src => $file, alt => "Browser Tracks", height => 800, width => 1200, class => "foo", id => "pix_id", usemap => "map"  ) );
+    @html = Maasha::XHTML::div( txt => join( "\n", @html ), class => 'browse' );
 
     return wantarray ? @html : \@html;
 }