]> git.donarmstrong.com Git - biopieces.git/commitdiff
wiggle tracks display - almost there
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Fri, 5 Mar 2010 11:10:55 +0000 (11:10 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Fri, 5 Mar 2010 11:10:55 +0000 (11:10 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@894 74ccb610-7750-0410-82ae-013aeee3265d

code_perl/Maasha/BGB/Draw.pm
code_perl/Maasha/BGB/Track.pm

index d60c5e4d94c6e91995fec5c8131a24e4d95ebab8..3034974119e33ac45a5a02d819ca5cac9d4801d9 100644 (file)
@@ -81,10 +81,9 @@ sub draw_feature
 
                 undef $first;
             }
-            else
-            {
-                $cr->line_to( $feature->{ 'x2' }, $feature->{ 'y2' } );
-            }
+
+            $cr->line_to( $feature->{ 'x1' }, $feature->{ 'y2' } );
+            $cr->line_to( $feature->{ 'x2' }, $feature->{ 'y2' } );
         }
         elsif ( $feature->{ 'type' } eq 'arrow' )
         {
index 1c8ba95a963a7643286366668470854def5f813f..8056ec2911c1f576d2d8a285573989ea178c8d7e 100644 (file)
@@ -225,7 +225,7 @@ 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 );
 
     $factor = $cookie->{ 'IMG_WIDTH' } / ( $end - $beg );
 
@@ -237,20 +237,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 +265,7 @@ sub track_wiggle
             $x1 = $x2;
             $y1 = $y2;
 
-            undef @block;
+            $block_max = 0;
         }
     }