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

[ENSCORESW-473]. Adding a fetch all CoordSystems by version for regulation.

parent 55faf258
No related branches found
No related tags found
No related merge requests found
......@@ -516,9 +516,31 @@ sub fetch_all_by_name {
return $self->{'_name_cache'}->{$name} || [];
}
=head2 fetch_all_by_version
Arg [1] : string $version
The version of the coordinate systems to retrieve.
Example : foreach my $cs (@{$csa->fetch_all_by_version('GRCh37')}){
print $cs->name(), ' ', $cs->version();
}
Description: Retrieves all coordinate systems of a particular version
Returntype : ArrayRef of Bio::EnsEMBL::CoordSystem objects
Exceptions : throw if no name argument provided
Caller : general
Status : Stable
=cut
sub fetch_all_by_version {
my ($self, $version) = @_;
throw "Version argument is required" if ! $version;
my $coord_systems = [
grep { $_->version() eq $version }
map { $self->{_rank_cache}->{$_} }
sort keys %{$self->{_rank_cache}}
];
return $coord_systems;
}
=head2 fetch_by_dbID
......
......@@ -3,6 +3,7 @@ use strict;
use Test::More;
use Bio::EnsEMBL::Test::MultiTestDB;
use Bio::EnsEMBL::Test::TestUtils;
use Test::Exception;
our $verbose = 1; #set to 1 to turn on debug printouts
......@@ -176,6 +177,27 @@ ok( @{$new_path} == 2 &&
my $new_paths2 = $csa->store_mapping_path( $cs, $cln_cs );
ok( @{$new_paths2} == 0 ); # Should not update second time round
#
# Do some inserting of mock coord systems and
# do version retrieval
#
my $newcs_two = Bio::EnsEMBL::CoordSystem->new(
-NAME => 'newsystem_number_two',
-VERSION => 'NCBI35',
-DEFAULT => 0,
-SEQUENCE_LEVEL => 0,
-RANK => 11
);
$csa->store($newcs_two);
dies_ok { $csa->fetch_all_by_version() } 'fetch_all_by_version should die if not given a version to check';
is_deeply($csa->fetch_all_by_version('NCBI35'), [ $cs, $newcs_two ], 'Checking version rank retrieval works');
is_deeply(
$csa->fetch_all_by_version('NCBI33'),
[$csa->fetch_by_name('chromosome')],
'Retrieval by name should return the same as version for NCBI33');
is_deeply($csa->fetch_all_by_version('thisdoesnotexist'), [], 'Bogus coordinate system results in no results');
$multi->restore('core', 'coord_system');
$multi->restore('core', 'meta');
......
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