use Maasha::Calc;
use Maasha::XHTML;
use Maasha::KISS;
-use Maasha::BBrowser::Session;
-use Maasha::BBrowser::Track;
-use Maasha::BBrowser::Draw;
+use Maasha::BGB::Session;
+use Maasha::BGB::Track;
+use Maasha::BGB::Draw;
my ( $cgi, $cookie, @html );
$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' );
$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->{ 'S_BEG' } = $cgi->param( 's_beg' );
$cookie->{ 'S_END' } = $cgi->param( 's_end' );
$cookie->{ 'STRAND' } = $cgi->param( 'strand' );
my ( $session );
- $session = Maasha::BBrowser::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' };
+ $session = Maasha::BGB::Session::session_restore( "$cookie->{ 'SESSION_DIR' }/sessions.txt" );
+
+ # 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 SESSION ID\n" if not $cookie->{ 'USER' }; # DEBUG
+ print STDERR "NO SESSION USER\n" if not exists $session->{ $cookie->{ 'USER' } }; # DEBUG
+ }
}
my ( $session );
- $session = Maasha::BBrowser::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::BBrowser::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::BBrowser::Session::session_store( "$cookie->{ 'SESSION_DIR' }/sessions.txt", $session );
+ Maasha::BGB::Session::session_store( "$cookie->{ 'SESSION_DIR' }/sessions.txt", $session );
}
else
{
my ( $max );
- $max = Maasha::Filesys::file_size( Maasha::BBrowser::Track::path_seq( $cookie ) );
+ $max = Maasha::Filesys::file_size( Maasha::BGB::Track::path_seq( $cookie ) );
if ( defined $cookie->{ 'NAV_END' } )
{
my ( $max, $dist, $new_dist, $dist_diff );
- $max = Maasha::Filesys::file_size( Maasha::BBrowser::Track::path_seq( $cookie ) );
+ $max = Maasha::Filesys::file_size( Maasha::BGB::Track::path_seq( $cookie ) );
$dist = $cookie->{ 'NAV_END' } - $cookie->{ 'NAV_START' };
my ( $max, $dist, $shift, $new_start, $new_end );
- $max = Maasha::Filesys::file_size( Maasha::BBrowser::Track::path_seq( $cookie ) );
+ $max = Maasha::Filesys::file_size( Maasha::BGB::Track::path_seq( $cookie ) );
$dist = $cookie->{ 'NAV_END' } - $cookie->{ 'NAV_START' };
last;
}
- if ( defined $cookie->{ 'NAV_START' } and defined $cookie->{ 'NAV_END' } ) {
+ if ( defined $cookie->{ 'NAV_START' } and defined $cookie->{ 'NAV_END' } and $page !~ /clade|genome|assembly|contig|browse/ ) {
$href_hash{ "nav_search" } = "$cookie->{ 'NAV_START' }-$cookie->{ 'NAV_END' }";
}
push @html, page_taxonomy( $cookie );
}
- push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "session_id", value => "$cookie->{ 'SESSION_ID' }" ) );
+ if ( $cookie->{ 'SESSION_ID' } ) {
+ push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "session_id", value => "$cookie->{ 'SESSION_ID' }" ) );
+ }
return wantarray ? @html : \@html;
}
push @html, section_taxonomy_table( $cookie );
push @html, section_navigate( $cookie );
push @html, section_browse( $cookie );
+ push @html, section_permalink( $cookie );
return wantarray ? @html : \@html;
}
my ( @tracks, $i, @features, $feat, $elem, $surface, $cr, $png_data, @html, @img );
- push @features, [ Maasha::BBrowser::Track::track_ruler( $cookie ) ];
- push @features, [ Maasha::BBrowser::Track::track_seq( $cookie ) ];
+ push @features, [ Maasha::BGB::Track::track_ruler( $cookie ) ];
+ push @features, [ Maasha::BGB::Track::track_seq( $cookie ) ];
- @tracks = Maasha::BBrowser::Track::path_tracks( $cookie );
+ @tracks = Maasha::BGB::Track::path_tracks( $cookie );
for ( $i = 0; $i < @tracks; $i++ )
{
- $cookie->{ 'FEAT_COLOR' } = Maasha::BBrowser::Draw::palette( $i );
+ $cookie->{ 'FEAT_COLOR' } = Maasha::BGB::Draw::palette( $i );
- push @features, [ Maasha::BBrowser::Track::track_feature( $tracks[ $i ], $cookie ) ];
+ push @features, [ Maasha::BGB::Track::track_feature( $tracks[ $i ], $cookie ) ];
}
$surface = Cairo::ImageSurface->create( 'argb32', $cookie->{ 'IMG_WIDTH' }, $cookie->{ 'TRACK_OFFSET' } );
$cr->fill;
foreach $feat ( @features ) {
- Maasha::BBrowser::Draw::draw_feature( $cr, $feat ) if $feat;
+ Maasha::BGB::Draw::draw_feature( $cr, $feat ) if $feat;
}
- $png_data = Maasha::BBrowser::Draw::base64_png( $surface );
+ $png_data = Maasha::BGB::Draw::base64_png( $surface );
push @img, Maasha::XHTML::img(
src => "data:image/png;base64,$png_data",
}
+sub section_permalink
+{
+ # Martin A. Hansen, December 2009.
+
+ # Return HTML with a permanent link to current browser view.
+
+ my ( $cookie, # cookie hash
+ ) = @_;
+
+ # Returns a list.
+
+ my ( $href, @html );
+
+ $href = join( "&",
+ "$cookie->{ 'SCRIPT' }?page=browse",
+ "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' }",
+ "session_id=$cookie->{ 'SESSION_ID' }",
+ );
+
+ push @html, Maasha::XHTML::p( txt => Maasha::XHTML::ln( txt => "Permalink", href => $href ), class => 'center' );
+
+ return wantarray ? @html : \@html;
+}
+
+
sub section_export
{
# Martin A. Hansen, November 2009.
my ( $results, $result, $count, @html, $export, $browse );
- $results = Maasha::BBrowser::Track::search_tracks( $cookie );
+ $results = Maasha::BGB::Track::search_tracks( $cookie );
$count = scalar @{ $results };
$beg =~ tr/,//d;
$end =~ tr/,//d;
- $seq = ">$cookie->{ 'CONTIG' }_$beg" . "_$end" . "_$cookie->{ 'STRAND' }\n";
- $seq .= Maasha::BBrowser::Track::dna_get( $cookie );
+ $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 );