From c9368928437d17b82346242b18e4fc94172ec1c3 Mon Sep 17 00:00:00 2001 From: martinahansen Date: Thu, 26 Nov 2009 13:42:51 +0000 Subject: [PATCH] cleaned BBrowser::Tracks.pm git-svn-id: http://biopieces.googlecode.com/svn/trunk@780 74ccb610-7750-0410-82ae-013aeee3265d --- code_perl/Maasha/BBrowser/Track.pm | 71 ++++++++++++++++++++++++------ www/index.cgi | 3 +- 2 files changed, 59 insertions(+), 15 deletions(-) diff --git a/code_perl/Maasha/BBrowser/Track.pm b/code_perl/Maasha/BBrowser/Track.pm index bb9c228..2d5afed 100644 --- a/code_perl/Maasha/BBrowser/Track.pm +++ b/code_perl/Maasha/BBrowser/Track.pm @@ -46,9 +46,16 @@ use vars qw( @ISA @EXPORT ); sub track_ruler { - my ( $cookie, # browser cookie + # Martin A. Hansen, November 2009. + + # Create a track with a ruler of tics and positions for + # the browser window. + + my ( $cookie, # browser cookie ) = @_; + # Returns a list. + my ( $beg, $end, $factor, $step, $i, $txt, $x, @ruler ); $beg = $cookie->{ 'NAV_START' }; @@ -57,8 +64,7 @@ sub track_ruler $step = 10; - while ( ( $end - $beg ) / $step > 20 ) - { + while ( ( $end - $beg ) / $step > 20 ) { $step *= 5; } @@ -66,7 +72,7 @@ sub track_ruler { if ( ( $i % $step ) == 0 ) { - $txt = Maasha::Calc::commify( $i ) . "|"; + $txt = Maasha::Calc::commify( $i ) . "|"; # TODO reverse this so |123 instead of 123| $x = sprintf( "%.0f", ( $i - $beg - length $txt ) * $factor ); if ( $x > 0 and $x + ( $cookie->{ 'RULER_FONT_SIZE' } * length $txt ) < $cookie->{ 'IMG_WIDTH' } ) @@ -91,9 +97,16 @@ sub track_ruler sub track_seq { + # Martin A. Hansen, November 2009. + + # Create a sequence track by extracting the appropriate + # stretch of sequence from the sequence file. + my ( $cookie, # browser cookie ) = @_; + # Returns a list. + my ( $file, $fh, $seq, @chars, $factor, $i, @seq_list ); if ( $cookie->{ 'NAV_END' } - $cookie->{ 'NAV_START' } + 1 <= 220 ) @@ -131,8 +144,13 @@ sub track_seq sub track_feature { - my ( $track, - $cookie, + # Martin A. Hansen, November 2009. + + # Create a track with features. If there are more than $cookie->FEAT_MAX + # features the track created will be a histogram, else linear. + + my ( $track, # path to kiss file with track data + $cookie, # cookie hash ) = @_; # Returns a list. @@ -160,7 +178,7 @@ sub track_feature $cookie->{ 'TRACK_OFFSET' } += 10; - if ( $count > 5000 ) + if ( $count > $cookie->{ 'FEAT_MAX' } ) { $entries = Maasha::KISS::kiss_index_get_blocks( $index, $start, $end ); push @{ $features }, track_feature_histogram( $cookie, $start, $end, $entries ); @@ -177,6 +195,11 @@ sub track_feature sub track_feature_linear { + # Martin A. Hansen, November 2009. + + # Create a linear feature track where the granularity depends + # on the lenght of the features and the browser window width. + my ( $cookie, # hashref with image draw metrics $beg, # base window beg $end, # base window end @@ -235,7 +258,11 @@ sub track_feature_linear sub feature_align { - # 17:A>T + # Martin A. Hansen, November 2009. + + # Add to feature track alignment info if the granularity is + # sufficient. + # TODO: The printing of chars is imprecise. my ( $entry, # Partial KISS entry $beg, # base window beg @@ -298,10 +325,16 @@ sub feature_align sub track_feature_histogram { + # Martin A. Hansen, November 2009. + + # Create a feature track as a histogram using information + # from the index only thus avoiding to load features from the + # file. + my ( $cookie, # hashref with image draw metrics - $min, # minimum base position - $max, # maximum base position - $blocks, # list of blocks + $min, # minimum base position + $max, # maximum base position + $blocks, # list of blocks ) = @_; # Returns a list. @@ -372,7 +405,12 @@ sub track_feature_histogram sub path_seq { - my ( $cookie, + # Martin A. Hansen, November 2009. + + # Returns the path to the sequence file for a specified + # contig as written in the cookie. + + my ( $cookie, # cookie hash ) = @_; # Returns a string. @@ -405,11 +443,16 @@ sub path_seq sub path_tracks { - my ( $cookie, + # Martin A. Hansen, November 2009. + + # Returns a list of paths to all tracks for a specified + # contig as written in the cookie. + + my ( $cookie, # cookie path ) = @_; # Returns a list. - # + my ( $path, @tracks ); die qq(ERROR: no USER in cookie.\n) if not $cookie->{ 'USER' }; diff --git a/www/index.cgi b/www/index.cgi index 701aa86..5d0d8dc 100755 --- a/www/index.cgi +++ b/www/index.cgi @@ -120,6 +120,7 @@ sub cookie_default $cookie->{ 'SEQ_COLOR' } = [ 0, 0, 0, ]; $cookie->{ 'FEAT_WIDTH' } = 5; $cookie->{ 'FEAT_COLOR' } = [ 0, 0, 0 ]; + $cookie->{ 'FEAT_MAX' } = 5000; $path = "$cookie->{ 'DATA_DIR' }/Users"; @@ -584,7 +585,7 @@ sub section_browse { $cookie->{ 'FEAT_COLOR' } = Maasha::BBrowser::Draw::palette( $i ); - push @features, [ Maasha::BBrowser::Track::track_feature( $tracks[ $i ], $cookie, $cookie ) ]; + push @features, [ Maasha::BBrowser::Track::track_feature( $tracks[ $i ], $cookie ) ]; } $file = "fisk.png"; # FIXME -- 2.39.2