Question: How To Traverse A Newick Tree Bottom-Up?
gravatar for sayonidas03
7.8 years ago by
London, U.K
sayonidas03100 wrote:


I have a sequence phylogenetic tree in Newick format (with branch lengths). I want to traverse the tree bottom-up in a Perl program and edit merging/splitting of nodes based on additional information. I have not done tree traversal before, hence I need some help/advice. This part of the code will give me a cluster representation of the nodes:

use Bio::TreeIO;
use Bio::Tree::Node;
use Bio::Tree::Tree;
use Bio::Tree::Compatible;
my $input = new Bio::TreeIO(-file   => "tree.fasttree",
                        -format => "newick");
my $tree = $input->next_tree;
map { print "(",join(',',@{$_}),")\n" } values %{Bio::Tree::Compatible::cluster_representation( $tree ) };

I want to know how to use information from the cluster_representation ( Bio::Tree::Compatible::cluster_representation code in ) to traverse the tree bottom_up.

Am I in the right track at all?

perl phylogenetics tree • 3.0k views
ADD COMMENTlink modified 6.9 years ago by Biostar ♦♦ 20 • written 7.8 years ago by sayonidas03100
gravatar for Istvan Albert
7.8 years ago by
Istvan Albert ♦♦ 86k
University Park, USA
Istvan Albert ♦♦ 86k wrote:

It is not obvious what "bottom-up" traversal means.

Some people call the postorder traversal as "bottom-up", is that what you mean? If so you are in luck as the class offers a postorder_traversal method.

ADD COMMENTlink written 7.8 years ago by Istvan Albert ♦♦ 86k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1010 users visited in the last hour