]> git.donarmstrong.com Git - biopieces.git/blobdiff - www/index.cgi
cleaned up BGB track code
[biopieces.git] / www / index.cgi
index 1fc10db23b37336386438d198a49f28a21534f8c..3ccd79b04fc951c098a4fc3cf2c795e06df6c99a 100755 (executable)
@@ -26,13 +26,13 @@ use warnings;
 use lib $ENV{ 'BP_PERL' };
 
 use CGI;
+use URI::Escape;
 use Data::Dumper;
 use Digest::MD5;
 use Maasha::Common;
 use Maasha::Filesys;
 use Maasha::Calc;
 use Maasha::XHTML;
-use Maasha::KISS;
 use Maasha::BGB::Session;
 use Maasha::BGB::Track;
 use Maasha::BGB::Draw;
@@ -44,10 +44,10 @@ $cookie = cookie_default( $cgi );;
 
 push @html, Maasha::XHTML::html_header(
     cgi_header  => 1,
-    title       => "Biopieces Genome Browser",
-    css_file    => "bgb.css",
-    author      => "Martin A. Hansen, mail\@maasha.dk",
-    description => "Biopieces Genome Browser",
+    title       => 'Biopieces Genome Browser',
+    css_file    => 'bgb.css',
+    author      => 'Martin A. Hansen, mail@maasha.dk',
+    description => 'Biopieces Genome Browser',
     keywords    => [ qw( Biopieces biopiece genome browser viewer bacterium bacteria prokaryote prokaryotes ) ],
     no_cache    => 1,
 );
@@ -85,7 +85,7 @@ sub cookie_default
 
     # Returns a hash.
 
-    my ( $cookie, $path );
+    my ( $cookie );
 
     $cookie = {};
 
@@ -109,7 +109,7 @@ sub cookie_default
     $cookie->{ 'SESSION_DIR' }     = "Sessions";
     $cookie->{ 'LIST_PAGES' }      = [ qw( clade genome assembly contig browse ) ];
 
-    $cookie->{ 'USER' }            = $cgi->param( 'user' );
+    $cookie->{ 'USER' }            = $cgi->param( 'user' ) || '';
     $cookie->{ 'PASSWORD' }        = $cgi->param( 'password' );
     $cookie->{ 'SESSION_ID' }      = $cgi->param( 'session_id' );
 
@@ -122,6 +122,9 @@ sub cookie_default
     $cookie->{ 'ASSEMBLY' }        = $cgi->param( 'assembly' ) || '';
     $cookie->{ 'CONTIG' }          = $cgi->param( 'contig' )   || '';
     $cookie->{ 'Q_ID' }            = $cgi->param( 'q_id' );
+    $cookie->{ 'NAV_START' }     ||= $cgi->param( 'nav_start' );
+    $cookie->{ 'NAV_END' }       ||= $cgi->param( 'nav_end' );
+    $cookie->{ 'NAV_CENTER' }      = $cgi->param( 'nav_center' );
     $cookie->{ 'S_BEG' }           = $cgi->param( 's_beg' );
     $cookie->{ 'S_END' }           = $cgi->param( 's_end' );
     $cookie->{ 'STRAND' }          = $cgi->param( 'strand' );
@@ -150,25 +153,11 @@ sub cookie_default
     $cookie->{ 'FEAT_COLOR' }      = [ 0, 0, 0 ];
     $cookie->{ 'FEAT_MAX' }        = 5000;
 
-    $path = "$cookie->{ 'DATA_DIR' }/Users";
-
-    $cookie->{ 'LIST_USER' }       = Maasha::Filesys::ls_dirs_base( $path ) if -d $path;
-
-    $path .= "/$cookie->{ 'USER' }";
-
-    $cookie->{ 'LIST_CLADE' }      = Maasha::Filesys::ls_dirs_base( $path ) if -d $path;
-
-    $path .= "/$cookie->{ 'CLADE' }";
-
-    $cookie->{ 'LIST_GENOME' }     = Maasha::Filesys::ls_dirs_base( $path ) if -d $path;
-
-    $path .= "/$cookie->{ 'GENOME' }";
-
-    $cookie->{ 'LIST_ASSEMBLY' }   = Maasha::Filesys::ls_dirs_base( $path ) if -d $path;
-
-    $path .= "/$cookie->{ 'ASSEMBLY' }";
-
-    $cookie->{ 'LIST_CONTIG' }     = Maasha::Filesys::ls_dirs_base( $path ) if -d $path;
+    $cookie->{ 'LIST_USER' }       = Maasha::BGB::Track::list_users();
+    $cookie->{ 'LIST_CLADE' }      = Maasha::BGB::Track::list_clades(     $cookie->{ 'USER' } );
+    $cookie->{ 'LIST_GENOME' }     = Maasha::BGB::Track::list_genomes(    $cookie->{ 'USER' }, $cookie->{ 'CLADE' } );
+    $cookie->{ 'LIST_ASSEMBLY' }   = Maasha::BGB::Track::list_assemblies( $cookie->{ 'USER' }, $cookie->{ 'CLADE' }, $cookie->{ 'GENOME' } );
+    $cookie->{ 'LIST_CONTIG' }     = Maasha::BGB::Track::list_contigs(    $cookie->{ 'USER' }, $cookie->{ 'CLADE' }, $cookie->{ 'GENOME' }, $cookie->{ 'ASSEMBLY' } );
 
     if ( $cookie->{ 'CONTIG' } )
     {
@@ -176,6 +165,7 @@ sub cookie_default
         cookie_end( $cookie );
         cookie_zoom( $cookie );
         cookie_move( $cookie );
+        cookie_center( $cookie );
     }
 
     $cookie->{ 'STRAND' } = '+' if defined $cookie->{ 'STRAND' } and $cookie->{ 'STRAND' } eq ' ';   # FIXME ugly HTML fix
@@ -199,10 +189,35 @@ sub cookie_session
 
     $session = Maasha::BGB::Session::session_restore( "$cookie->{ 'SESSION_DIR' }/sessions.txt" );
 
-    $cookie->{ 'PAGE' } = 'login' if not $cookie->{ 'SESSION_ID' };
-    $cookie->{ 'PAGE' } = 'login' if $cookie->{ 'SESSION_ID' } ne $ENV{ 'SSL_SESSION_ID' };
-    $cookie->{ 'PAGE' } = 'login' if not exists $session->{ $cookie->{ 'USER' } };
-    $cookie->{ 'PAGE' } = 'login' if $session->{ $cookie->{ 'USER' } }->{ 'SESSION_ID' } ne $cookie->{ 'SESSION_ID' };
+    # if ( $cookie->{ 'SESSION_ID' } )
+    # {
+    #     if ( $cookie->{ 'SESSION_ID' } ne $ENV{ 'SSL_SESSION_ID' } ) {
+    #         $cookie->{ 'PAGE' } = 'login';
+    #         print STDERR "HER1"; # DEBUG
+    #     }
+    # }
+    # else
+    # {
+    #     $cookie->{ 'PAGE' } = 'login';
+    # 
+    #     print STDERR "HER2"; # DEBUG
+    # }
+
+    if ( exists $session->{ $cookie->{ 'USER' } } and $cookie->{ 'SESSION_ID' } )
+    {
+        if ( $session->{ $cookie->{ 'USER' } }->{ 'SESSION_ID' } ne $cookie->{ 'SESSION_ID' } ) {
+            $cookie->{ 'PAGE' } = 'login';
+            print STDERR "HER3"; # DEBUG
+        }
+    }
+    else
+    {
+        $cookie->{ 'PAGE' } = 'login';
+        print STDERR "HER4"; # DEBUG
+        print STDERR "NO COOKIE SESSION ID\n" if not $cookie->{ 'SESSION_ID' }; # DEBUG
+        print STDERR "NO COOKIE USER\n" if not $cookie->{ 'USER' }; # DEBUG
+        print STDERR "NO SESSION USER\n"      if not exists $session->{ $cookie->{ 'USER' } }; # DEBUG
+    }
 }
 
 
@@ -220,20 +235,19 @@ sub cookie_login
 
     my ( $session );
 
-    $session = Maasha::BGB::Session::session_restore( "$cookie->{ 'SESSION_DIR' }/sessions.txt" );
-    
     if ( $cookie->{ 'USER' } and $cookie->{ 'PASSWORD' } )
     {
+        $session = Maasha::BGB::Session::session_restore( "$cookie->{ 'SESSION_DIR' }/sessions.txt" );
+    
         if ( exists $session->{ $cookie->{ 'USER' } } and
              $session->{ $cookie->{ 'USER' } }->{ 'PASSWORD' } eq Digest::MD5::md5_hex( $cookie->{ 'PASSWORD' } ) )
         {
-            $session->{ $cookie->{ 'USER' } }->{ 'SESSION_ID' } ||= Maasha::BGB::Session::session_new();
-            $session->{ $cookie->{ 'USER' } }->{ 'SESSION_ID' }   = $ENV{ 'SSL_SESSION_ID' };
+            $session->{ $cookie->{ 'USER' } }->{ 'SESSION_ID' } ||= Maasha::BGB::Session::session_new();
+            $session->{ $cookie->{ 'USER' } }->{ 'SESSION_ID' }   = $ENV{ 'SSL_SESSION_ID' };
             $session->{ $cookie->{ 'USER' } }->{ 'TIME' }         = Maasha::Common::time_stamp();
 
             $cookie->{ 'SESSION_ID' } = $session->{ $cookie->{ 'USER' } }->{ 'SESSION_ID' };
             $cookie->{ 'LOGIN' }      = "OK";
-            $cookie->{ 'USER' }       = $cookie->{ 'USER' };
             $cookie->{ 'PAGE' }       = 'clade'; 
 
             Maasha::BGB::Session::session_store( "$cookie->{ 'SESSION_DIR' }/sessions.txt", $session );
@@ -354,6 +368,8 @@ sub cookie_move
     my ( $cookie,   # cookie hash
        ) = @_;
 
+    # Returns nothing.
+    
     my ( $max, $dist, $shift, $new_start, $new_end );
 
     $max = Maasha::Filesys::file_size( Maasha::BGB::Track::path_seq( $cookie ) );
@@ -388,53 +404,31 @@ sub cookie_move
 }
 
 
-sub cookie_href
+sub cookie_center
 {
-    # Martin A. Hansen, November 2009.
-
-    # Returns the href for a taxonomy path terminated at a given
-    # page using information stored in a cookie.
+    # Martin A. Hansen, March 2010
+   
+    # Adjust the cookie values for NAV_START and NAV_END based
+    # on cookie CENTER value if defined.
 
     my ( $cookie,   # cookie hash
-         $page,     # page
        ) = @_;
 
-    # Returns a string.
-
-    my ( @href_list, %href_hash, $href );
+    # Returns nothing.
 
-    $href_hash{ "user" } = $cookie->{ 'USER' } if $cookie->{ 'USER' };
+    my ( $l_dist, $r_dist );
 
-    while ( 1 )
+    if ( defined $cookie->{ 'NAV_CENTER' } )
     {
-        $href_hash{ "clade" } = $cookie->{ 'CLADE' }        if $cookie->{ 'CLADE' };
-        last if $page eq 'clade';
-        $href_hash{ "genome" } = $cookie->{ 'GENOME' }      if $cookie->{ 'GENOME' };
-        last if $page eq 'genome';
-        $href_hash{ "assembly" } = $cookie->{ 'ASSEMBLY' }  if $cookie->{ 'ASSEMBLY' };
-        last if $page eq 'assembly';
-        $href_hash{ "contig" } = $cookie->{ 'CONTIG' }      if $cookie->{ 'CONTIG' };
-        last if $page eq 'contig';
-        last;
-    }
+        $l_dist = $cookie->{ 'NAV_CENTER' } - $cookie->{ 'NAV_START' };
+        $r_dist = $cookie->{ 'NAV_END' } - $cookie->{ 'NAV_CENTER' };
 
-    if ( defined $cookie->{ 'NAV_START' } and defined $cookie->{ 'NAV_END' } ) {
-        $href_hash{ "nav_search" } = "$cookie->{ 'NAV_START' }-$cookie->{ 'NAV_END' }";
-    }
-
-    $href_hash{ "s_beg" }      = $cookie->{ 'S_BEG' }      if defined $cookie->{ 'S_BEG' };
-    $href_hash{ "s_end" }      = $cookie->{ 'S_END' }      if defined $cookie->{ 'S_END' };
-    $href_hash{ "q_id" }       = $cookie->{ 'Q_ID' }       if defined $cookie->{ 'Q_ID' };
-    $href_hash{ "strand" }     = $cookie->{ 'STRAND' }     if defined $cookie->{ 'STRAND' };
-    $href_hash{ "session_id" } = $cookie->{ 'SESSION_ID' } if defined $cookie->{ 'SESSION_ID' };
-
-    push @href_list, "$cookie->{ 'SCRIPT' }?page=$page";
-
-    foreach $href ( keys %href_hash ) {
-        push @href_list, "$href=$href_hash{ $href }";
+        if ( $l_dist > $r_dist ) {
+            $cookie->{ 'NAV_START' } = $cookie->{ 'NAV_END' } - 2 * $r_dist;
+        } else {
+            $cookie->{ 'NAV_END' } = $cookie->{ 'NAV_START' } + 2 * $l_dist;
+        }
     }
-
-    return join "&", @href_list;
 }
 
 
@@ -476,6 +470,10 @@ sub page
 
     my ( @html );
 
+    if ( $cookie->{ 'SESSION_ID' } ) {
+        push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "session_id", value => $cookie->{ 'SESSION_ID' } ) );
+    }
+
     if ( $cookie->{ 'PAGE' } eq 'login' ) {
         push @html, page_login( $cookie );
     } elsif ( $cookie->{ 'PAGE' } eq 'search' ) {
@@ -490,8 +488,6 @@ sub page
         push @html, page_taxonomy( $cookie );
     }
 
-    push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "session_id", value => "$cookie->{ 'SESSION_ID' }" ) );
-
     return wantarray ? @html : \@html;
 }
 
@@ -671,7 +667,13 @@ sub section_taxonomy_table
     {
         last if $page eq $cookie->{ 'PAGE' } or $page eq 'browse';
 
-        $href = cookie_href( $cookie, $page );
+        $href  = "$cookie->{ 'SCRIPT' }?page=$page";
+        $href .= "&session_id=$cookie->{ 'SESSION_ID' }";
+        $href .= "&user=$cookie->{ 'USER' }";
+        $href .= "&clade=$cookie->{ 'CLADE' }"       if $page !~ /clade/;
+        $href .= "&genome=$cookie->{ 'GENOME' }"     if $page !~ /clade|genome/;
+        $href .= "&assembly=$cookie->{ 'ASSEMBLY' }" if $page !~ /clade|genome|assembly/;
+        $href .= "&contig=$cookie->{ 'CONTIG' }"     if $page !~ /clade|genome|assembly|contig/;
 
         $txt = ": $cookie->{ uc $page }";
 
@@ -711,7 +713,13 @@ sub section_taxonomy_select
     {
         $cookie->{ uc $cookie->{ 'PAGE' } } = $item;
 
-        $href = cookie_href( $cookie, cookie_page_next( $cookie ) );
+        $href  = "$cookie->{ 'SCRIPT' }?page=" . cookie_page_next( $cookie );
+        $href .= "&session_id=$cookie->{ 'SESSION_ID' }";
+        $href .= "&user=$cookie->{ 'USER' }";
+        $href .= "&clade=$cookie->{ 'CLADE' }";
+        $href .= "&genome=$cookie->{ 'GENOME' }"     if $cookie->{ 'GENOME' };
+        $href .= "&assembly=$cookie->{ 'ASSEMBLY' }" if $cookie->{ 'ASSEMBLY' };
+        $href .= "&contig=$cookie->{ 'CONTIG' }"     if $cookie->{ 'CONTIG' };
 
         push @html, Maasha::XHTML::table_row_simple( tr => [ Maasha::XHTML::ln( txt => $item, href => $href ) ] );
     }
@@ -766,11 +774,11 @@ sub section_navigate
     push @html, Maasha::XHTML::table_end;
 
     push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "page",     value => "browse" ) );
-    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' }" ) );
+    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;
 }
@@ -783,7 +791,7 @@ sub section_browse
 
     # Returns a list.
 
-    my ( @tracks, $i, @features, $feat, $elem, $surface, $cr, $png_data, @html, @img );
+    my ( @tracks, $i, @features, $feat, $elem, $surface, $cr, $png_data, @html, @img, $x1, $y1, $x2, $y2, $factor, $center );
 
     push @features, [ Maasha::BGB::Track::track_ruler( $cookie ) ];
     push @features, [ Maasha::BGB::Track::track_seq( $cookie ) ];
@@ -821,11 +829,41 @@ sub section_browse
 
     push @img, Maasha::XHTML::map_beg( name => "browser_map", id => "browser_map" );
 
+    $factor = ( $cookie->{ 'NAV_END' } - $cookie->{ 'NAV_START' } + 1 ) / $cookie->{ 'IMG_WIDTH' };
+
+    for ( $i = 0; $i < $cookie->{ 'IMG_WIDTH' }; $i += 5 )
+    {
+        $x1 = $i;
+        $y1 = 10;
+        $x2 = $i + 5;
+        $y2 = 20;
+
+        $center = int( $cookie->{ 'NAV_START' } + $factor * $i );
+
+        push @img, Maasha::XHTML::area(
+            href     => join( "&", "$cookie->{ 'SCRIPT' }?page=browse",
+                                   "session_id=$cookie->{ 'SESSION_ID' }",
+                                   "user=$cookie->{ 'USER' }",
+                                   "clade=$cookie->{ 'CLADE' }",
+                                   "genome=$cookie->{ 'GENOME' }",
+                                   "contig=$cookie->{ 'CONTIG' }",
+                                   "assembly=$cookie->{ 'ASSEMBLY' }",
+                                   "nav_start=$cookie->{ 'NAV_START' }",
+                                   "nav_end=$cookie->{ 'NAV_END' }",
+                                   "nav_center=$center",
+                      ),
+            shape  => 'rect',
+            coords => "$x1, $y1, $x2, $y2",
+            title  => "Center on " . Maasha::Calc::commify( $center ),
+        );
+    }
+
     foreach $feat ( @features )
     {
         foreach $elem ( @{ $feat } )
         {
             next if $elem->{ 'type' } eq 'text';
+            next if $elem->{ 'type' } eq 'wiggle';
 
             #$elem->{ 'strand' } = '&#43' if $elem->{ 'strand' } eq '+';
 
@@ -835,10 +873,20 @@ sub section_browse
             $cookie->{ 'STRAND' } = $elem->{ 'strand' };
 
             push @img, Maasha::XHTML::area(
-                href   => cookie_href( $cookie, "export" ),
-                # href   => cookie_href( $cookie, "export" ) . "&q_id=$elem->{ 'q_id' }&s_beg=$elem->{ 's_beg' }&s_end=$elem->{ 's_end' }&strand=$elem->{ 'strand' }",
-                shape  => "rect",
-                coords => "$elem->{ x1 }, $elem->{ y1 }, $elem->{ x2 }, $elem->{ y2 }", title => "$elem->{ 'title' }",
+                href     => join( "&", "$cookie->{ 'SCRIPT' }?page=export",
+                                       "session_id=$cookie->{ 'SESSION_ID' }",
+                                       "user=$cookie->{ 'USER' }",
+                                       "clade=$cookie->{ 'CLADE' }",
+                                       "genome=$cookie->{ 'GENOME' }",
+                                       "contig=$cookie->{ 'CONTIG' }",
+                                       "assembly=$cookie->{ 'ASSEMBLY' }",
+                                       "s_beg=$cookie->{ 'S_BEG' }",
+                                       "s_end=$cookie->{ 'S_END' }",
+                                       "strand=$cookie->{ 'STRAND' }",
+                          ),
+                shape  => 'rect',
+                coords => "$elem->{ x1 }, $elem->{ y1 }, $elem->{ x2 }, $elem->{ y2 }",
+                title  => "$elem->{ 'title' }",
             );
         }
     }
@@ -880,12 +928,12 @@ sub section_export
     push @html, Maasha::XHTML::table_row_simple( tr => \@row_dna_contig );
     push @html, Maasha::XHTML::table_end;
 
-    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' }" ) );
+    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;
 }
@@ -926,8 +974,35 @@ sub section_search
             $cookie->{ 'STRAND' }    = $result->{ 'STRAND' };
             $cookie->{ 'Q_ID' }      = $result->{ 'Q_ID' };
 
-            $browse = Maasha::XHTML::ln( txt => "browse", href => cookie_href( $cookie, "browse" ) );
-            $export = Maasha::XHTML::ln( txt => "export", href => cookie_href( $cookie, "export" ) );
+            $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' }",
+                                   "contig=$cookie->{ 'CONTIG' }",
+                                   "assembly=$cookie->{ 'ASSEMBLY' }",
+                                   "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' }",
+                                   "contig=$cookie->{ 'CONTIG' }",
+                                   "assembly=$cookie->{ 'ASSEMBLY' }",
+                                   "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' } },
@@ -973,7 +1048,7 @@ sub section_dna
     $beg =~ tr/,//d;
     $end =~ tr/,//d;
 
-    $seq = ">$cookie->{ 'CONTIG' }_$beg" . "_$end" . "_$cookie->{ 'STRAND' }\n";
+    $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' );