diff --git a/modules/Bio/EnsEMBL/Registry.pm b/modules/Bio/EnsEMBL/Registry.pm index 45c1d2315c9a42f3fc8170a1f2988e920ddbdc26..19ff9a40cea1cb4c57d9b0e853fd17b5decec682 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 3f13480287926803bb0f6f42a6dce259ba68e432..86fd82ebef553c8093002c94ba12a2209f29ba75 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