Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed bug where taxon rank was missing

+ more tests for Bio::DB::Taxonomy::list
  • Loading branch information...
commit 168c0982769450113fe14d62c81774c746e9d504 1 parent 35f1b07
@fangly fangly authored
Showing with 11 additions and 5 deletions.
  1. +2 −2 Bio/DB/Taxonomy/list.pm
  2. +9 −3 t/RemoteDB/Taxonomy.t
View
4 Bio/DB/Taxonomy/list.pm
@@ -233,12 +233,12 @@ sub add_lineage {
my $next_num = ++$self->{node_ids};
$node_id = $prefix.$next_num;
push @{$self->{name_to_id}->{$name}}, $node_id;
- $self->{node_data}->{$node_id} = [$name];
+ $self->{node_data}->{$node_id}->[0] = $name;
}
if ( (defined $rank) && (not defined $node_data->{$node_id}->[1]) ) {
# Save rank if node in database has no rank but the current node has one
- $node_data->{$node_id}->[1] = $rank;
+ $self->{node_data}->{$node_id}->[1] = $rank;
}
if ($my_ancestor_id) {
View
12 t/RemoteDB/Taxonomy.t
@@ -7,7 +7,7 @@ BEGIN {
use lib '.';
use Bio::Root::Test;
- test_begin(-tests => 155,
+ test_begin(-tests => 159,
-requires_module => 'XML::Twig');
use_ok('Bio::DB::Taxonomy');
@@ -164,11 +164,16 @@ ok $db_list = Bio::DB::Taxonomy->new(
);
is $db_list->get_num_taxa, 4;
+my @taxa;
+ok @taxa = map {$db_list->get_taxon(-name=>$_)} @h_lineage;
+is_deeply [map {ref($_)} @taxa], [('Bio::Taxon')x4];
+is_deeply [map {$_->rank} @taxa], \@ranks, 'Ranks';
+
@h_lineage = ('Eukaryota', 'Mammalia', 'Homo', 'Homo erectus');
$db_list->add_lineage(-names => \@h_lineage, -ranks => \@ranks);
-ok my @taxa = map {$db_list->get_taxon(-name=>$_)} @h_lineage;
-is_deeply [map {ref($_)} @taxa], ['Bio::Taxon','Bio::Taxon','Bio::Taxon','Bio::Taxon'];
+ok @taxa = map {$db_list->get_taxon(-name=>$_)} @h_lineage;
+is_deeply [map {ref($_)} @taxa], [('Bio::Taxon')x4];
is_deeply [map {$_->rank} @taxa], \@ranks, 'Ranks';
# Make a tree
@@ -316,6 +321,7 @@ $db_list->add_lineage(-names => [
maculipennis group, maculipennis species complex, Anopheles labranchiae"))]);
my $node = $db_list->get_taxon(-name => 'Anopheles labranchiae');
is $node->ancestor->ancestor->ancestor->ancestor->ancestor->ancestor->ancestor->scientific_name, 'Anophelinae';
+is $node->rank, undef;
# missing 'subgenus' Anopheles
$db_list->add_lineage(-names => [

0 comments on commit 168c098

Please sign in to comment.
Something went wrong with that request. Please try again.