HOWTO Discussion:Trees
From BioPerl
Could someone write documentation on how to read/write from a string, like in the HOWTO for SeqIO? Much appreciated. --Lskatz 20:31, 26 January 2011 (UTC)
It is just like read/write from a string in SeqIO
use warnings; use strict; use Bio::TreeIO; use IO::String; my $string = "(A,(B,C));"; my $io = IO::String->new($string); my $treeio = Bio::TreeIO->new(-fh => $io, -format => 'newick'); while( my $tree = $treeio->next_tree ) { # get a tree, print out number of total nodes print "node count is ", scalar $tree->get_nodes, "\n"; }