[Bioperl-l] a PerlIO layer for Bio::SeqIO

Mark A. Jensen maj at fortinbras.us
Fri Oct 30 01:27:27 UTC 2009


Hey Florent --
Got gzip working now. On CPAN, get the current PerlIO::via::gzip (0.021)
and the current PerlIO::via::SeqIO (0.03). Then one can do the following:

compressed, converted output:
 open(my $tfh,"<:via(SeqIO)", "test.fas");
 open(my $zfh,'>:via(SeqIO::embl):via(gzip)', 'test.embl.gz');
 while (<$tfh>) {
     print $zfh $_;
 }
 close($zfh);

decompressed, converted input
 open($tfh,"<:via(gzip):via(SeqIO::fasta)", "test.fas.gz");
 open(my $zfh,'>:via(SeqIO::embl)', 'test.embl');
 while (<$tfh>) {
     print $zfh $_;
 }

gzip-to-gzip conversion:

open(my $tfh, "<:via(gzip):via(SeqIO::fasta)", "test.fas.gz");
 open(my $zfh, ">:via(gzip):via(SeqIO::embl)", "test.embl.gz");
 local $/;
 print $zfh <$tfh>;
 close($zfh);

have fun-- MAJ


----- Original Message ----- 
From: "Florent Angly" <florent.angly at gmail.com>
To: "Mark A. Jensen" <maj at fortinbras.us>
Cc: "'BioPerl List'" <bioperl-l at bioperl.org>; "Smithies,Russell" 
<Russell.Smithies at agresearch.co.nz>
Sent: Thursday, October 22, 2009 7:14 PM
Subject: Re: [Bioperl-l] a PerlIO layer for Bio::SeqIO


> Sounds cool Mark! After all, UNIX is based on the notion on piping data from 
> one program to another using filehandles.
> Any chance that this could also work for compressed files like *.gz ?? I don't 
> think that Bio::Root::Utilities::compress and uncompress can deal with 
> filehandles, can it?
> Florent
>
> Mark A. Jensen wrote:
>> Because it's fun! Also:
>>
>> use CGI;
>> use PerlIO::via::SeqIO;
>> use strict;
>> use warnings;
>> my $q = new CGI;
>> my ($seqfh, $dup);
>> open($seqfh, "<:via(SeqIO)", 'test.fas');
>> open(STDOUT, ">:via(SeqIO::fasta)");
>>
>> my $s = <$seqfh>;
>>
>> print (
>>    $q->start_html,
>>    "Copy the desired format from the boxes below:<br><br>",
>>    $q->div({-style=>"border:solid 1px black"},
>>     $q->h3("FASTA\n"),
>>     $q->pre($s))
>>    );
>> (tied *STDOUT)->set_write_format('embl');
>> print (
>>    $q->div({-style=>"border:solid 1px black"},
>>     $q->h3("EMBL"),
>>     $q->pre($s))
>>    );
>> (tied *STDOUT)->set_write_format('gcg');
>> print (
>>    $q->div({-style=>"border:solid 1px black"},
>>     $q->h3("GCG"),
>>     $q->pre($s)),
>>    $q->end_html
>>    );
>> 1;
>>
>> ----- Original Message ----- From: "Smithies, Russell" 
>> <Russell.Smithies at agresearch.co.nz>
>> To: "'Mark A. Jensen'" <maj at fortinbras.us>; "'BioPerl List'" 
>> <bioperl-l at bioperl.org>
>> Sent: Thursday, October 22, 2009 6:57 PM
>> Subject: RE: [Bioperl-l] a PerlIO layer for Bio::SeqIO
>>
>>
>> Why anyone would want to do it this way is the only thing that's bugging me 
>> ;-)
>> Maybe I'm a bit dense this morning but what's the advantage?
>>
>> --Russell
>> (I need more coffee)
>>
>>> -----Original Message-----
>>> From: bioperl-l-bounces at lists.open-bio.org [mailto:bioperl-l-
>>> bounces at lists.open-bio.org] On Behalf Of Mark A. Jensen
>>> Sent: Friday, 23 October 2009 11:24 a.m.
>>> To: BioPerl List
>>> Subject: [Bioperl-l] a PerlIO layer for Bio::SeqIO
>>>
>>> Hi All:
>>>
>>> Have you ever wanted to do this?
>>>
>>>  open($f, "<:via(SeqIO)", "my.fas");
>>>  open($g, ">:via(SeqIO::embl)", "my.fas.embl");
>>>  while (<$f>) { print $g $_; }
>>>
>>> Or this?
>>>
>>>  open($f, "<:via(SeqIO)", "my.fas");
>>>  open(STDOUT, ">:via(SeqIO::fasta)");
>>>  $seq = <$f>;
>>>  print "The following is an example of FASTA format:", $seq;
>>>
>>> Or even this?
>>>
>>>  (tied *STDOUT)->set_write_format('gcg');
>>>  print "While this is an example of GCG:", $seq;
>>>
>>> Now you can, and much more. See
>>> http://search.cpan.org/search?query=PerlIO::via::SeqIO
>>>
>>> Send me the bugs.
>>> cheers,
>>> MAJ
>>>
>>> _______________________________________________
>>> Bioperl-l mailing list
>>> Bioperl-l at lists.open-bio.org
>>> http://lists.open-bio.org/mailman/listinfo/bioperl-l
>> =======================================================================
>> Attention: The information contained in this message and/or attachments
>> from AgResearch Limited is intended only for the persons or entities
>> to which it is addressed and may contain confidential and/or privileged
>> material. Any review, retransmission, dissemination or other use of, or
>> taking of any action in reliance upon, this information by persons or
>> entities other than the intended recipients is prohibited by AgResearch
>> Limited. If you have received this message in error, please notify the
>> sender immediately.
>> =======================================================================
>>
>>
>> _______________________________________________
>> Bioperl-l mailing list
>> Bioperl-l at lists.open-bio.org
>> http://lists.open-bio.org/mailman/listinfo/bioperl-l
>>
>
> _______________________________________________
> 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