From d5e73c6ee6eda666d63a3951ddddc0f253321a1a Mon Sep 17 00:00:00 2001 From: Kieron Taylor <ktaylor@ebi.ac.uk> Date: Wed, 15 May 2013 16:27:48 +0000 Subject: [PATCH] Added a method that lists the species in available databases. Ancestral_ are ignored, and the list is filtered to a group type, defaulting to core dbs. Testcase is less than perfect, because the test db has so few species in it. --- modules/Bio/EnsEMBL/Registry.pm | 26 ++++++++++++++++++++++++++ modules/t/registry.t | 6 ++++++ 2 files changed, 32 insertions(+) diff --git a/modules/Bio/EnsEMBL/Registry.pm b/modules/Bio/EnsEMBL/Registry.pm index 45c1d2315c..19ff9a40ce 100644 --- a/modules/Bio/EnsEMBL/Registry.pm +++ b/modules/Bio/EnsEMBL/Registry.pm @@ -2663,6 +2663,32 @@ sub version_check { return 1; # Ok } ## end sub version_check +=head2 get_all_species + + Arg [1] : String group type, such as core, or otherfeatures + Description: Method for getting all valid species names found in available + databases. This excludes the ancestral sequence databases, and + any species from a non-core database. Specifying a group allows + the list to apply to non-core database types. + Example : my @species_names = @{ $reg->get_all_species() }; + Returntype : Listref of species names + +=cut + +sub get_all_species { + my ($self,$group) = @_; + $group ||= 'core'; + my @species; + foreach my $name (keys %{$registry_register{_SPECIES}}) { + push @species, $name if ( + # limit species names to given db group and no ancestral dbs + $registry_register{_SPECIES}->{$name}->{$group} + && $name !~ /^ancestral/i + ); + } + return \@species; +} + =head2 get_species_and_object_type diff --git a/modules/t/registry.t b/modules/t/registry.t index 3f13480287..86fd82ebef 100644 --- a/modules/t/registry.t +++ b/modules/t/registry.t @@ -97,4 +97,10 @@ TMPL $tester->('verison'); } +# Test get_all_species + +my @species = $reg->get_all_species(); +ok(scalar(@species) == 1, "get_all_species"); +ok(scalar(@{ $reg->get_all_species('cahoona') }) == 0, "get_all_species with bogus data."); + done_testing(); \ No newline at end of file -- GitLab