[Bioperl-l] Bio::TreeIO -> Reconstructing Newick
Jason Stajich
jason@cgt.mc.duke.edu
Mon, 15 Apr 2002 13:27:42 -0400 (EDT)
You got to open a new file -
my $in_treeio = new Bio::TreeIO('-format' => 'newick',
'-file' => 'treefile.consense');
my $out_treeio = new Bio::TreeIO('-format' => 'newick',
'-file' => '>NEW_treefile.consense');
my $tree = $in_treeio->next_tree;
$out_treeio->write_tree($tree);
Can't use the same handle for both reading and writing.
Note the ">" at the front of the filename in the out_treefile
initialization - this is to tell Perl you are opening a new file.
You can specify a filehandle like STDOUT or a filehandle you have opened
somewhere else with the
-fh => \*STDOUT
or
-fh => $otherFH
in place of the -file key&value in the init hash.
HTH,
Jason
On Mon, 15 Apr 2002, Joseph Ryan wrote:
> I am trying to read in a Newick Treefile, make some adjustments to the
> bootstrap values, and then print back out a treefile. Reading in the treefile
> is a breeze with the Bio::TreeIO module.
>
> my $treeio = new Bio::TreeIO('-format' => 'newick',
> '-file' => 'treefile.consense');
>
> Adjusting the bootstrap values should be fairly straight forward, but I have
> come across a snag in trying to generate an updated newick treefile. I tried
> to use the write_tree method from Bio::TreeIO:
>
> $treeio->write_tree($tree);
>
> But I get the following error:
>
> Filehandle Symbol::GEN0 opened only for input at
> /usr/local/lib/perl5/site_perl/5.6.1/Bio/Root/IO.pm
>
> Is there an easy way to adjust the output stream? Maybe to STDOUT?
>
> Many thanks,
> Joe Ryan
> --
>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Tax Center - online filing with TurboTax
> http://taxes.yahoo.com/
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l@bioperl.org
> http://bioperl.org/mailman/listinfo/bioperl-l
>
--
Jason Stajich
Duke University
jason@cgt.mc.duke.edu