[Bioperl-l] difference in opening file from @ARGV and STDIN?

Cook, Malcolm MEC at stowers-institute.org
Thu Sep 11 14:01:01 EDT 2008

Filipe and Dave,

I find that the following works generically for SeqIO and AlignIO (at least)...

#after processing all options using GetOpt,
#any remaining options should name files to process...
@ARGV = ('-') unless @ARGV;     # Default to standard input
my %inopt;
$inopt{-fh} ||=  \*ARGV;
my $AlignIO =  Bio::AlignIO->new(
                        )  or die "calling Bio::AlignIO->new on %inopt" ;


-----Original Message-----
From: bioperl-l-bounces at lists.open-bio.org [mailto:bioperl-l-bounces at lists.open-bio.org] On Behalf Of Dave Messina
Sent: Thursday, September 11, 2008 6:22 AM
To: Felipe Figueiredo
Cc: bioperl-l at lists.open-bio.org
Subject: Re: [Bioperl-l] difference in opening file from @ARGV and STDIN?

Hi Felipe,

Specifying STDIN via a '-' argument to the -file parameter is not valid.
While that is a convention with some UNIX tools, it's not, as far as I know, something you should be able to count on.

In BioPerl, one can specify STDIN by passing the \*STDIN filehandle glob to the -fh parameter (NOT to -file).

In other words,

my $align = Bio::AlignIO->new(-fh => \*STDIN)->next_aln;

That is a convention in BioPerl, so the -file and -fh parameters should work the same way in AlignIO, SearchIO, SeqIO, etc.

Take a look at the beginners' HOWTO for some examples.

Bioperl-l mailing list
Bioperl-l at lists.open-bio.org

More information about the Bioperl-l mailing list