My question should be simple. I am looking to remove nodes from a phylogenetic tree. The splice function in bioperl should presumably take both the node ids or the node pointers. I have tried to include or and not include the root, yet I cannot get this function work. At first I created an array of nodes that I wanted to keep, but I have since reverted to trying to keep all the nodes and just trying to get the splice function to work.
Any help would be greatly appreciated.
Thank you!
#!/usr/bin/env perl + use strict; use warnings; use Bio::TreeIO; use Bio::Tree::TreeFunctionsI; use Bio::Tree::Tree; use Data::Dumper; use Bio::Seq; use Bio::SeqIO; use Bio::Tree::Node; my $usage = "usage: $0 treeFile \n"; my $treeFile = $ARGV[0] or die $usage; my @stored; my $treeio = new Bio::TreeIO('-format' => 'newick', '-file' => $treeFile); my $tree = $treeio->next_tree(); my $root_node = $tree->get_root_node; my @nodes = $tree->get_nodes(); #push (@nodes, $root_node); $tree->splice(-keep_node => \@nodes); exit(0);
I get the following error:
--------------------- WARNING ---------------------
MSG: Requested to remove everything except certain nodes, but those nodes were not found; doing nothing instead
---------------------------------------------------
When I just print the node ids, it works fine and I can get the node ids or the pointers:
my $tree = $treeio->next_tree(); my $root_node = $tree->get_root_node; my @nodes = $tree->get_nodes(); foreach my $my_node (@nodes){ print $my_node->id(); print "\n"; }
In reply to Splice Function for Bioperl Tree editing by xela07
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |