<commit_before>package Bio::EnsEMBL::GlyphSet::ctcf;
use strict;
use base qw(Bio::EnsEMBL::GlyphSet_wiggle_and_block);

sub my_helplink { return "ctcf"; }

sub get_block_features {
  ### block_features
  my ( $self, $db ) = @_;  
  unless ( $self->{'block_features'} ) {
    my $feature_adaptor = $db->get_DataSetAdaptor(); 
    if (!$feature_adaptor) {
      warn ("Cannot get get adaptors: $feature_adaptor");
      return [];
    }
     #warn "Adapt $feature_adaptor"; 
     my $features = $feature_adaptor->fetch_all_displayable_by_feature_type_class('Insulator') || [] ;  
    $self->{'block_features'} = $features; 
  }

  my $colour = "dodgerblue4";
  return ( $self->{'block_features'}, $colour);
}


sub draw_features {

  ### Description: gets features for block features and passes to render_block_features
  ### Draws wiggles if wiggle flag is 1
  ### Returns 1 if draws blocks. Returns 0 if no blocks drawn

  my ($self, $wiggle)= @_; 
  my $db =  $self->dbadaptor( 'homo sapiens', 'FUNCGEN' ); warn $db; 
  my ($block_features, $colour) = $self->get_block_features($db);
  my $drawn_flag = 0;
  my $drawn_wiggle_flag = $wiggle ? 0: "wiggle"; warn $wiggle;
  my $slice = $self->{'container'};
  my $wiggle_colour = "steelblue";
  foreach my $feature ( @$block_features ) {
    warn $feature; 
    # render wiggle if wiggle
   if ($wiggle) { 
	foreach my $result_set  ( @{ $feature->get_displayable_supporting_sets() } ){ 
	  warn $result_set;
	 #get features for slice and experimental chip set
	 my @features = @{ $result_set->get_displayable_ResultFeatures_by_Slice($slice) }; warn scalar @features;
	 next unless @features; 	
	 $drawn_wiggle_flag = "wiggle";
	 @features   = sort { $a->score <=> $b->score  } @features;
	 my ($min_score, $max_score) = ($features[0]->score || 0, $features[-1]->score|| 0); 
	 $self->render_wiggle_plot(\@features, $wiggle_colour, $min_score, $max_score, $result_set->display_label);
   }
      $self->render_space_glyph() if $drawn_wiggle_flag;
  }

    # Block feature 
   my $fset = $feature->get_displayable_product_FeatureSet();   
      my $display_label = $fset->display_label();<commit_msg>fixed to work with new wiggle glyphset<commit_after>package Bio::EnsEMBL::GlyphSet::ctcf;
use strict;
use base qw(Bio::EnsEMBL::GlyphSet_wiggle_and_block);

sub my_helplink { return "ctcf"; }

sub get_block_features {
  ### block_features
  my ( $self, $db ) = @_;  
  unless ( $self->{'block_features'} ) {
    my $feature_adaptor = $db->get_DataSetAdaptor(); 
    if (!$feature_adaptor) {
      warn ("Cannot get get adaptors: $feature_adaptor");
      return [];
    }
     #warn "Adapt $feature_adaptor"; 
     my $features = $feature_adaptor->fetch_all_displayable_by_feature_type_class('Insulator') || [] ;  
    $self->{'block_features'} = $features; 
  }

  my $colour = "dodgerblue4";
  return ( $self->{'block_features'}, $colour);
}


sub draw_features {

  ### Description: gets features for block features and passes to render_block_features
  ### Draws wiggles if wiggle flag is 1
  ### Returns 1 if draws blocks. Returns 0 if no blocks drawn

  my ($self, $wiggle)= @_; 
  my $db =  $self->dbadaptor( 'homo sapiens', 'FUNCGEN' ); warn $db; 
  my ($block_features, $colour) = $self->get_block_features($db);
  my $drawn_flag = 0;
  my $drawn_wiggle_flag = $wiggle ? 0: "wiggle"; warn $wiggle;
  my $slice = $self->{'container'};
  my $wiggle_colour = "steelblue";
  foreach my $feature ( @$block_features ) {
    warn $feature; 
    # render wiggle if wiggle
   if ($wiggle) { 
	foreach my $result_set  ( @{ $feature->get_displayable_supporting_sets() } ){ 
	  warn $result_set;
	 #get features for slice and experimental chip set
	 my @features = @{ $result_set->get_displayable_ResultFeatures_by_Slice($slice) }; warn scalar @features;
	 next unless @features; 	
	 $drawn_wiggle_flag = "wiggle";
	 @features   = sort { $a->score <=> $b->score  } @features;
	 my ($min_score, $max_score) = ($features[0]->score || 0, $features[-1]->score|| 0); 
#	 $self->render_wiggle_plot(\@features, $min_score, $max_score, $result_set->display_label, $wiggle_colour );
   $self->render_wiggle_plot(
    \@features,                      ## Features array
    { 'min_score' => $min_score, 'max_score' => $max_score }
  );

   }
      $self->render_space_glyph() if $drawn_wiggle_flag;
  }

    # Block feature 
   my $fset = $feature->get_displayable_product_FeatureSet();   
      my $display_label = $fset->display_label();
{'fraction_non_alphanumeric': 0.1514202639230597, 'fraction_numerical': 0.004473272198613286, 'mean_word_length': 4.0875995449374285, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 46, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4537129', 'n_tokens_mistral': 1632, 'n_tokens_neox': 1528, 'n_words': 357}