GBrowse

 view release on metacpan or  search on metacpan

conf/plugins/Spectrogram.pm  view on Meta::CPAN

    
    my $G = shift @g;
    my $A = shift @a;
    my $T = shift @t;
    my $C = shift @c;
    
    my $atts = { g   => $G,
		 a   => $A,
		 t   => $T,
		 c   => $C,
		 max => $max };
    
    # y-axis labels for first column
    if ($first) {
      $atts->{labels} = [$conf->{type},@labels];
      $first = 0;
    }
    
    # create a column for the spectrogram.  Offset the seuquence
    # coordinates so that features in the specrogam are directly below
    # the corresponding DNA 
    my $sf = Bio::Graphics::Feature->new( -type   => 'spectrogram',
					  -source => 'calculated',
					  -start  => $start + $slide_offset,
					  -end    => $end   + $slide_offset,
					  -ref    => $segment->ref,
					  -url    => $url,
					  -attributes    => $atts );
    
    $feature_list->add_feature($sf);
    
  }
  
  return $feature_list;
}

sub configure_form {
  my $self    = shift;
  my $conf    = $self->configuration;
  my $segment = ($self->segments)[0];

  my $state       = { on => 0, override => 1 };
  my $description = p(
      $self->_help_message($state,
			   span({-class=>'searchtitle'},
				'What is a DNA spectrogram?'),
			   $self->long_description)
      );

  my $form = $description;
 
  my $msg = $self->_help_message( $state, 'Sliding window size', split "NL", <<'END;');
Window size is the number of bases to include in each calculation.NL
Overlap is the increment by which the window slides (amount of overlap).NL
<font color=red>Note: </font>larger window sizes and/or smaller
overlaps increase computation time.
END;

  $form .= h4({-class => 'searchtitle'}, $msg) .
      p( 'Window: size ',
	 popup_menu( -name  => $self->config_name('win'),
		     -values => [8,16,32,64,128,256,512,1024,2048,4096,8192],
		     -default => $conf->{win} ),
	 ' bp' . br. br . ' overlap ',
	 textfield( -name  => $self->config_name('inc'),
		    -value => $conf->{inc},
		    -size  => 4 ),
	 'bp' );
  
  $msg = $self->_help_message( $state, 'Display options', split "NL", <<'END;');
The allowed range of periods or frequencies controls spectrogram height
and calculation time.NL 
period = size (bp) of structure or repeat unit, calculated as 
2*(window size)/frequency.NL
row height = the height (pixels) of each frequency row in the spectrogram.
END;
  
  $form .= br .  h4({-class => 'searchtitle'}, $msg) .
      p( 'Restrict ',
	 popup_menu( -name   => $self->config_name('measure'),
		     -values => [qw/period frequency/],
		     -default => $conf->{type} ),
	 ' to between ',
	 textfield( -name  => $self->config_name('min'),
		    -value => $conf->{min},
		    -size  => 4 ),
	 ' and ',
	 textfield( -name  => $self->config_name('max'),
		    -value => $conf->{max},
		    -size  => 4 ),
	 br . br . 'Row height',
         textfield( -name => $self->config_name('y_unit'),
                    -value => $conf->{y_unit},
                    -size  => 2 ),
         ' px ' );	 


  $msg = $self->_help_message( $state, 'Image saturation', split "NL", <<'END;');
Lowering the saturation value will reduce the dominance of very bright
colors on the spectrogram by setting an arbitrary maximum value
(expressed as a percentile rank).NL
Setting a lower saturation will reduce the effects of very high 
amplitude signals elsewhere in the spectrogram and help to 
emphasize less intense features.NL
The higher the saturation value is set, the darker the "background"
of the spectrogram.NL
There is a very large amplitude signal at frequency 0 Hz
(the very top of the spectrogram), with some bleed over to 1 Hz.NL
Filtering out these frequencies will help make the fainter
spots more visible by decreasing the overall range of signal
magnitudes.
END;

  $form .=  br . h4({-class => 'searchtitle'}, $msg) .
     p( 'Saturate color intensity at the ',
        textfield( -name   => $self->config_name('quantile'),
	 	  -value  => $conf->{quantile},
		   -size   => 5 ),
       'th percentile' );

  my @checked = (checked => 'checked') if $conf->{filter_01};
  $form .=    p( checkbox( -name => $self->config_name('filter_01'),
			   @checked,
			   -label => 'Filter out 0-1 Hz' ));

  return $form;
}

sub _help_message {
  my $self    = shift;
  my $state   = shift;
  my $section = shift;
  my @items = map li($_).br, @_;
  
  my $details = table( {-width => 800},
		      Tr( td( {-class => 'databody'}, ul(@items))));
  
  $self->toggle( $state, $section, $details );
}
  



( run in 1.014 second using v1.01-cache-2.11-cpan-364913b4093 )