Permalink
Browse files

Adding arbitrary branch length in Bio::DB::Taxonomy::get_tree

  • Loading branch information...
1 parent 74eed3e commit 3317ea15d2977611898505403035389d5f5035a1 @fangly fangly committed Jun 24, 2013
Showing with 18 additions and 5 deletions.
  1. +7 −1 Bio/DB/Taxonomy.pm
  2. +1 −1 Bio/Taxon.pm
  3. +10 −3 t/RemoteDB/Taxonomy.t
View
@@ -189,7 +189,8 @@ sub get_taxonids {
species names. The nodes for the requested species are given
name('supplied') values corresponding to the supplied name, such that
they can be identified if the real species name in the database
- (stored under node_name()) is different.
+ (stored under node_name()) is different. The nodes are also given an
+ arbitrary branch length of 1.
Returns : Bio::Tree::Tree
Args : a list of species names (strings)
@@ -215,6 +216,11 @@ sub get_tree {
}
}
}
+
+ # add arbitrary branch length
+ for my $node ($tree->get_nodes) {
+ $node->branch_length(1);
+ }
return $tree;
}
View
@@ -602,7 +602,7 @@ sub get_Children_Nodes {
scientific name and common name, respectively. 'scientific' and
'division' are treated specially, allowing only the first value
in the Arg2 list to be set.
- Arg2 .. => list of names
+ Arg2 ... => list of names
=cut
View
@@ -7,7 +7,7 @@ BEGIN {
use lib '.';
use Bio::Root::Test;
- test_begin(-tests => 146,
+ test_begin(-tests => 150,
-requires_module => 'XML::Twig');
use_ok('Bio::DB::Taxonomy');
@@ -164,10 +164,17 @@ ok $db_list = Bio::DB::Taxonomy->new(
);
is $db_list->get_num_taxa, 4;
+@h_lineage = ('Eukaryota', 'Mammalia', 'Homo', 'Homo erectus');
+$db_list->add_lineage(-names => \@h_lineage, -ranks => \@ranks);
+
# Make a tree
-my $tree = $db_list->get_tree('Homo sapiens');
+my $tree = $db_list->get_tree('Homo sapiens', 'Homo erectus');
isa_ok $tree, 'Bio::Tree::TreeI';
-is $tree->number_nodes, 4;
+is $tree->number_nodes, 5;
+is $tree->total_branch_length, 4;
+ok my $node1 = $tree->find_node( -scientific_name => 'Homo sapiens' );
+ok my $node2 = $tree->find_node( -scientific_name => 'Homo erectus' );
+is $tree->distance($node1, $node2), 2;
ok my $h_list = $db_list->get_taxon(-name => 'Homo sapiens');
ok my $h_flat = $db_flatfile->get_taxon(-name => 'Homo sapiens');

0 comments on commit 3317ea1

Please sign in to comment.