<commit_before>package EnsEMBL::Web::Component::Location::SyntenyImage;

### Module to replace part of the former SyntenyView, in this case displaying 
### an image of the syntenous chromosome regions 

use strict;

use base qw(EnsEMBL::Web::Component::Location);

sub _init {
  my $self = shift;
  $self->cacheable(1);
  $self->ajaxable(1);
}

sub content {
  my $self    = shift;
  my $hub     = $self->hub;
  my $object  = $self->object;
  my $species = $hub->species;
  my %synteny = $hub->species_defs->multi('DATABASE_COMPARA', 'SYNTENY');
  my $other   = $self->hub->otherspecies; 
  my $chr     = $object->seq_region_name;
  my %chr_1   = map { $_, 1 } @{$hub->species_defs->ENSEMBL_CHROMOSOMES || []};
  my $chr_2   = scalar @{$hub->species_defs->get_config($other, 'ENSEMBL_CHROMOSOMES')};
  
  unless ($synteny{$other}) {
    $hub->problem('fatal', "Can't display synteny",  "There is no synteny data for these two species ($species and $other)");
    return undef;
  }
  
  unless ($chr_1{$chr} && $chr_2 > 0) {
    $hub->problem('fatal', "Unable to display", "Synteny view only displays synteny between real chromosomes - not fragments");
    return undef;
  }

  my $ka         = $hub->get_adaptor('get_KaryotypeBandAdaptor', 'core', $species);
  my $ka2        = $hub->get_adaptor('get_KaryotypeBandAdaptor', 'core', $other);
  my $compara_db = $hub->database('compara');
  my $raw_data   = $object->chromosome->get_all_compara_Syntenies($other, undef, $compara_db);   
  my $chr_length = $object->chromosome->length;
  
  my ($localgenes, $offset) = $object->get_synteny_local_genes;
  my $loc = (@$localgenes ? $localgenes->[0]->start + $object->seq_region_start : 1); # Jump loc to the location of the genes
  
  my $image_config = $hub->get_imageconfig('Vsynteny');
  
  $image_config->{'other_species_installed'} = $synteny{$other};
  $image_config->container_width($chr_length);

  my $image = $self->new_vimage({
    chr           => $chr,
    ka_main       => $ka,
    sa_main       => $hub->get_adaptor('get_SliceAdaptor'),
    ka_secondary  => $ka2,
    sa_secondary  => $hub->get_adaptor('get_SliceAdaptor', 'core', $other),
    synteny       => $raw_data,
    other_species => $other,
    line          => $loc,
    format        => $hub->param('export')
  }, $image_config);

  $image->centred    = 1;  
  $image->imagemap   = 'yes';
  $image->image_type = 'syntenyview';
  $image->image_name = "$species-$chr-$other";
  $image->set_button('drag', 'title' => 'Click or drag to change region');

  my $chr_form = $self->chromosome_form('Vsynteny');

  $chr_form->add_element(
      type  => 'Hidden',
      name  => 'otherspecies',
      value => $self->hub->param('otherspecies') || $self->default_otherspecies,
  );
  
  return if $self->_export_image($image);
  my $html = sprintf('
  <div class="synteny_image">
    %s
  </div>
  <div class="synteny_forms">
    %s
    %s
  </div>
', $image->render, $self->species_form->render, $chr_form->render);

  return $html;
}

sub species_form {
  my $self             = shift;
  my $hub              = $self->hub;
  my $species_defs     = $hub->species_defs;
  my $url              = $hub->url({ otherspecies => undef }, 1);
  my $image_config     = $hub->get_imageconfig('Vsynteny');
  my $vwidth           = $image_config->image_height;
  my $form             = $self->new_form({ id => 'change_sp', action => $url->[0], method => 'get', class => 'autocenter', style => $vwidth ? "width:${vwidth}px" : undef });<commit_msg>remove gff in the export<commit_after>package EnsEMBL::Web::Component::Location::SyntenyImage;

### Module to replace part of the former SyntenyView, in this case displaying 
### an image of the syntenous chromosome regions 

use strict;

use base qw(EnsEMBL::Web::Component::Location);

sub _init {
  my $self = shift;
  $self->cacheable(1);
  $self->ajaxable(1);
}

sub content {
  my $self    = shift;
  my $hub     = $self->hub;
  my $object  = $self->object;
  my $species = $hub->species;
  my %synteny = $hub->species_defs->multi('DATABASE_COMPARA', 'SYNTENY');
  my $other   = $self->hub->otherspecies; 
  my $chr     = $object->seq_region_name;
  my %chr_1   = map { $_, 1 } @{$hub->species_defs->ENSEMBL_CHROMOSOMES || []};
  my $chr_2   = scalar @{$hub->species_defs->get_config($other, 'ENSEMBL_CHROMOSOMES')};
  
  unless ($synteny{$other}) {
    $hub->problem('fatal', "Can't display synteny",  "There is no synteny data for these two species ($species and $other)");
    return undef;
  }
  
  unless ($chr_1{$chr} && $chr_2 > 0) {
    $hub->problem('fatal', "Unable to display", "Synteny view only displays synteny between real chromosomes - not fragments");
    return undef;
  }

  my $ka         = $hub->get_adaptor('get_KaryotypeBandAdaptor', 'core', $species);
  my $ka2        = $hub->get_adaptor('get_KaryotypeBandAdaptor', 'core', $other);
  my $compara_db = $hub->database('compara');
  my $raw_data   = $object->chromosome->get_all_compara_Syntenies($other, undef, $compara_db);   
  my $chr_length = $object->chromosome->length;
  
  my ($localgenes, $offset) = $object->get_synteny_local_genes;
  my $loc = (@$localgenes ? $localgenes->[0]->start + $object->seq_region_start : 1); # Jump loc to the location of the genes
  
  my $image_config = $hub->get_imageconfig('Vsynteny');
  
  $image_config->{'other_species_installed'} = $synteny{$other};
  $image_config->container_width($chr_length);

  my $image = $self->new_vimage({
    chr           => $chr,
    ka_main       => $ka,
    sa_main       => $hub->get_adaptor('get_SliceAdaptor'),
    ka_secondary  => $ka2,
    sa_secondary  => $hub->get_adaptor('get_SliceAdaptor', 'core', $other),
    synteny       => $raw_data,
    other_species => $other,
    line          => $loc,
    format        => $hub->param('export')
  }, $image_config);

  $image->centred    = 1;  
  $image->imagemap   = 'yes';
  $image->image_type = 'syntenyview';
  $image->image_name = "$species-$chr-$other";
  $image->set_button('drag', 'title' => 'Click or drag to change region');

  my $chr_form = $self->chromosome_form('Vsynteny');

  $chr_form->add_element(
      type  => 'Hidden',
      name  => 'otherspecies',
      value => $self->hub->param('otherspecies') || $self->default_otherspecies,
  );
  
  return if $self->_export_image($image,'no_text');
  my $html = sprintf('
  <div class="synteny_image">
    %s
  </div>
  <div class="synteny_forms">
    %s
    %s
  </div>
', $image->render, $self->species_form->render, $chr_form->render);

  return $html;
}

sub species_form {
  my $self             = shift;
  my $hub              = $self->hub;
  my $species_defs     = $hub->species_defs;
  my $url              = $hub->url({ otherspecies => undef }, 1);
  my $image_config     = $hub->get_imageconfig('Vsynteny');
  my $vwidth           = $image_config->image_height;
  my $form             = $self->new_form({ id => 'change_sp', action => $url->[0], method => 'get', class => 'autocenter', style => $vwidth ? "width:${vwidth}px" : undef });
{'fraction_non_alphanumeric': 0.17429100755308535, 'fraction_numerical': 0.004275331338178709, 'mean_word_length': 3.478621569878749, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 163, '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': '1786960', 'n_tokens_mistral': 2608, 'n_tokens_neox': 2489, 'n_words': 526}