]> git.donarmstrong.com Git - biopieces.git/blobdiff - code_perl/Maasha/BGB/Track.pm
layout of wiggle improved
[biopieces.git] / code_perl / Maasha / BGB / Track.pm
index 1c8ba95a963a7643286366668470854def5f813f..5322636b7980faa62c12bc11f46c43d8179821fd 100644 (file)
@@ -225,7 +225,9 @@ sub track_wiggle
 
     # Returns a list.
 
-    my ( $i, $max_val, $min_val, $factor, $factor_height, $x1, $y1, $x2, $y2, @block, $mean, @features );
+    my ( $i, $max_val, $min_val, $factor, $factor_height, $x1, $y1, $x2, $y2, $block_max, $mean, @features );
+
+    $cookie->{ 'TRACK_OFFSET' } += 10;
 
     $factor = $cookie->{ 'IMG_WIDTH' } / ( $end - $beg );
 
@@ -237,20 +239,20 @@ sub track_wiggle
         $factor_height = $cookie->{ 'WIGGLE_HEIGHT' } / $max_val;
     }
 
+    $block_max = 0;
+
     $x1 = 0;
     $y1 = $cookie->{ 'TRACK_OFFSET' } + $cookie->{ 'WIGGLE_HEIGHT' };
 
     for ( $i = 0; $i < scalar @{ $vals }; $i++ )
     {
-        push @block, $vals->[ $i ];
+        $block_max = Maasha::Calc::max( $block_max, $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 );
+            $y2 = $cookie->{ 'TRACK_OFFSET' } + $cookie->{ 'WIGGLE_HEIGHT' } - sprintf( "%.0f", $block_max * $factor_height );
 
             push @features, {
                 type       => 'wiggle',
@@ -265,7 +267,7 @@ sub track_wiggle
             $x1 = $x2;
             $y1 = $y2;
 
-            undef @block;
+            $block_max = 0;
         }
     }
 
@@ -287,7 +289,7 @@ sub track_wiggle
         font_size => $cookie->{ 'SEQ_FONT_SIZE' } - 2,
         color     => $cookie->{ 'SEQ_COLOR' },
         x1        => 0,
-        y1        => $cookie->{ 'TRACK_OFFSET' },
+        y1        => $cookie->{ 'TRACK_OFFSET' } - 5,
     };
 
     $cookie->{ 'TRACK_OFFSET' } += $cookie->{ 'WIGGLE_HEIGHT' } + $cookie->{ 'TRACK_SPACE' };