[ensembl-dev] protein tree id and tagvalue

Moretti Sébastien sebastien.moretti at unil.ch
Wed Jul 4 14:37:15 BST 2012


There is still something wrong.
Each recursive call on split_tree calls always the same first children 
of the tree root, producing an infinite loop.

Here is part of my code:

For a particular tree:
my $tree_adaptor = $reg->get_adaptor('Multi', 'compara', 'GeneTree');
my $tree    = $tree_adaptor->fetch_by_root_id(487410); # example

my $tax_level = $tree->root->get_tagvalue('taxon_name');

...
# If tax_level is not Euteleostomi
...
split_tree($tree);


sub split_tree {
     my ($tree) = @_;

     my @children = @{$tree->root->sorted_children()};
     for my $subtree ( @children ){
         my $tax_level = $tree->get_tagvalue('taxon_name');
         ...
         # If tax_level is not Euteleostomi
         split_tree($subtree);
     }
}


> "->root", called on any node of a tree, will return the root node of
> that tree. That's why you keep getting the taxon_name of the root in
> your example. Simply remove "->root" and directly use
> $subtree->get_tagvalue('taxon_name')
>
> If the sub-tree is not in the expected clade, you can recursively call
> $subtree->children
>
> Regards
> Matthieu

-- 
Sébastien Moretti
Department of Ecology and Evolution,
Biophore, University of Lausanne,
CH-1015 Lausanne, Switzerland
Tel.: +41 (21) 692 4221/4079
http://selectome.unil.ch/ http://bgee.unil.ch/






More information about the Dev mailing list