<commit_before>package EnsEMBL::Web::ZMenu::Supporting_alignment;

use strict;

use HTML::Entities qw(encode_entities);

use base qw(EnsEMBL::Web::ZMenu);

sub content {
  my $self         = shift;
  my $object       = $self->object;
  my $id           = $object->param('id');
  my $db           = $object->param('fdb') || $object->param('db') || 'core'; 
  my $object_type  = $object->param('ftype');
  my $db_adaptor   = $object->database(lc($db));
  my $adaptor_name = "get_${object_type}Adaptor";
  my $feat_adap    = $db_adaptor->$adaptor_name;
  my $features     = $feat_adap->fetch_all_by_hit_name($id) || [];

  $self->caption($id);

  if ($features->[0]->analysis->logic_name =~ /intron/) {

    if (scalar(@$features) > 1) { warn "multiple intron objects, not good";}

    my $r = $object->seq_region_name . ':' . $object->seq_region_start . '-' . $object->seq_region_end;
    $self->add_entry({
      type  => 'Location',
      label => $r,
    });

    my $score = $features->[0]->score;
    $self->add_entry({
      type  => 'Read coverage',
      label => $score,
    });
  }

  else {
#    foreach my $feat (@$features) {
#      my $evalue = $feat->{'p_value'};
#      $self->add_entry({
#	type  => 'RPKM',
#	label => $evalue,
#      });
#    }
#  }

  $self->add_entry({ 
    label => 'View all hits',
    link  => $object->_url({
      type   => 'Location',
      action => 'Genome',
      ftype  => $object_type,
      id     => $id,
      db     => $db
    })
  });

  $self->add_entry({
    label_html => $features->[0]->analysis->description
  });
}

1;<commit_msg>show distinct scores on individual featuers within the group, don't show standard featureview link<commit_after>package EnsEMBL::Web::ZMenu::Supporting_alignment;

use strict;

use HTML::Entities qw(encode_entities);

use base qw(EnsEMBL::Web::ZMenu);

sub content {
  my $self         = shift;
  my $object       = $self->object;
  my $id           = $object->param('id');
  my $db           = $object->param('fdb') || $object->param('db') || 'core'; 
  my $object_type  = $object->param('ftype');
  my $db_adaptor   = $object->database(lc($db));
  my $adaptor_name = "get_${object_type}Adaptor";
  my $feat_adap    = $db_adaptor->$adaptor_name;
  my $features     = $feat_adap->fetch_all_by_hit_name($id) || [];
  my $click_start  = $object->param('click_start');
  my $click_end    = $object->param('click_end');

  $self->caption($id);

  if ($features->[0]->analysis->logic_name =~ /intron/) {

    if (scalar(@$features) > 1) { warn "multiple intron objects, not good, code is written for single ones";}

    my $r = $object->seq_region_name . ':' . $object->seq_region_start . '-' . $object->seq_region_end;
    $self->add_entry({
      type  => 'Location',
      label => $r,
    });

    my $score = $features->[0]->score;
    $self->add_entry({
      type  => 'Read coverage',
      label => $score,
    });
  }

  else {
    my $longest_feat_dbID;
    my $length = 0;
    #code below assumes longest feature supports the transcript - quicker than getting a slice for each feature
    #and identifying (transcript)_supporting_features using fetch_all_by_Slice_constraint
    #will need modifying for single exon Zv9 RNASeq transcripts - either with API call on feature, or by hit name or logic_name
    foreach my $feat (@$features) {
      if (($feat->end - $feat->start + 1) > $length) {
	$longest_feat_dbID = $feat->dbID;
	$length = $feat->end - $feat->start + 1;
      }
    }
    foreach my $feat (@$features) {
      if ( ($click_start < $feat->end) && ($click_end > $feat->start) ) {
	my $type = $feat->dbID eq $longest_feat_dbID ? 'transcript RPKM' : 'exon RPKM';
	my $evalue = sprintf ("%.4f",$feat->{'p_value'});
	$self->add_entry({
	  type  => $type,
	  label => $evalue,
	});
      }
    }
  }

  #don't bother showing the usual featureview link since the names are unique
#  $self->add_entry({ 
#    label => 'View all hits',
#    link  => $object->_url({
#      type   => 'Location',
#      action => 'Genome',
#      ftype  => $object_type,
#      id     => $id,
#      db     => $db
#    })
#  });

  $self->add_entry({
    label_html => $features->[0]->analysis->description
  });

}

1;
{'fraction_non_alphanumeric': 0.18357142857142858, 'fraction_numerical': 0.0035714285714285713, 'mean_word_length': 2.9298409728718426, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 99, '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': '4146572', 'n_tokens_mistral': 1533, 'n_tokens_neox': 1476, 'n_words': 327}