2 package CXGN
::Phylo
::Ortholog_group_factory
;
9 my $self = bless $args, $class;
11 my @ortholog_groups = $self->collect_orthologs($tree->get_root());
16 sub collect_orthologs
{
19 my $ortho_groups_ref = shift;
20 my $ortho_tree_ref = shift;
22 # test if we have a subtree that contains orthologs... that's the case
23 # when the subtree_species_count is equal to the subtree_node_count.
25 if ($node->get_subtree_species_count() == $node->get_subtree_node_count()) {
26 #print STDERR "Found ortholog group starting at node ". $node->get_name()."\n";
28 # collect all the leaves in that subtree
30 my @orthologs = $node->recursive_leaf_list();
31 push @
$ortho_groups_ref, \
@orthologs;
32 #print STDERR "Done collecting ".scalar(@orthologs)." subnodes.\n";
34 # now we also want the actual subtree so that we can compare it to the
35 # species tree. First, copy the subtree.
36 #print STDERR "Getting the subtree...\n";
37 my $new_tree = CXGN
::Phylo
::Tree
->new();
38 my $new_root = $node->recursive_copy(undef, $new_tree);
40 $new_tree->set_root($new_root);
42 push @
$ortho_tree_ref, $new_tree;
44 return ($ortho_groups_ref, $ortho_tree_ref);
47 foreach my $c ($node->get_children()) {
48 #print STDERR "Testing child node ".$c->get_name()." for orthology.\n";
49 my ($children_ortho_groups_ref, $children_ortho_trees_ref) = $self->collect_orthologs($node);
50 foreach my $ref (@
$children_ortho_groups_ref) {
51 #print STDERR "Adding subnodes...\n";
52 push @
$ortho_groups_ref, $ref;
54 foreach my $ref (@
$children_ortho_trees_ref) {
55 #print STDERR "Adding subtree to ortholog tree list...\n";
56 push @
$ortho_tree_ref, $ref;
60 #print STDERR "Returning.\n";
61 return ($ortho_groups_ref, $ortho_tree_ref);