[Bioperl-l] flushing i/o with TreeIO

Jason Stajich jason@cgt.mc.duke.edu
Thu, 11 Jul 2002 18:01:49 -0400 (EDT)


On Fri, 12 Jul 2002, Howard Ross wrote:

> This may be a newbie question.
>
> I've been using Bio::TreeIO to manipulate phylogenetic trees. When I use
>    my $treeout = new Bio::TreeIO(-format => 'newick', -file =>  $outfile );
>    ... stuff ...
>    $treeout->write_tree($tree);
>
> (and all the ancillary code) to write the tree to file, I find that the
> output is not flushed and hence not available to ordinary reads from the
> output file, eg
>   while (defined($treeline = <OUTTEMP>)) { ... }

You can do this by destructing the object -
$treeout = undef;
Since Bio::TreeIO objects are Bio::Root::IO objects you should be able to
close the filehandle by saying
$treeout->close();

There is a way to turn autoflushing on by saying
$treeout->fh->autoflush(1) ;
but I think the above will work for you.

HTH.

>
> The only solution I have found is to return from the subroutine where the
> tree manipulation is happening.
>
> How do I flush output to file, or close the output file, to make it
> available for future reads, without having to exit the subroutine?
>
> Thanks,
> Howard
>

-- 
Jason Stajich
Duke University
jason at cgt.mc.duke.edu