Permalink
Browse files

Use list context instead of scalar context to include all taxa

  • Loading branch information...
1 parent b5256d6 commit 98defe8da4117c98fdbd045dc3d10ed328ce81b5 @fangly fangly committed Jun 24, 2013
Showing with 8 additions and 10 deletions.
  1. +8 −10 Bio/DB/Taxonomy.pm
View
@@ -200,22 +200,20 @@ sub get_tree {
# the full lineages of the species are merged into a single tree
my $tree;
- foreach my $name (@species_names) {
- my $ncbi_id = $self->get_taxonid($name);
- if ($ncbi_id) {
- my $node = $self->get_taxon(-taxonid => $ncbi_id);
+ for my $name (@species_names) {
+ my @ids = $self->get_taxonids($name);
+ if (not scalar @ids) {
+ $self->throw("No taxonomy database node for species ".$name);
+ }
+ for my $id (@ids) {
+ my $node = $self->get_taxon(-taxonid => $id);
$node->name('supplied', $name);
-
if ($tree) {
$tree->merge_lineage($node);
- }
- else {
+ } else {
$tree = Bio::Tree::Tree->new(-verbose => $self->verbose, -node => $node);
}
}
- else {
- $self->throw("No taxonomy database node for species ".$name);
- }
}
return $tree;

0 comments on commit 98defe8

Please sign in to comment.