<commit_before>package Bio::EnsEMBL::GlyphSet::assemblyexception;

use strict;

use base qw(Bio::EnsEMBL::GlyphSet_simple);

sub readable_strand { return $_[1] < 0 ? 'rev' : 'fwd'; }
sub my_label        { return undef; }

sub features        { return $_[0]->{'container'}->get_all_AssemblyExceptionFeatures; }

sub colour_key {
  my ($self, $f) = @_;
  (my $key = lc $f->type) =~ s/ /_/g;
  return $key;
}

sub feature_label {
  my ($self, $f) = @_;
  
  return undef if $self->my_config('label') eq 'off';

=pod
  my %type_lookup = (
    'HAP' => 'Haplotype(s)',
    'PAR' => 'PAR',
    'PATCH_NOVEL' => 'Novel patch',
    'PATCH_FIX'   => 'Fix patch',
  );

  if ($self->my_config('short_labels')) {
    (my $key = $f->type) =~ s/ REF//;
    my $label = $type_lookup{$key};
    return $label;
  }
=cut
  return $f->{'alternate_slice'}->seq_region_name if $self->my_config('short_labels');

  return sprintf(
    '%s: %s:%d-%d (%s)',
    $f->type,
    $f->{'alternate_slice'}->seq_region_name,
    $f->{'alternate_slice'}->start,
    $f->{'alternate_slice'}->end,
    $self->readable_strand($f->{'alternate_slice'}->strand)
  );
}

sub title {
  my ($self, $f) = @_;

  return sprintf('%s; %s:%d-%d (%s); %s:%d-%d (%s)',
    $self->my_colour($self->colour_key($f), 'text'),
    $f->{'slice'}->seq_region_name,
    $f->{'slice'}->start + $f->{'start'} - 1,
    $f->{'slice'}->start + $f->{'end'}   - 1,
    $self->readable_strand($f->{'slice'}->strand),
    $f->{'alternate_slice'}->seq_region_name,
    $f->{'alternate_slice'}->start,
    $f->{'alternate_slice'}->end,
    $self->readable_strand($f->{'alternate_slice'}->strand)
  );
}


sub href {
  my ($self, $f) = @_;
  my $slice = $f->alternate_slice;
  my $c2    = $slice->seq_region_name;
  my $s2    = $slice->start;
  my $e2    = $slice->end;
  my $o2    = $slice->strand;
  my $class = $self->colour_key($f);
  
  return $self->_url({
    species     => $f->species,
    action      => 'View',
    r           => "$c2:$s2-$e2",
    target      => $f->slice->seq_region_name,
    target_type => [ split ' ', $f->type ]->[0],
    class       => $class,
  });
}
<commit_msg>Updated to work with alternate renderers<commit_after>package Bio::EnsEMBL::GlyphSet::assemblyexception;

use strict;

use base qw(Bio::EnsEMBL::GlyphSet_simple);

sub readable_strand { return $_[1] < 0 ? 'rev' : 'fwd'; }
sub my_label        { return undef; }

sub features        { return $_[0]->{'container'}->get_all_AssemblyExceptionFeatures; }

sub render_normal           { 
  my $self = shift;
  $self->{'my_config'}->set('label', 'off'); 
  $self->{'my_config'}->set('depth', 1);
  $self->SUPER::render_normal; 
}

sub render_labels           { $_[0]->SUPER::render_normal; }

sub colour_key {
  my ($self, $f) = @_;
  (my $key = lc $f->type) =~ s/ /_/g;
  return $key;
}

sub feature_label {
  my ($self, $f) = @_;
  
  return undef if $self->my_config('label') eq 'off';

  return $f->{'alternate_slice'}->seq_region_name if $self->my_config('short_labels');

  return sprintf(
    '%s: %s:%d-%d (%s)',
    $f->type,
    $f->{'alternate_slice'}->seq_region_name,
    $f->{'alternate_slice'}->start,
    $f->{'alternate_slice'}->end,
    $self->readable_strand($f->{'alternate_slice'}->strand)
  );
}

sub title {
  my ($self, $f) = @_;

  return sprintf('%s; %s:%d-%d (%s); %s:%d-%d (%s)',
    $self->my_colour($self->colour_key($f), 'text'),
    $f->{'slice'}->seq_region_name,
    $f->{'slice'}->start + $f->{'start'} - 1,
    $f->{'slice'}->start + $f->{'end'}   - 1,
    $self->readable_strand($f->{'slice'}->strand),
    $f->{'alternate_slice'}->seq_region_name,
    $f->{'alternate_slice'}->start,
    $f->{'alternate_slice'}->end,
    $self->readable_strand($f->{'alternate_slice'}->strand)
  );
}


sub href {
  my ($self, $f) = @_;
  my $slice = $f->alternate_slice;
  my $c2    = $slice->seq_region_name;
  my $s2    = $slice->start;
  my $e2    = $slice->end;
  my $o2    = $slice->strand;
  my $class = $self->colour_key($f);
 
  return $self->_url({
    species     => $f->species,
    action      => 'View',
    r           => "$c2:$s2-$e2",
    target      => $f->slice->seq_region_name,
    target_type => [ split ' ', $f->type ]->[0],
    class       => $class,
    depth       => $self->my_config('depth'),
    dbID        => $f->id,
  });
}

{'fraction_non_alphanumeric': 0.23500697350069735, 'fraction_numerical': 0.006508600650860065, 'mean_word_length': 3.1414821944177094, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 133, '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': '5622117', 'n_tokens_mistral': 1757, 'n_tokens_neox': 1699, 'n_words': 296}