[Bioperl-l] Bio::TreeIO - tree object to string

Kevin Brown Kevin.M.Brown at asu.edu
Mon Mar 10 16:17:11 UTC 2008


You need to either pass in a FileHandle or a path to an output file else
you are going to see the behavior you are getting.

open my $tree_string, ">TreeFile.txt";
my $out = new Bio::TreeIO(-fh => $tree_string, -format => 'newick');

OR

my $out = new Bio::TreeIO(-file => "TreeFile.txt", -format => 'newick');

> -----Original Message-----
> From: bioperl-l-bounces at lists.open-bio.org 
> [mailto:bioperl-l-bounces at lists.open-bio.org] On Behalf Of 
> Daniel Gerlach
> Sent: Monday, March 10, 2008 9:14 AM
> To: bioperl-l at portal.open-bio.org
> Subject: [Bioperl-l] Bio::TreeIO - tree object to string
> 
> Dear all,
> 
> This is a very basic question. I have a tree object in $tree 
> and want to 
> save its newick representation in a variable as a string:
> 
> my $out = new Bio::TreeIO(-fh => $tree_string, -format => 'newick');
> $out->write_tree($tree);
> print $tree_string;
> 
> Unfortunately this does not work and he prints out the newick tree on 
> stdout plus the message "Use of uninitialized value in print 
> at ...". He 
> also prints out the tree on the stdout if I remove the line "print 
> $tree_string". The variable $tree_string seems to be empty.
> 
> D.
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l
> 




More information about the Bioperl-l mailing list