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

Fixing get_Species() and making sure it doesn't give back "bad" data

parent 92a4d495
No related branches found
No related tags found
No related merge requests found
......@@ -158,9 +158,17 @@ sub get_Species {
if ( !@$classification ) {
return undef;
}
#Re-create the old classification data structure by adding the scientific
#name back onto the classification but with species before genus e.g.
# sapiens -> Homo -> Hominade
my $scientific_name = $self->get_scientific_name();
my ($genus, @sp) = split(/ /, $scientific_name);
unshift(@{$classification}, join(q{ }, @sp), $genus);
my $species = Bio::Species->new();
$species->common_name($common_name);
$species->classification($classification, 1); #always force it
return $species;
......
use strict;
use warnings;
use Data::Dumper;
BEGIN { $| = 1;
use Test;
plan tests => 10;
}
use Test::More;
use Bio::EnsEMBL::Test::TestUtils;
use Bio::EnsEMBL::Test::MultiTestDB;
......@@ -69,5 +63,17 @@ $mc->store_key_value('species.division',$divname);
$div = $mc->get_division();
ok($div eq $divname);
#
# Testing get_Species()
#
capture_std_streams(sub {
my ($stdout_ref, $stderr_ref) = @_;
my $s = $mc->get_Species();
is($s->binomial(), 'Homo sapiens', 'Checking binomial from Bio::Species continues to work');
like(${$stderr_ref}, qr/.+ deprecated .+ get_scientific_name\(\)/xms, 'Make sure we warn about deprecation');
});
$mdb->restore('core', 'meta');
done_testing();
\ No newline at end of file
......@@ -7,8 +7,6 @@
29 1 species.classification Primates
28 1 species.classification Catarrhini
27 1 species.classification Hominidae
26 1 species.classification Homo
25 1 species.classification sapiens
34 1 species.classification Metazoa
35 1 species.classification Eukaryota
36 1 species.common_name Human
......
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