From: martinahansen Date: Fri, 5 Mar 2010 11:10:55 +0000 (+0000) Subject: wiggle tracks display - almost there X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=828b7c74049b1765dbe01d1194c05415d30e4e90;p=biopieces.git wiggle tracks display - almost there git-svn-id: http://biopieces.googlecode.com/svn/trunk@894 74ccb610-7750-0410-82ae-013aeee3265d --- diff --git a/code_perl/Maasha/BGB/Draw.pm b/code_perl/Maasha/BGB/Draw.pm index d60c5e4..3034974 100644 --- a/code_perl/Maasha/BGB/Draw.pm +++ b/code_perl/Maasha/BGB/Draw.pm @@ -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' ) { diff --git a/code_perl/Maasha/BGB/Track.pm b/code_perl/Maasha/BGB/Track.pm index 1c8ba95..8056ec2 100644 --- a/code_perl/Maasha/BGB/Track.pm +++ b/code_perl/Maasha/BGB/Track.pm @@ -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; } }