]> git.donarmstrong.com Git - biopieces.git/commitdiff
cleaned BBrowser::Tracks.pm
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 26 Nov 2009 13:42:51 +0000 (13:42 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 26 Nov 2009 13:42:51 +0000 (13:42 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@780 74ccb610-7750-0410-82ae-013aeee3265d

code_perl/Maasha/BBrowser/Track.pm
www/index.cgi

index bb9c2289b00c768821a255b723e52615af666e2d..2d5afed482aa55da873781a2fccf0db48f12c8cb 100644 (file)
@@ -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' };
index 701aa86c05cffe32c53704ddfd22e4082bed3266..5d0d8dc77c256b5d29050d3da4a3156dbe5fd987 100755 (executable)
@@ -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