$beg = $cookie->{ 'NAV_START' };
$end = $cookie->{ 'NAV_END' };
- $factor = $cookie->{ 'IMG_WIDTH' } / ( $end - $beg + 1 );
+ $factor = $cookie->{ 'IMG_WIDTH' } / ( $end - $beg );
$step = 10;
# Returns a list.
- my ( $i, $height, $max_val, $min_val, $max, $factor, $x1, $y1, $x2, $y2, @features );
+ my ( $i, $max_val, $min_val, $factor, $factor_height, $x1, $y1, $x2, $y2, @block, $mean, @features );
- $height = 75; # pixels
+ $factor = $cookie->{ 'IMG_WIDTH' } / ( $end - $beg );
( $min_val, $max_val ) = Maasha::Calc::minmax( $vals );
- $vals = Maasha::BGB::Wiggle::wiggle_normalize( $vals, $cookie->{ 'IMG_WIDTH' } );
-
- $max = Maasha::Calc::list_max( $vals );
- $max ||= 1;
-
- $factor = $height / $max;
+ if ( $max_val == 0 ) {
+ $factor_height = $cookie->{ 'WIGGLE_HEIGHT' } / 1;
+ } else {
+ $factor_height = $cookie->{ 'WIGGLE_HEIGHT' } / $max_val;
+ }
$x1 = 0;
- $y1 = $cookie->{ 'TRACK_OFFSET' } + $height;
+ $y1 = $cookie->{ 'TRACK_OFFSET' } + $cookie->{ 'WIGGLE_HEIGHT' };
for ( $i = 0; $i < scalar @{ $vals }; $i++ )
{
- $x2 = $i;
- $y2 = $cookie->{ 'TRACK_OFFSET' } + $height - sprintf( "%.0f", $vals->[ $i ] * $factor );
-
- push @features, {
- type => 'wiggle',
- color => $cookie->{ 'FEAT_COLOR' },
- line_width => 1,
- x1 => $x1,
- y1 => $y1,
- x2 => $x2,
- y2 => $y2,
- };
-
- $x1 = $x2;
- $y1 = $y2;
+ push @block, $vals->[ $i ];
+
+ $x2 = int( $i * $factor );
+
+ if ( $x2 > $x1 )
+ {
+ $mean = sprintf( "%.0f", Maasha::Calc::mean( \@block ) );
+
+ $y2 = $cookie->{ 'TRACK_OFFSET' } + $cookie->{ 'WIGGLE_HEIGHT' } - ( $mean * $factor_height );
+
+ push @features, {
+ type => 'wiggle',
+ color => $cookie->{ 'FEAT_COLOR' },
+ line_width => 1,
+ x1 => $x1,
+ y1 => $y1,
+ x2 => $x2,
+ y2 => $y2,
+ };
+
+ $x1 = $x2;
+ $y1 = $y2;
+
+ undef @block;
+ }
}
- $x2 = $i;
- $y2 = $cookie->{ 'TRACK_OFFSET' } + $height;
+ $y2 = $cookie->{ 'TRACK_OFFSET' } + $cookie->{ 'WIGGLE_HEIGHT' };
push @features, {
- type => 'wiggle',
- color => $cookie->{ 'FEAT_COLOR' },
+ type => 'wiggle',
+ color => $cookie->{ 'FEAT_COLOR' },
line_width => 1,
x1 => $x1,
y1 => $y1,
y1 => $cookie->{ 'TRACK_OFFSET' },
};
- $cookie->{ 'TRACK_OFFSET' } += $height + $cookie->{ 'TRACK_SPACE' };
+ $cookie->{ 'TRACK_OFFSET' } += $cookie->{ 'WIGGLE_HEIGHT' } + $cookie->{ 'TRACK_SPACE' };
return wantarray ? @features : \@features;
}
my ( $factor, $entry, $y_step, @ladder, $y_max, $w, $x1, $y1, $x2, $y2, $feature, @features );
- $factor = $cookie->{ 'IMG_WIDTH' } / ( $end - $beg + 1 );
+ $factor = $cookie->{ 'IMG_WIDTH' } / ( $end - $beg );
$y_step = 0;
$y_max = 0;
$hist_height = 100; # pixels
$bucket_width = 5;
$bucket_count = $cookie->{ 'IMG_WIDTH' } / $bucket_width;
- $factor = ( $cookie->{ 'IMG_WIDTH' } / $bucket_width ) / ( $max - $min + 1 );
+ $factor = ( $cookie->{ 'IMG_WIDTH' } / $bucket_width ) / ( $max - $min );
$min_bucket = 999999999;
$max_height = 0;
$cookie->{ 'MOVE_RIGHT2' } = $cgi->param( 'move_right2' );
$cookie->{ 'MOVE_RIGHT3' } = $cgi->param( 'move_right3' );
- $cookie->{ 'IMG_WIDTH' } = 1200;
- $cookie->{ 'IMG_HEIGHT' } = 800;
+ $cookie->{ 'IMG_WIDTH' } = 1200; # Width of browser image in pixels
+ $cookie->{ 'IMG_HEIGHT' } = 800; # Height of browser image in pixels
+ $cookie->{ 'WIGGLE_HEIGHT' } = 75; # Height of Wiggle tracks in pixels
$cookie->{ 'TRACK_OFFSET' } = 20;
$cookie->{ 'TRACK_SPACE' } = 20;
- $cookie->{ 'RULER_FONT_SIZE' } = 10;
+ $cookie->{ 'RULER_FONT_SIZE' } = 10; # Size of ruler font in pixels
$cookie->{ 'RULER_COLOR' } = [ 0, 0, 0 ];
$cookie->{ 'SEQ_FONT_SIZE' } = 10;
$cookie->{ 'SEQ_COLOR' } = [ 0, 0, 0, ];
$cookie->{ 'FEAT_WIDTH' } = 5;
$cookie->{ 'FEAT_COLOR' } = [ 0, 0, 0 ];
- $cookie->{ 'FEAT_MAX' } = 5000;
+ $cookie->{ 'FEAT_MAX' } = 5000; # TODO: Reduntant?
$cookie->{ 'LIST_USER' } = Maasha::BGB::Track::list_users();
$cookie->{ 'LIST_CLADE' } = Maasha::BGB::Track::list_clades( $cookie->{ 'USER' } );