Skip to content
Snippets Groups Projects
Commit c71041df authored by Andy Yates's avatar Andy Yates
Browse files

[ENSCORESW-774]. Better default compara now chosen.

We had an error whenever we used the ensembl genomes species with the
multi databases from compara. Our best guess compara DB was switching
to the division’s compara DB rather than using multi. We now avoid
that problem by giving a default. So we will still try to use the
division’s DB but the lack of it will result in the correct results
being passed back.
parent 73a05b40
No related branches found
No related tags found
No related merge requests found
......@@ -170,6 +170,16 @@ msgpack=0 # control usage of Data::MessagePack as a serialisation option
max_slice_length = 5e6
</Controller::Feature>
<Controller::Compara>
# Sets the default compara to use when finding the best compara fails. Defaults to multi
# default_compara=multi
</Controller::Compara>
<Controller::GenomicAlignment>
# Sets the default compara to use when finding the best compara fails. Defaults to multi
# default_compara=multi
</Controller::GenomicAlignment>
<View::GFF3>
# Set the default source of a GFF3 record
# default_source=.
......
......@@ -36,7 +36,7 @@ sub get_adaptors :Private {
try {
my $species = $c->stash()->{species};
my $compara_dba = $c->model('Registry')->get_best_compara_DBAdaptor($species, $c->request()->param('compara'));
my $compara_dba = $c->model('Registry')->get_best_compara_DBAdaptor($species, $c->request()->param('compara'), $self->default_compara());
my $gma = $compara_dba->get_GeneMemberAdaptor();
my $sma = $compara_dba->get_SeqMemberAdaptor();
my $ha = $compara_dba->get_HomologyAdaptor();
......
......@@ -24,6 +24,7 @@ require EnsEMBL::REST;
BEGIN { extends 'Catalyst::Controller::REST'; }
has 'default_compara' => ( is => 'ro', isa => 'Str', default => 'multi' );
has 'max_slice_length' => ( isa => 'Num', is => 'ro', default => 1e6);
sub get_adaptors :Private {
......@@ -31,7 +32,7 @@ sub get_adaptors :Private {
try {
my $species = $c->stash()->{species};
my $compara_dba = $c->model('Registry')->get_best_compara_DBAdaptor($species, $c->request()->param('compara'));
my $compara_dba = $c->model('Registry')->get_best_compara_DBAdaptor($species, $c->request()->param('compara'), $self->default_compara());
my $mlssa = $compara_dba->get_MethodLinkSpeciesSetAdaptor();
my $gdba = $compara_dba->get_GenomeDBAdaptor();
my $asa = $compara_dba->get_AlignSliceAdaptor();
......
......@@ -198,13 +198,30 @@ sub _build_lookup {
return Bio::EnsEMBL::LookUp->new(%args);
}
# Logic here is if we were told a compara name we use that
# If not we query the species for the "best" compara (normally depends on division)
# If no hit and the queried name was different from the default name then try that
# Return if we got a hit otherwise throw an error
sub get_best_compara_DBAdaptor {
my ($self, $species, $request_compara_name) = @_;
my ($self, $species, $request_compara_name, $default_compara) = @_;
$default_compara = 'multi' if ! defined $default_compara;
my $compara_name = $request_compara_name || $self->get_compara_name_for_species($species);
if(!$compara_name) {
throw "Cannot find a suitable compara database for the species $species. Try specifying a compara parameter";
}
return $self->get_DBAdaptor($compara_name, 'compara');
my $dba = $self->get_DBAdaptor($compara_name, 'compara', 'no alias check');
# If the compara name we used was not the same then we've got another bite at the cherry
if(! $dba && $compara_name ne $default_compara) {
$dba = $self->get_DBAdaptor($default_compara, 'compara', 'no alias check');
}
# Throw an error if we had no DBAdaptor
if(!$dba) {
throw "Cannot find a database adaptor for $compara_name or $default_compara. Please contact the server admin with this error message and URL";
}
return $dba;
}
sub get_DBAdaptor {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment