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

Hi,

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 http://doc.bioperl.org/bioperl-live/Bio/Tree/Compatible.html ) to traverse the tree bottom_up.

Am I in the right track at all?

perl phylogenetics tree • 2.8k views
ADD COMMENTlink modified 6.3 years ago by Biostar ♦♦ 20 • written 7.1 years ago by sayonidas03100
2
gravatar for Istvan Albert
7.1 years ago by
Istvan Albert ♦♦ 84k
University Park, USA
Istvan Albert ♦♦ 84k 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.

http://doc.bioperl.org/bioperl-live/Bio/Tree/Compatible.html#CODE1

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

Help
Access

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