[ensembl-dev] protein tree id and tagvalue

Matthieu Muffato muffato at ebi.ac.uk
Wed Jul 4 14:40:24 BST 2012


Because you call sorted_children() on the root node

On 04/07/12 14:37, Moretti Sébastien wrote:
> 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
>





More information about the Dev mailing list