How To Traverse A Newick Tree Bottom-Up?
1
0
Entering edit mode
11.6 years ago
sayonidas03 ▴ 100

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?

phylogenetics tree perl • 3.9k views
ADD COMMENT
2
Entering edit mode
11.6 years ago

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 COMMENT

Login before adding your answer.

Traffic: 1320 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6