$cookie->{ 'Q_ID' } = $cgi->param( 'q_id' );
$cookie->{ 'NAV_START' } ||= $cgi->param( 'nav_start' ) || $cgi->param( 's_beg' ); # FIXME this is ugly!
$cookie->{ 'NAV_END' } ||= $cgi->param( 'nav_end' ) || $cgi->param( 's_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' );
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
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 ) );
}
+sub cookie_center
+{
+ # 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
+ ) = @_;
+
+ # Returns nothing.
+
+ my ( $l_dist, $r_dist );
+
+ if ( defined $cookie->{ 'NAV_CENTER' } )
+ {
+ $l_dist = $cookie->{ 'NAV_CENTER' } - $cookie->{ 'NAV_START' };
+ $r_dist = $cookie->{ 'NAV_END' } - $cookie->{ 'NAV_CENTER' };
+
+ if ( $l_dist > $r_dist ) {
+ $cookie->{ 'NAV_START' } = $cookie->{ 'NAV_END' } - 2 * $r_dist;
+ } else {
+ $cookie->{ 'NAV_END' } = $cookie->{ 'NAV_START' } + 2 * $l_dist;
+ }
+ }
+}
+
+
sub cookie_href
{
# Martin A. Hansen, November 2009.
# 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 ) ];
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' }",
+ shape => 'rect',
+ coords => "$elem->{ x1 }, $elem->{ y1 }, $elem->{ x2 }, $elem->{ y2 }",
+ title => "$elem->{ 'title' }",
);
}
}
+ $factor = $cookie->{ 'IMG_WIDTH' } / ( $cookie->{ 'NAV_END' } - $cookie->{ 'NAV_START' } + 1 );
+ $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 => cookie_href( $cookie, "browse" ) . "&nav_start=$cookie->{ 'NAV_START' }&nav_end=$cookie->{ 'NAV_END' }&nav_center=$center",
+ 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 ),
+ );
+ }
+
push @img, Maasha::XHTML::map_end();
push @html, Maasha::XHTML::p( txt => join( "\n", @img ) );