Commit 5e1c558c authored by Andy Yates's avatar Andy Yates
Browse files

[ENSCORESW-578]. First commit of the switchable adaptors.

Now supports a very basic mechanism of switching in replacement
adaptors into the registry.
parent fc6f84e5
......@@ -61,10 +61,11 @@ use Bio::EnsEMBL::DBSQL::BaseFeatureAdaptor;
use Bio::EnsEMBL::Utils::SeqRegionCache;
use Bio::EnsEMBL::Utils::Exception qw(throw warning deprecate);
use Bio::EnsEMBL::Utils::Argument qw(rearrange);
use Bio::EnsEMBL::Registry;
use Bio::EnsEMBL::Utils::Scalar qw(check_ref scope_guard);
use Bio::EnsEMBL::Utils::ConfigRegistry;
my $reg = "Bio::EnsEMBL::Registry";
my $REGISTRY = "Bio::EnsEMBL::Registry";
require Bio::EnsEMBL::Registry;
=head2 new
......@@ -125,7 +126,7 @@ sub new {
my $self = bless {}, $class;
my ( $is_multispecies, $species, $species_id, $group, $con, $dnadb,
$no_cache, $dbname )
$no_cache, $dbname)
= rearrange( [
'MULTISPECIES_DB', 'SPECIES', 'SPECIES_ID', 'GROUP',
'DBCONN', 'DNADB', 'NO_CACHE', 'DBNAME'
......@@ -141,16 +142,11 @@ sub new {
$self->dbc( new Bio::EnsEMBL::DBSQL::DBConnection(@args) );
}
if ( defined($species) ) { $self->species($species) }
if ( defined($group) ) { $self->group($group) }
if ( defined($species) ) { $self->species($species) }
if ( defined($group) ) { $self->group($group) }
$self = Bio::EnsEMBL::Utils::ConfigRegistry::gen_load($self);
# if(!defined($species) ){
# $reg->find_and_add_aliases($self);
# }
$self->species_id( $species_id || 1 );
$self->is_multispecies( defined($is_multispecies)
......@@ -176,7 +172,7 @@ sub new {
sub clear_caches {
my ($self) = @_;
my $adaptors = Bio::EnsEMBL::Registry->get_all_adaptors(
my $adaptors = $REGISTRY->get_all_adaptors(
$self->species(), $self->group());
foreach my $adaptor (@{$adaptors}) {
if($adaptor->can('clear_cache')) {
......@@ -214,8 +210,6 @@ sub dbc{
return $self->{_dbc};
}
=head2 add_db_adaptor
Arg [1] : string $name
......@@ -240,7 +234,7 @@ sub add_db_adaptor {
throw('adaptor and name arguments are required');
}
Bio::EnsEMBL::Registry->add_db($self, $name, $adaptor);
$REGISTRY->add_db($self, $name, $adaptor);
}
......@@ -262,8 +256,7 @@ sub add_db_adaptor {
sub remove_db_adaptor {
my ($self, $name) = @_;
return Bio::EnsEMBL::Registry->remove_db($self, $name);
return $REGISTRY->remove_db($self, $name);
}
......@@ -285,7 +278,7 @@ sub remove_db_adaptor {
sub get_all_db_adaptors {
my ($self) = @_;
return Bio::EnsEMBL::Registry->get_all_db_adaptors($self);
return $REGISTRY->get_all_db_adaptors($self);
}
......@@ -309,7 +302,7 @@ sub get_all_db_adaptors {
sub get_db_adaptor {
my ($self, $name) = @_;
return Bio::EnsEMBL::Registry->get_db($self, $name);
return $REGISTRY->get_db($self, $name);
}
=head2 get_available_adaptors
......@@ -324,39 +317,68 @@ sub get_db_adaptor {
=cut
sub get_available_adaptors {
my %pairs = (
my $adaptors = {
# Firstly those that just have an adaptor named after there object
# in the main DBSQL directory.
map( { $_ => "Bio::EnsEMBL::DBSQL::${_}Adaptor" } qw(
Analysis ArchiveStableId Attribute
AssemblyExceptionFeature AssemblyMapper CoordSystem
CompressedSequence DBEntry DnaAlignFeature
DensityFeature DensityType Exon
Gene KaryotypeBand MiscSet
MiscFeature PredictionTranscript PredictionExon
ProteinFeature ProteinAlignFeature RepeatConsensus
RepeatFeature Sequence SeqRegionSynonym SimpleFeature
Slice SupportingFeature Transcript
TranscriptSupportingFeature Translation UnmappedObject
UnconventionalTranscriptAssociation AssemblySlice
SplicingEvent SplicingEventFeature SplicingTranscriptPair
Operon OperonTranscript
DataFile Assembly
IntronSupportingEvidence AltAlleleGroup
) ),
AltAlleleGroup => 'Bio::EnsEMBL::DBSQL::AltAlleleGroupAdaptor',
Analysis => 'Bio::EnsEMBL::DBSQL::AnalysisAdaptor',
ArchiveStableId => 'Bio::EnsEMBL::DBSQL::ArchiveStableIdAdaptor',
Assembly => 'Bio::EnsEMBL::DBSQL::AssemblyAdaptor',
AssemblyExceptionFeature => 'Bio::EnsEMBL::DBSQL::AssemblyExceptionFeatureAdaptor',
AssemblyMapper => 'Bio::EnsEMBL::DBSQL::AssemblyMapperAdaptor',
AssemblySlice => 'Bio::EnsEMBL::DBSQL::AssemblySliceAdaptor',
Attribute => 'Bio::EnsEMBL::DBSQL::AttributeAdaptor',
CompressedSequence => 'Bio::EnsEMBL::DBSQL::CompressedSequenceAdaptor',
CoordSystem => 'Bio::EnsEMBL::DBSQL::CoordSystemAdaptor',
DataFile => 'Bio::EnsEMBL::DBSQL::DataFileAdaptor',
DBEntry => 'Bio::EnsEMBL::DBSQL::DBEntryAdaptor',
DensityFeature => 'Bio::EnsEMBL::DBSQL::DensityFeatureAdaptor',
DensityType => 'Bio::EnsEMBL::DBSQL::DensityTypeAdaptor',
DnaAlignFeature => 'Bio::EnsEMBL::DBSQL::DnaAlignFeatureAdaptor',
Exon => 'Bio::EnsEMBL::DBSQL::ExonAdaptor',
Gene => 'Bio::EnsEMBL::DBSQL::GeneAdaptor',
IntronSupportingEvidence => 'Bio::EnsEMBL::DBSQL::IntronSupportingEvidenceAdaptor',
KaryotypeBand => 'Bio::EnsEMBL::DBSQL::KaryotypeBandAdaptor',
MiscFeature => 'Bio::EnsEMBL::DBSQL::MiscFeatureAdaptor',
MiscSet => 'Bio::EnsEMBL::DBSQL::MiscSetAdaptor',
Operon => 'Bio::EnsEMBL::DBSQL::OperonAdaptor',
OperonTranscript => 'Bio::EnsEMBL::DBSQL::OperonTranscriptAdaptor',
PredictionExon => 'Bio::EnsEMBL::DBSQL::PredictionExonAdaptor',
PredictionTranscript => 'Bio::EnsEMBL::DBSQL::PredictionTranscriptAdaptor',
ProteinAlignFeature => 'Bio::EnsEMBL::DBSQL::ProteinAlignFeatureAdaptor',
ProteinFeature => 'Bio::EnsEMBL::DBSQL::ProteinFeatureAdaptor',
RepeatConsensus => 'Bio::EnsEMBL::DBSQL::RepeatConsensusAdaptor',
RepeatFeature => 'Bio::EnsEMBL::DBSQL::RepeatFeatureAdaptor',
SeqRegionSynonym => 'Bio::EnsEMBL::DBSQL::SeqRegionSynonymAdaptor',
Sequence => 'Bio::EnsEMBL::DBSQL::SequenceAdaptor',
SimpleFeature => 'Bio::EnsEMBL::DBSQL::SimpleFeatureAdaptor',
Slice => 'Bio::EnsEMBL::DBSQL::SliceAdaptor',
SplicingEvent => 'Bio::EnsEMBL::DBSQL::SplicingEventAdaptor',
SplicingEventFeature => 'Bio::EnsEMBL::DBSQL::SplicingEventFeatureAdaptor',
SplicingTranscriptPair => 'Bio::EnsEMBL::DBSQL::SplicingTranscriptPairAdaptor',
SupportingFeature => 'Bio::EnsEMBL::DBSQL::SupportingFeatureAdaptor',
Transcript => 'Bio::EnsEMBL::DBSQL::TranscriptAdaptor',
TranscriptSupportingFeature => 'Bio::EnsEMBL::DBSQL::TranscriptSupportingFeatureAdaptor',
Translation => 'Bio::EnsEMBL::DBSQL::TranslationAdaptor',
UnconventionalTranscriptAssociation => 'Bio::EnsEMBL::DBSQL::UnconventionalTranscriptAssociationAdaptor',
UnmappedObject => 'Bio::EnsEMBL::DBSQL::UnmappedObjectAdaptor',
# Those whose adaptors are in Map::DBSQL
map( { $_ => "Bio::EnsEMBL::Map::DBSQL::${_}Adaptor" } qw(
Marker MarkerFeature QtlFeature Qtl Ditag DitagFeature
) ),
Ditag => 'Bio::EnsEMBL::Map::DBSQL::DitagAdaptor',
DitagFeature => 'Bio::EnsEMBL::Map::DBSQL::DitagFeatureAdaptor',
Marker => 'Bio::EnsEMBL::Map::DBSQL::MarkerAdaptor',
MarkerFeature => 'Bio::EnsEMBL::Map::DBSQL::MarkerFeatureAdaptor',
Qtl => 'Bio::EnsEMBL::Map::DBSQL::QtlAdaptor',
QtlFeature => 'Bio::EnsEMBL::Map::DBSQL::QtlFeatureAdaptor',
# Finally the exceptions... those that have non-standard mapping
# between object / adaptor ....
# 'Blast' => 'Bio::EnsEMBL::External::BlastAdaptor',
'MetaCoordContainer' => 'Bio::EnsEMBL::DBSQL::MetaCoordContainer',
'MetaContainer' => 'Bio::EnsEMBL::DBSQL::MetaContainer',
'SNP' => 'Bio::EnsEMBL::DBSQL::ProxySNPAdaptor',
);
return ( \%pairs );
# Blast => 'Bio::EnsEMBL::External::BlastAdaptor',
MetaContainer => 'Bio::EnsEMBL::DBSQL::MetaContainer',
MetaCoordContainer => 'Bio::EnsEMBL::DBSQL::MetaCoordContainer',
SNP => 'Bio::EnsEMBL::DBSQL::ProxySNPAdaptor',
};
return $adaptors;
} ## end sub get_available_adaptors
###########################################################
......@@ -555,7 +577,7 @@ sub add_ExternalFeatureFactory{
sub get_adaptor {
my ($self, $canonical_name, @other_args) = @_;
return $reg->get_adaptor($self->species(),$self->group(),$canonical_name);
return $REGISTRY->get_adaptor($self->species(),$self->group(),$canonical_name);
}
......@@ -580,7 +602,7 @@ sub get_adaptor {
sub set_adaptor {
my ($self, $canonical_name, $module) = @_;
$reg->add_adaptor($self->species(),$self->group(),$canonical_name,$module);
$REGISTRY->add_adaptor($self->species(),$self->group(),$canonical_name,$module);
return $module;
}
......@@ -694,30 +716,10 @@ sub species {
sub all_species {
my ($self) = @_;
if ( !$self->is_multispecies() ) { return [ $self->species() ] }
if ( exists( $self->{'_all_species'} ) ) {
return $self->{'_all_species'};
}
my $statement =
"SELECT meta_value "
. "FROM meta "
. "WHERE meta_key = 'species.db_name'";
my $sth = $self->dbc()->db_handle()->prepare($statement);
$sth->execute();
my $species;
$sth->bind_columns( \$species );
my @all_species;
while ( $sth->fetch() ) { push( @all_species, $species ) }
$self->{'_all_species'} = \@all_species;
return $self->{'_all_species'} if exists $self->{_all_species};
my $sql = "SELECT meta_value FROM meta WHERE meta_key = 'species.db_name'";
$self->{_all_species} = $self->dbc->sql_helper()->execute_simple(-SQL => $sql);
return $self->{'_all_species'};
} ## end sub all_species
......@@ -895,11 +897,11 @@ sub dnadb {
if(@_) {
my $arg = shift;
$reg->add_DNAAdaptor($self->species(),$self->group(),$arg->species(),$arg->group());
$REGISTRY->add_DNAAdaptor($self->species(),$self->group(),$arg->species(),$arg->group());
}
# return $self->{'dnadb'} || $self;
return $reg->get_DNAAdaptor($self->species(),$self->group()) || $self;
return $REGISTRY->get_DNAAdaptor($self->species(),$self->group()) || $self;
}
......@@ -917,7 +919,7 @@ sub AUTOLOAD {
throw( sprintf( "Could not work out type for %s\n", $AUTOLOAD ) );
}
my $ret = $reg->get_adaptor( $self->species(), $self->group(), $type );
my $ret = $REGISTRY->get_adaptor( $self->species(), $self->group(), $type );
return $ret if $ret;
......@@ -957,6 +959,88 @@ sub to_hash {
return $hash;
}
#########################
# Switchable adaptor methods
#########################
=head2 switch_adaptor
Arg [1] : String name of the adaptor type to switch out
Arg [2] : Reference The switchable adaptor implementation
Arg [3] : (optional) CodeRef Callback which provides automatic switchable adaptor cleanup
once the method has finished
Arg [4] : (optional) Boolean override any existing switchable adaptor
Example : $dba->switch_adaptor("seqeunce", $my_replacement_sequence_adaptor);
$dba->switch_adaptor("seqeunce", $my_other_replacement_sequence_adaptor, 1);
$dba->switch_adaptor("seqeunce", $my_replacement_sequence_adaptor, sub {
#Make calls as normal without having to do manual cleanup
});
Returntype : None
Description : Provides a wrapper around the Registry add_switchable_adaptor() method
defaulting both species and group to the current DBAdaptor. Callbacks are
also available providing automatic resource cleanup.
The method also remembers the last switch you did. It will not remember
multiple switches though.
Exceptions : Thrown if no switchable adaptor instance was given
=cut
sub switch_adaptor {
my ($self, $adaptor_name, $instance, $callback, $force) = @_;
my ($species, $group) = ($self->species(), $self->group());
$REGISTRY->add_switchable_adaptor($species, $group, $adaptor_name, $instance, $force);
$self->{_last_switchable_adaptor} = $adaptor_name;
if(check_ref($callback, 'CODE')) {
#Scope guard will reset the adaptor once it falls out of scope. They
#are implemented as callback DESTROYS so are neigh on impossible
#to stop executing
my $guard = scope_guard(sub { $REGISTRY->remove_switchable_adaptor($species, $group, $adaptor_name); } );
$callback->();
}
return;
}
=head2 has_switched_adaptor
Arg [1] : String name of the adaptor type to switch back in
Example : $dba->has_switchable_adaptor("seqeunce"); #explicit switching back
Returntype : Boolean indicating if the given adaptor is being activly switched
Description : Provides a wrapper around the Registry has_switchable_adaptor() method
defaulting both species and group to the current DBAdaptor. This will
inform if the specified adaptor is being switched out
Exceptions : None
=cut
sub has_switched_adaptor {
my ($self, $adaptor_name) = @_;
return $REGISTRY->has_switchable_adaptor($self->species, $self->group, $adaptor_name);
}
=head2 revert_adaptor
Arg [1] : (optional) String name of the adaptor type to switch back in
Example : $dba->revert_adaptor(); #implicit switching back whatever was the last switch_adaptor() call
$dba->revert_adaptor("seqeunce"); #explicit switching back
Returntype : The removed adaptor
Description : Provides a wrapper around the Registry remove_switchable_adaptor() method
defaulting both species and group to the current DBAdaptor. This will remove
a switchable adaptor. You can also remove the last adaptor you switched
in without having to specify any parameter.
Exceptions : Thrown if no switchable adaptor name was given or could be found in the internal
last adaptor variable
=cut
sub revert_adaptor {
my ($self, $adaptor_name) = @_;
$adaptor_name ||= $self->{_last_switchable_adaptor};
throw "Not given an adaptor name to remove and cannot find the name of the last switched adaptor" if ! $adaptor_name;
my $deleted_adaptor = $REGISTRY->remove_switchable_adaptor($self->species, $self->group, $adaptor_name);
delete $self->{last_switch};
return $deleted_adaptor;
}
#########################
# sub DEPRECATED METHODS
......
......@@ -134,6 +134,8 @@ use Bio::EnsEMBL::Utils::URI qw/parse_uri/;
use DBI qw(:sql_types);
use Scalar::Util qw/blessed/;
use vars qw(%registry_register);
# This is a map from group names to Ensembl DB adaptors. Used by
......@@ -909,6 +911,8 @@ sub add_adaptor {
my ( $class, $species, $group, $type, $adap, $reset ) = @_;
$species = $class->get_alias($species);
my $lc_group = lc($group);
my $lc_type = lc($type);
# Since the adaptors are not stored initially, only their class paths
# when the adaptors are obtained, we need to store these instead. It
......@@ -918,52 +922,151 @@ sub add_adaptor {
if ( defined($reset) )
{ # JUST RESET THE HASH VALUE NO MORE PROCESSING NEEDED
$registry_register{_SPECIES}{$species}{ lc($group) }{ lc($type) } =
$adap;
$registry_register{_SPECIES}{$species}{ $lc_group }{ $lc_type } = $adap;
return;
}
if (
defined(
$registry_register{_SPECIES}{$species}{ lc($group) }{ lc($type) }
$registry_register{_SPECIES}{$species}{ $lc_group }{ $lc_type }
) )
{
# print STDERR (
# "Overwriting Adaptor in Registry for $species $group $type\n");
$registry_register{_SPECIES}{$species}{ lc($group) }{ lc($type) } =
$adap;
$registry_register{_SPECIES}{$species}{ $lc_group }{ $lc_type } = $adap;
return;
}
$registry_register{_SPECIES}{$species}{ lc($group) }{ lc($type) } =
$adap;
$registry_register{_SPECIES}{$species}{ $lc_group }{ $lc_type } = $adap;
if ( !defined( $registry_register{_SPECIES}{$species}{'list'} ) ) {
$registry_register{_SPECIES}{$species}{'list'} = [$type];
} else {
}
else {
push( @{ $registry_register{_SPECIES}{$species}{'list'} }, $type );
}
if ( !defined( $registry_register{_TYPE}{ lc($type) }{$species} ) ) {
$registry_register{_TYPE}{ lc($type) }{$species} = [$adap];
} else {
push( @{ $registry_register{_TYPE}{ lc($type) }{$species} },
$adap );
if ( !defined( $registry_register{_TYPE}{ $lc_type }{$species} ) ) {
$registry_register{_TYPE}{ $lc_type }{$species} = [$adap];
}
else {
push( @{ $registry_register{_TYPE}{ $lc_type }{$species} }, $adap );
}
return;
} ## end sub add_adaptor
=head2 get_adaptor
=head2 add_switchable_adaptor
Arg [1] : name of the species to add the adaptor to in the registry.
Arg [2] : name of the group to add the adaptor to in the registry.
Arg [3] : name of the type to add the adaptor to in the registry.
Example : $adap = Bio::EnsEMBL::Registry->get_adaptor("Human", "core", "Gene");
Returntype : adaptor
Arg [1] : String name of the species to add its switchable adaptor into the registry
Arg [2] : String name of the group to add its switchable adaptor into the registry
Arg [3] : String name of the type to add its switchable adaptor into the registry
Arg [4] : Reference switchable adaptor to insert
Arg [5] : Boolean override any existing switchable adaptor
Example : Bio::EnsEMBL::Registry->add_switchable_adaptor("Human", "core", "Gene", $my_other_source);
Returntype : None
Exceptions : Thrown if a valid internal name cannot be found for the given
name. If thrown check your API and DB version. Also thrown if
no type, group or switchable adaptor instance was given
=cut
sub add_switchable_adaptor {
my ($class, $species, $group, $adaptor_type, $instance, $override) = @_;
my $ispecies = $class->get_alias($species);
throw "Cannot decode given species ${species} to an internal registry name" if ! $species;
throw "No group given" if ! $group;
throw "No adaptor type given" if ! $adaptor_type;
throw "No switchable adaptor given" if ! $instance;
throw "Switchable adaptor was not a blessed reference" if ! blessed($instance);
$group = lc($group);
$adaptor_type = lc($adaptor_type);
if($override) {
$registry_register{_SWITCHABLE}{$species}{$group}{$adaptor_type} = $instance;
return;
}
if(exists $registry_register{_SWITCHABLE}{$species}{$group}{$adaptor_type}) {
my $existing_ref = ref($registry_register{_SWITCHABLE}{$species}{$group}{$adaptor_type});
throw "Cannot switch adaptors for ${species}, ${group} and ${adaptor_type} because one is already set ($existing_ref). Use the override flag or revert_switchable_adaptor";
}
$registry_register{_SWITCHABLE}{$species}{$group}{$adaptor_type} = $instance;
return;
}
=head2 has_switchable_adaptor
Arg [1] : String name of the species to add its switchable adaptor into the registry
Arg [2] : String name of the group to add its switchable adaptor into the registry
Arg [3] : String name of the type to add its switchable adaptor into the registry
Example : Bio::EnsEMBL::Registry->has_switchable_adaptor("Human", "core", "Gene");
Returntype : Boolean indicating if a switchable adaptor is available for your submitted combination
Exceptions : Thrown if a valid internal name cannot be found for the given
name. If thrown check your API and DB version. Also thrown if
no type, group or switchable adaptor instance was given
=cut
sub has_switchable_adaptor {
my ($class, $species, $group, $adaptor_type) = @_;
my $ispecies = $class->get_alias($species);
throw "Cannot decode given species ${species} to an internal registry name" if ! $species;
throw "No group given" if ! $group;
throw "No adaptor type given" if ! $adaptor_type;
$group = lc($group);
$adaptor_type = lc($adaptor_type);
return (defined $registry_register{_SWITCHABLE}{$species}{$group}{$adaptor_type}) ? 1 : 0;
}
=head2 remove_switchable_adaptor
Arg [1] : name of the species to remove its switchable adaptor from the registry
Arg [2] : name of the group to remove its switchable adaptor from the registry
Arg [3] : name of the type to remove its switchable adaptor from the registry
Example : $adap = Bio::EnsEMBL::Registry->remove_switchable_adaptor("Human", "core", "Gene");
Returntype : The removed adaptor if one was removed. Otherwise undef
Exceptions : Thrown if a valid internal name cannot be found for the given
name. If thrown check your API and DB version. Also thrown if
no type or group was given
Status : Stable
=cut
sub remove_switchable_adaptor {
my ($class, $species, $group, $adaptor_type) = @_;
my $ispecies = $class->get_alias($species);
throw "Cannot decode given species ${species} to an internal registry name" if ! $species;
throw "No group given" if ! $group;
throw "No adaptor type given" if ! $adaptor_type;
$group = lc($group);
$adaptor_type = lc($adaptor_type);
if(defined $registry_register{_SWITCHABLE}{$ispecies}{$group}{$adaptor_type}) {
my $adaptor = $registry_register{_SWITCHABLE}{$ispecies}{$group}{$adaptor_type};
delete $registry_register{_SWITCHABLE}{$ispecies}{$group}{$adaptor_type};
return $adaptor;
}
return;
}
=head2 get_adaptor
Arg [1] : name of the species to add the adaptor to in the registry.
Arg [2] : name of the group to add the adaptor to in the registry.
Arg [3] : name of the type to add the adaptor to in the registry.
Example : $adap = Bio::EnsEMBL::Registry->get_adaptor("Human", "core", "Gene");
Description : Finds and returns the specified adaptor. This method will also check
if the species, group and adaptor combination satisfy a DNADB condition
(and will return that DNADB's implementation). Also we check for
any available switchable adaptors and will return that if available.
Returntype : adaptor
Exceptions : Thrown if a valid internal name cannot be found for the given
name. If thrown check your API and DB version. Also thrown if
no type or group was given
Status : Stable
=cut
......@@ -979,6 +1082,9 @@ sub get_adaptor {
throw 'No adaptor group given' if ! defined $group;
throw 'No adaptor type given' if ! defined $type;
$group = lc($group);
my $lc_type = lc($type);
if($type =~ /Adaptor$/i) {
......@@ -986,43 +1092,50 @@ sub get_adaptor {
$type =~ s/Adaptor$//i;
}
# For historical reasons, allow use of group 'regulation' to refer to
# group 'funcgen'.
if ( $group eq 'regulation' ) { $group = 'funcgen' }
my %dnadb_adaptors = (
'sequence' => 1,
'assemblymapper' => 1,
'karyotypeband' => 1,
'repeatfeature' => 1,
'coordsystem' => ((lc($group) ne 'funcgen') ? 1 : undef),
'coordsystem' => (($group ne 'funcgen') ? 1 : undef),
'assemblyexceptionfeature' => 1
);
# warn "$species, $group, $type";
$type = lc($type);
# For historical reasons, allow use of group 'regulation' to refer to
# group 'funcgen'.
if ( lc($group) eq 'regulation' ) { $group = 'funcgen' }
#Before looking for DNA adaptors we need to see if we have a switchable adaptor since they take preference
if(defined $registry_register{_SWITCHABLE}{$species}{$group}{$lc_type}) {
return $registry_register{_SWITCHABLE}{$species}{$group}{$lc_type};
}
my $dnadb_group =
$registry_register{_SPECIES}{$species}{ lc($group) }{'_DNA'};
# Look for a possible DNADB group alongside the species hash
my $dnadb_group = $registry_register{_SPECIES}{$species}{ $group }{'_DNA'};
if ( defined($dnadb_group)
&& defined( $dnadb_adaptors{ lc($type) } ) )
{
$species =
$registry_register{_SPECIES}{$species}{ lc($group) }{'_DNA2'};
# If we found one & this is an adaptor we should be replaced by a DNADB then
# look up the species to use and replace the current group with the DNADB group
# (groups are held in _DNA, species are in _DNA2)
if ( defined($dnadb_group) && defined( $dnadb_adaptors{ $lc_type } ) ) {
$species = $registry_register{_SPECIES}{$species}{ $group }{'_DNA2'};
$group = $dnadb_group;
# Once we have switched to the possibility of a DNADB call now check again for
# a switchable adaptor
if(defined $registry_register{_SWITCHABLE}{$species}{$group}{$lc_type}) {
return $registry_register{_SWITCHABLE}{$species}{$group}{$lc_type};
}
}
my $ret =
$registry_register{_SPECIES}{$species}{ lc($group) }{ lc($type) };