[Bioperl-l] use Bio::SeqIO to read Fasta sequence from pipe, or @ARGV, like "while (<>) {....}"

Haiyan Lin linhy0120 at gmail.com
Mon Jul 14 13:47:20 UTC 2014


Hi, Gorge,

Thanks for your advice. 

Best wishes!

Haiyan

On Mon, 2014-07-14 at 06:24 -0700, George Hartzell wrote:
> Haiyan Lin writes:
>  > Thanks all reply and advice first.
>  > 
>  > I want to handle a single can handle data provided in two ways:
>  > 
>  > 1)Read data from a file, such as "perl fastaLen.pl try.fa". No problem
>  > for "-fh=>$filename". 
>  > 
>  > 2)Read data from output of cmmand, such as "less try.fa | perl
>  > fastaLen.pl". No probelm when using "-fh=>\*STDIN".
>  > 
>  > 
>  > And, I can do this by first read data through <>, and write into a tmp
>  > file, and
>  > creat instance of Bio::SeqIO with "-fh=>\$tmpFile", then remove the tmp
>  > file.  I'm looking for a way to avoiding writing/removing tmp file.
> 
> Paul suggested the use of -p to test whether STDIN is a pipe or not,
> which stricly works to your specs.  I don't think it does what *I*
> would expect if you redirect input from a file (foo.pl < moose.fa),
> but that doesn't seem to be one of your requirements.
> 
> Alternatively, you could be more explicit about how it is supposed to
> behave.  One thought would be to use an option on the command line to
> specify the input file and use the name "-" to specify that program
> should read from stdin.  There is a lot of unix tradition in that
> pattern.
> 
> Alternatively^2, you could specify the name of the input file on the
> command line (with an option or without) and if no name was specified
> then read from stdin.
> 
> g.




More information about the Bioperl-l mailing list