[Bioperl-l] perl one-liner with Bio::SeqIO

Aaron Mackey amackey at virginia.edu
Thu Jul 22 17:15:18 UTC 2010


You cannot seek on a pipe, unfortunately.  SeqIO should probably try to
detect this, and die rather than invoking GuessSeqFormat.

-Aaron

On Thu, Jul 22, 2010 at 10:30 AM, Stefan Kirov <stefan.kirov at bms.com> wrote:

> From what I see in /bioperl-live/Bio/Tools/GuessSeqFormat.pm
>
>    if (defined $self->{-file}) {
>        # Close the file we opened.
>        close($fh);
>    } elsif (ref $fh eq 'GLOB') {
>        # Try seeking to the start position.
> >>>        seek($fh, $start_pos, 0);
>    } elsif (defined $fh && $fh->can('setpos')) {
>        # Seek to the start position.
>        $fh->setpos($start_pos);
>    }
>    return ($done ? $fmt_string : undef);
>
>  seek($fh, $start_pos, 0); does not reset as expected- tell $fh after reset
> is where the second non-null line starts.
> I am not sure why- all manuals claim this should work?
> Hope this helps.
> Stefan
>
> On 7/22/2010 9:27 AM, Chris Fields wrote:
>
>> cat test.fa | perl -MBio::SeqIO -e 'my $seq=Bio::SeqIO->new(-fh
>> >>>  =>\*STDIN); while ($myseq=$seq->next_seq){ print
>> >>>  $myseq->id,"\t",$myseq->seq,"\n"}
>>
>
>
> _______________________________________________
> 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