Permalink
Browse files

Add homoeologues page and menu item - initially only for Triticum aes…

…tivum
  • Loading branch information...
1 parent 2058a7d commit 3ef9acbba35b9ebf09fb355e69a9bef202f85dff @nicklangridge nicklangridge committed Mar 7, 2014
@@ -0,0 +1,225 @@
+=head1 LICENSE
+
+Copyright [1999-2014] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+=cut
+
+package EnsEMBL::Web::Component::Gene::ComparaHomoeologs;
+
+use strict;
+
+use HTML::Entities qw(encode_entities);
+
+use base qw(EnsEMBL::Web::Component::Gene);
+
+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_defs = $hub->species_defs;
+ my $cdb = shift || $hub->param('cdb') || 'compara';
+ my $availability = $object->availability;
+
+ my @homoeologues = (
+ $object->get_homology_matches('ENSEMBL_HOMOEOLOGUES', 'homoeolog', undef, $cdb),
+ );
+
+ my %homoeologue_list;
+ my %skipped;
+
+ foreach my $homology_type (@homoeologues) {
+ foreach (keys %$homology_type) {
+ (my $species = $_) =~ tr/ /_/;
+ $homoeologue_list{$species} = {%{$homoeologue_list{$species}||{}}, %{$homology_type->{$_}}};
+ $skipped{$species} += keys %{$homology_type->{$_}} if $hub->param('species_' . lc $species) eq 'off';
+ }
+ }
+
+ return '<p>No homoeologues have been identified for this gene</p>' unless keys %homoeologue_list;
+
+ my %homoeologue_map = qw(SEED BRH PIP RHS);
+ my $alignview = 0;
+
+ my ($html, $columns, @rows);
+
+ my $column_name = $self->html_format ? 'Compare' : 'Description';
+
+ my $columns = [
+ { key => 'Species', align => 'left', width => '10%', sort => 'html' },
+ { key => 'Type', align => 'left', width => '5%', sort => 'string' },
+ { key => 'dN/dS', align => 'left', width => '5%', sort => 'numeric' },
+ { key => 'identifier', align => 'left', width => '15%', sort => 'html', title => $self->html_format ? 'Ensembl identifier &amp; gene name' : 'Ensembl identifier'},
+ { key => $column_name, align => 'left', width => '10%', sort => 'none' },
+ { key => 'Location', align => 'left', width => '20%', sort => 'position_html' },
+ { key => 'Target %id', align => 'left', width => '5%', sort => 'numeric' },
+ { key => 'Query %id', align => 'left', width => '5%', sort => 'numeric' },
+ ];
+
+ push @$columns, { key => 'Gene name(Xref)', align => 'left', width => '15%', sort => 'html', title => 'Gene name(Xref)'} if(!$self->html_format);
+
+ @rows = ();
+
+ foreach my $species (sort { ($a =~ /^<.*?>(.+)/ ? $1 : $a) cmp ($b =~ /^<.*?>(.+)/ ? $1 : $b) } keys %homoeologue_list) {
+ next if $skipped{$species};
+
+ foreach my $stable_id (sort keys %{$homoeologue_list{$species}}) {
+ my $homoeologue = $homoeologue_list{$species}{$stable_id};
+ my ($target, $query);
+
+ # (Column 2) Add in homoeologue description
+ my $homoeologue_desc = $homoeologue_map{$homoeologue->{'homology_desc'}} || $homoeologue->{'homology_desc'};
+
+ # (Column 3) Add in the dN/dS ratio
+ my $homoeologue_dnds_ratio = $homoeologue->{'homology_dnds_ratio'} || 'n/a';
+
+ # (Column 4) Sort out
+ # (1) the link to the other species
+ # (2) information about %ids
+ # (3) links to multi-contigview and align view
+ (my $spp = $homoeologue->{'spp'}) =~ tr/ /_/;
+ my $link_url = $hub->url({
+ species => $spp,
+ action => 'Summary',
+ g => $stable_id,
+ __clear => 1
+ });
+
+ # Check the target species are on the same portal - otherwise the multispecies link does not make sense
+ my $target_links = ($link_url =~ /^\//
+ && $cdb eq 'compara'
+ && $availability->{'has_pairwise_alignments'}
+ ) ? sprintf(
+ '<ul class="compact"><li class="first"><a href="%s" class="notext">Region Comparison</a></li>',
+ $hub->url({
+ type => 'Location',
+ action => 'Multi',
+ g1 => $stable_id,
+ s1 => $spp,
+ r => undef,
+ config => 'opt_join_genes_bottom=on',
+ })
+ ) : '';
+
+ if ($homoeologue_desc ne 'DWGA') {
+ ($target, $query) = ($homoeologue->{'target_perc_id'}, $homoeologue->{'query_perc_id'});
+
+ my $align_url = $hub->url({
+ action => 'Compara_Homoeolog',
+ function => 'Alignment' . ($cdb =~ /pan/ ? '_pan_compara' : ''),
+ g1 => $stable_id,
+ });
+
+ unless ($object->Obj->biotype =~ /RNA/) {
+ $target_links .= sprintf '<li><a href="%s" class="notext">Alignment (protein)</a></li>', $align_url;
+ }
+ $align_url .= ';seq=cDNA';
+ $target_links .= sprintf '<li><a href="%s" class="notext">Alignment (cDNA)</a></li>', $align_url;
+
+ $alignview = 1;
+ }
+
+ $target_links .= sprintf(
+ '<li><a href="%s" class="notext">Gene Tree (image)</a></li></ul>',
+ $hub->url({
+ type => 'Gene',
+ action => 'Compara_Tree' . ($cdb =~ /pan/ ? '/pan_compara' : ''),
+ g1 => $stable_id,
+ anc => $homoeologue->{'gene_tree_node_id'},
+ r => undef
+ })
+ );
+
+ # (Column 5) External ref and description
+ my $description = encode_entities($homoeologue->{'description'});
+ $description = 'No description' if $description eq 'NULL';
+
+ if ($description =~ s/\[\w+:([-\/\w]+)\;\w+:(\w+)\]//g) {
+ my ($edb, $acc) = ($1, $2);
+ $description .= sprintf '[Source: %s; acc: %s]', $edb, $hub->get_ExtURL_link($acc, $edb, $acc) if $acc;
+ }
+
+ my @external = (qq{<span class="small">$description</span>});
+
+ if ($homoeologue->{'display_id'}) {
+ if ($homoeologue->{'display_id'} eq 'Novel Ensembl prediction' && $description eq 'No description') {
+ @external = ('<span class="small">-</span>');
+ } else {
+ unshift @external, $homoeologue->{'display_id'};
+ }
+ }
+
+ my $id_info = qq{<p class="space-below"><a href="$link_url">$stable_id</a></p>} . join '<br />', @external;
+
+ ## (Column 6) Location - split into elements to reduce horizonal space
+ my $location_link = $hub->url({
+ species => $spp,
+ type => 'Location',
+ action => 'View',
+ r => $homoeologue->{'location'},
+ g => $stable_id,
+ __clear => 1
+ });
+
+ my $table_details = {
+ 'Species' => join('<br />(', split /\s*\(/, $species_defs->species_label($species)),
+ 'Type' => ucfirst $homoeologue_desc,
+ 'dN/dS' => $homoeologue_dnds_ratio,
+ 'identifier' => $self->html_format ? $id_info : $stable_id,
+ 'Location' => qq{<a href="$location_link">$homoeologue->{'location'}</a>},
+ $column_name => $self->html_format ? qq{<span class="small">$target_links</span>} : $description,
+ 'Target %id' => $target,
+ 'Query %id' => $query
+ };
+ $table_details->{'Gene name(Xref)'}=$homoeologue->{'display_id'} if(!$self->html_format);
+
+ push @rows, $table_details;
+ }
+ }
+
+ my $table = $self->new_table($columns, \@rows, { data_table => 1, sorting => [ 'Species asc', 'Type asc' ], id => 'homoeologues' });
+
+ if ($alignview && keys %homoeologue_list) {
+ # PREpend
+ $html = sprintf(
+ '<p><a href="%s">View sequence alignments of all homoeologues</a>.</p>',
+ $hub->url({ action => 'Compara_Homoeolog', function => 'Alignment' . ($cdb =~ /pan/ ? '_pan_compara' : ''), })
+ ).$html;
+ }
+
+ $html .= $table->render;
+
+ if (scalar keys %skipped) {
+ my $count;
+ $count += $_ for values %skipped;
+
+ $html .= '<br />' . $self->_info(
+ 'homoeologues hidden by configuration',
+ sprintf(
+ '<p>%d homoeologues not shown in the table above from the following species. Use the "<strong>Configure this page</strong>" on the left to show them.<ul><li>%s</li></ul></p>',
+ $count,
+ join "</li>\n<li>", map "$_ ($skipped{$_})", sort keys %skipped
+ )
+ );
+ }
+ return $html;
+}
+
+1;
@@ -23,52 +23,67 @@ package EnsEMBL::Web::Component::Gene::HomologAlignment;
use strict;
use Bio::AlignIO;
-use List::MoreUtils qw{ none any };
use EnsEMBL::Web::Constants;
sub content {
my $self = shift;
my $hub = $self->hub;
my $cdb = shift || $hub->param('cdb') || 'compara';
+
my $species = $hub->species;
my $species_defs = $hub->species_defs;
my $gene_id = $self->object->stable_id;
my $second_gene = $hub->param('g1');
my $seq = $hub->param('seq');
my $text_format = $hub->param('text_format');
my $database = $hub->database($cdb);
- my $qm = $database->get_MemberAdaptor->fetch_by_source_stable_id('ENSEMBLGENE', $gene_id);
+ my $qm = $database->get_GeneMemberAdaptor->fetch_by_source_stable_id('ENSEMBLGENE', $gene_id);
my ($homologies, $html, %skipped);
-
+
eval {
$homologies = $database->get_HomologyAdaptor->fetch_all_by_Member($qm);
};
-
- my %desc_mapping = (
- ortholog_one2one => '1 to 1 orthologue',
- apparent_ortholog_one2one => '1 to 1 orthologue (apparent)',
- ortholog_one2many => '1 to many orthologue',
- between_species_paralog => 'paralogue (between species)',
- ortholog_many2many => 'many to many orthologue',
- within_species_paralog => 'paralogue (within species)',
- other_paralog => 'other paralogue (within species)',
- );
- my @orthologues = qw/ortholog_one2one apparent_ortholog_one2one ortholog_one2many ortholog_many2many possible_ortholog/;
- my @paralogues = ('other_paralog', 'between_species_paralog', 'within_species_paralog');
- my @list_to_show = ();
-
- if ( ($hub->referer->{'ENSEMBL_ACTION'} eq 'Compara_Paralog' && $hub->referer->{'ENSEMBL_FUNCTION'} eq 'Alignment_pan_compara')
- || ($hub->referer->{'ENSEMBL_ACTION'} eq 'Compara_Paralog' && $hub->referer->{'ENSEMBL_FUNCTION'} eq 'Alignment') ) {
- @list_to_show = (@paralogues);
- }
- if ( ($hub->referer->{'ENSEMBL_ACTION'} eq 'Compara_Ortholog' && $hub->referer->{'ENSEMBL_FUNCTION'} eq 'Alignment_pan_compara')
- || ( $hub->referer->{'ENSEMBL_ACTION'} eq 'Compara_Ortholog' && $hub->referer->{'ENSEMBL_FUNCTION'} eq 'Alignment')){
- @list_to_show = (@orthologues);
+ my ($match_type, %desc_mapping);
+
+ if ($hub->action eq 'Compara_Ortholog') {
+ $match_type = 'Orthologue';
+ %desc_mapping = (
+ ortholog_one2one => '1 to 1 orthologue',
+ apparent_ortholog_one2one => '1 to 1 orthologue (apparent)',
+ ortholog_one2many => '1 to many orthologue',
+ ortholog_many2many => 'many to many orthologue',
+ possible_ortholog => 'possible orthologue',
+ );
+ }
+## EG
+ elsif ($hub->action eq 'Compara_Homoeolog') {
+ $match_type = 'Homoeologue';
+ %desc_mapping = (
+ homoeolog_one2one => '1-to-1',
+ homoeolog_one2many => '1-to-many',
+ homoeolog_many2many => 'many-to-many',
+ );
+ }
+##
+ else {
+ $match_type = 'Paralogue';
+ %desc_mapping = (
+ within_species_paralog => 'paralogue (within species)',
+ putative_gene_split => 'putative gene split',
+ contiguous_gene_split => 'contiguous gene split',
+ );
}
-
+
+ my $homology_types = EnsEMBL::Web::Constants::HOMOLOGY_TYPES;
+
foreach my $homology (@{$homologies}) {
+
+ ## filter out non-required types
+ my $homology_desc = $homology_types->{$homology->{'_description'}} || $homology->{'_description'};
+ next unless $desc_mapping{$homology_desc};
+
my $sa;
eval {
@@ -100,6 +115,7 @@ sub content {
$peptide->stable_id,
sprintf('%d aa', $peptide->seq_length),
sprintf('%d %%', $peptide->perc_id),
+ sprintf('%d %%', $peptide->perc_cov),
$location,
];
} else {
@@ -115,6 +131,7 @@ sub content {
),
sprintf('%d aa', $peptide->seq_length),
sprintf('%d %%', $peptide->perc_id),
+ sprintf('%d %%', $peptide->perc_cov),
sprintf('<a href="%s">%s</a>',
$hub->url({ species => $member_species, type => 'Location', action => 'View', g => $gene->stable_id, r => $location, t => undef }),
$location
@@ -125,24 +142,19 @@ sub content {
next unless $flag;
- my $homology_types = EnsEMBL::Web::Constants::HOMOLOGY_TYPES;
- my $homology_desc = $homology_types->{$homology->{'_description'}} || $homology->{'_description'};
-
- next if
- none { $homology_desc eq $_ } @list_to_show;
-
my $homology_desc_mapped = $desc_mapping{$homology_desc} ? $desc_mapping{$homology_desc} :
$homology_desc ? $homology_desc : 'no description';
- $html .= "<h2>Homologue type: $homology_desc_mapped</h2>";
+ $html .= "<h2>$match_type type: $homology_desc_mapped</h2>";
my $ss = $self->new_table([
- { title => 'Species', width => '18%' },
- { title => 'Gene ID', width => '18%' },
- { title => 'Peptide ID', width => '18%' },
- { title => 'Peptide length', width => '13%' },
- { title => '% identity', width => '13%' },
- { title => 'Genomic location', width => '20%' }
+ { title => 'Species', width => '15%' },
+ { title => 'Gene ID', width => '15%' },
+ { title => 'Peptide ID', width => '15%' },
+ { title => 'Peptide length', width => '10%' },
+ { title => '% identity', width => '10%' },
+ { title => '% coverage', width => '10%' },
+ { title => 'Genomic location', width => '25%' }
],
$data
);
@@ -178,18 +190,20 @@ sub content {
$html .= "<pre>$var</pre>";
}
}
+
if (scalar keys %skipped) {
my $count;
$count += $_ for values %skipped;
-
- $html .= '<br />' . $self->_info(
- 'Orthologues hidden by configuration',
+## EG
+ $html .= '<br />' . $self->_info(
+ "${match_type}s hidden by configuration",
sprintf(
- '<p>%d orthologues not shown in the table above from the following species. Use the "<strong>Configure this page</strong>" on the left to show them.<ul><li>%s</li></ul></p>',
+ '<p>%d ${match_type}s not shown in the table above from the following species. Use the "<strong>Configure this page</strong>" on the left to show them.<ul><li>%s</li></ul></p>',
$count,
join "</li>\n<li>", map "$_ ($skipped{$_})", sort keys %skipped
)
);
+##
}
return $html;
Oops, something went wrong.

0 comments on commit 3ef9acb

Please sign in to comment.