Skip to content

Tweak handling of strain, Pan and subtree export #1074

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/EnsEMBL/Web/Command/DataExport/Output.pm
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ sub process {
$url_params->{'__clear'} = 1;
## Pass parameters needed for Back button to work
my @core_params = keys %{$hub->core_object('parameters')};
push @core_params, qw(export_action data_type data_action component align g1);
push @core_params, qw(export_action data_type data_action component align g1 node strain);
push @core_params, $self->config_params;
foreach (@core_params) {
my @values = $component->param($_);
Expand Down
31 changes: 31 additions & 0 deletions modules/EnsEMBL/Web/Constants.pm
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,37 @@ sub GENE_JOIN_TYPES {
}
}

sub GENE_TREE_CONSTANTS {
### Compara lookup for various gene-tree views
my ($cdb, $strain, $clusterset_id) = @_;

my $GENE_TREE_CONSTANTS = {
compara_pan_ensembl => {
action => 'PanComparaTree',
component => 'PanComparaTree',
},
compara_strain => {
action => 'Strain_Compara_Tree',
component => 'ComparaTree',
},
compara => {
action => 'Compara_Tree',
component => 'ComparaTree',
},
};

my $gene_tree_view_key;
if ($cdb eq 'compara_pan_ensembl') {
$gene_tree_view_key = 'compara_pan_ensembl';
} elsif ($strain) {
$gene_tree_view_key = 'compara_strain';
} else {
$gene_tree_view_key = 'compara';
}

return $GENE_TREE_CONSTANTS->{$gene_tree_view_key};
}

sub ALIGNMENT_FORMATS {
### Metadata for alignment export formats
return (
Expand Down
32 changes: 9 additions & 23 deletions modules/EnsEMBL/Web/ZMenu/ComparaTreeNode.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,17 @@ use URI::Escape qw(uri_escape);
use IO::String;
use Bio::AlignIO;

use EnsEMBL::Web::Constants;

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

sub content {
my $self = shift;
my $cdb = shift || 'compara';
my $hub = $self->hub;
my $object = $self->object;
my $strain_tree = $hub->species_defs->get_config($self->hub->species,'RELATED_TAXON') if $hub->param('strain');
my $is_strain = $hub->param('strain');
my $strain_tree = $hub->species_defs->get_config($self->hub->species,'RELATED_TAXON') if $is_strain;
my $tree = $object->isa('EnsEMBL::Web::Object::GeneTree') ? $object->tree : $object->get_GeneTree($cdb, "", $strain_tree);

die 'No tree for gene' unless $tree;
Expand Down Expand Up @@ -165,6 +168,7 @@ sub content {

}

my $gene_tree_constants = EnsEMBL::Web::Constants::GENE_TREE_CONSTANTS($cdb, $is_strain, $tree->tree->clusterset_id);
my $lookup = $hub->species_defs->prodnames_to_urls_lookup;
if ($is_leaf and $is_supertree) {

Expand All @@ -177,9 +181,6 @@ sub content {

my $link_gene = $node->{_sub_reference_gene};

## Strain trees and other trees are very different!
my $action = $hub->param('strain') ? 'Strain_Compara_Tree' : 'Compara_Tree';

my $that_subtree_link;
if ($tree_stable_id) {
$that_subtree_link = $hub->url({
Expand All @@ -193,27 +194,10 @@ sub content {
my $link_gene = $node->{_sub_reference_gene};
my $species = $lookup->{$link_gene->genome_db->name};

# This is not the most elegant approach, but it will change the $action
# only where gene-tree constants are available (e.g. Metazoa),
# and only for non-default protein trees that lack a stable ID.
require EnsEMBL::Web::Component::Gene::ComparaOrthologs;
if (defined $EnsEMBL::Web::Component::Gene::ComparaOrthologs::GENE_TREE_CONSTANTS) {
my $gene_tree_constants = $EnsEMBL::Web::Component::Gene::ComparaOrthologs::GENE_TREE_CONSTANTS;
if (defined $gene_tree_constants) {
my $clusterset_id = $tree->tree->clusterset_id;
if (exists $gene_tree_constants->{$clusterset_id}) {
my $clusterset_specific_action = $gene_tree_constants->{$clusterset_id}{url_part};
if (defined $clusterset_specific_action) {
$action = $clusterset_specific_action;
}
}
}
}

$that_subtree_link = $hub->url({
species => $species,
type => 'Gene',
action => $action,
action => $gene_tree_constants->{action},
__clear => 1,
g => $link_gene->stable_id,
});
Expand Down Expand Up @@ -387,11 +371,13 @@ sub content {
my $params = {
'type' => 'DataExport',
'action' => 'GeneTree',
'cdb' => $cdb,
'data_type' => 'Gene',
'component' => 'ComparaTree',
'component' => $gene_tree_constants->{component},
'gene_name' => $gene_name,
'align' => 'tree',
'node' => $node_id,
'strain' => $is_strain,
};

$self->add_entry({
Expand Down