[Bioperl-l] What happens to STDOUT?

Chris Fields cjfields at uiuc.edu
Thu Mar 30 23:43:54 UTC 2006


You can redirect to STDOUT by a glob (setting the filehandle to *\STDOUT).
Note that this doesn't use '-file', but '-fh.'   It's in the SeqIO HOWTO:

# create one SeqIO object to read in, and another to write out
my $seqin = Bio::SeqIO->new(-fh     => \*STDIN,
                            -format => $informat);
my $outseq = Bio::SeqIO->new(-fh     => \*STDOUT,
                             -format => $outformat);

Christopher Fields
Postdoctoral Researcher - Switzer Lab
Dept. of Biochemistry
University of Illinois Urbana-Champaign 

> -----Original Message-----
> From: bioperl-l-bounces at lists.open-bio.org [mailto:bioperl-l-
> bounces at lists.open-bio.org] On Behalf Of Torsten Seemann
> Sent: Thursday, March 30, 2006 4:45 PM
> To: golharam at umdnj.edu
> Cc: 'bioperl-l'
> Subject: Re: [Bioperl-l] What happens to STDOUT?
> 
> Ryan,
> 
> > I'm using a simply script to reformat a genbank file to a fasta file.
> > Within the script, I have it print out some information.  That
> > information never appears in the console unless I print it to STDERR.
> > What happened to stdout?  Here's the script:
> > 	while (my $seq = $seqin->next_seq) {
> > 		print $seqout->write_seq($seq);
> 
> This last line shouldn't have a "print" unless you want to print out the
> return
> value from write_seq(). The write_seq() function writes the sequence into
> your
> $fastafile. Perhaps this is cause of the STDOUT issue?
> 
>  > my $seqin = Bio::SeqIO->new(-file => "<$gbkfile", -format => 'genbank'
> );
> 
> It's a good idea to check if the open failed, eg:
> 
> my $seqin = Bio::SeqIO->new(-file => "<$gbkfile", -format => 'genbank') or
> die
> "could not open $gbkfile";
> 
>  > foreach my $gbkfile(`ls *.gbk`) {
> 
> This could also be written more portably as (<*.gbk>) or (glob('*.gbk')).
> 
> --
> Torsten Seemann
> Victorian Bioinformatics Consortium, Monash University, Australia
> http://www.vicbioinformatics.com/
> _______________________________________________
> 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