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

Stefan Kirov stefan.kirov at bms.com
Thu Jul 22 17:51:59 UTC 2010


Sorry for copying you all, but my posts to bioperl list do not go 
through (my headers seem suspicious).
I proposed (comment on the bug) that seek throws an IO error, I think 
this would be good practice in general (device gets disconnected, etc.)
I agree with Aaron that one option would be that if STDIN is the input 
format MUST be specified or parser dies.
Another option is to right to a temp file or slurp into memory. This 
could be dangerous though...

On 7/22/2010 1:15 PM, Aaron Mackey wrote:
> 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 
> <mailto: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 <mailto:Bioperl-l at lists.open-bio.org>
>     http://lists.open-bio.org/mailman/listinfo/bioperl-l
>
>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: stefan_kirov.vcf
Type: text/x-vcard
Size: 207 bytes
Desc: not available
URL: <http://lists.open-bio.org/pipermail/bioperl-l/attachments/20100722/ad5bd1bb/attachment-0003.vcf>


More information about the Bioperl-l mailing list