a PerlIO layer for Bio::SeqIO

View: New views
8 Messages — Rating Filter:   Alert me  

a PerlIO layer for Bio::SeqIO

by Mark A. Jensen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...
http://lists.open-bio.org/mailman/listinfo/bioperl-l

Re: a PerlIO layer for Bio::SeqIO

by Smithies, Russell :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@... [mailto:bioperl-l-
> bounces@...] 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@...
> 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@...
http://lists.open-bio.org/mailman/listinfo/bioperl-l

Re: a PerlIO layer for Bio::SeqIO

by Mark A. Jensen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...>
To: "'Mark A. Jensen'" <maj@...>; "'BioPerl List'"
<bioperl-l@...>
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@... [mailto:bioperl-l-
> bounces@...] 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@...
> 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@...
http://lists.open-bio.org/mailman/listinfo/bioperl-l

Re: a PerlIO layer for Bio::SeqIO

by Florent Angly :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...>
> To: "'Mark A. Jensen'" <maj@...>; "'BioPerl List'"
> <bioperl-l@...>
> 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@... [mailto:bioperl-l-
>> bounces@...] 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@...
>> 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@...
> http://lists.open-bio.org/mailman/listinfo/bioperl-l
>

_______________________________________________
Bioperl-l mailing list
Bioperl-l@...
http://lists.open-bio.org/mailman/listinfo/bioperl-l

Re: a PerlIO layer for Bio::SeqIO

by Smithies, Russell :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

In a Statistics seminar I attended recently, the presenter pointed out that Statisticians aren't boring people, they just get excited by boring things.
I think the same applies to Bioinformaticians and Perl programmers  ;-)

--Russell

> -----Original Message-----
> From: Mark A. Jensen [mailto:maj@...]
> Sent: Friday, 23 October 2009 12:04 p.m.
> To: Smithies, Russell; 'BioPerl List'
> Subject: Re: [Bioperl-l] a PerlIO layer for Bio::SeqIO
>
> 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@...>
> To: "'Mark A. Jensen'" <maj@...>; "'BioPerl List'"
> <bioperl-l@...>
> 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@... [mailto:bioperl-l-
> > bounces@...] 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@...
> > 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@...
http://lists.open-bio.org/mailman/listinfo/bioperl-l

Re: a PerlIO layer for Bio::SeqIO

by Mark A. Jensen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This is definitely doable. I will investigate. There is at least one
PerlIO via layer for compression (bzip2); the cool thing about
layers is you should be able to do something like

 open($cfh, '>:via(SeqIO::embl):via(bzip2)', 'my.embl.bz2')

A quick test of passing an IO::Compress handle to via(SeqIO)
indicates I have more a little more work to do. (Gotta fill that
spare time,RS!)
cheers MAJ
----- Original Message -----
From: "Florent Angly" <florent.angly@...>
To: "Mark A. Jensen" <maj@...>
Cc: "Smithies, Russell" <Russell.Smithies@...>; "'BioPerl List'"
<bioperl-l@...>
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@...>
>> To: "'Mark A. Jensen'" <maj@...>; "'BioPerl List'"
>> <bioperl-l@...>
>> 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@... [mailto:bioperl-l-
>>> bounces@...] 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@...
>>> 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@...
>> http://lists.open-bio.org/mailman/listinfo/bioperl-l
>>
>
>
>

_______________________________________________
Bioperl-l mailing list
Bioperl-l@...
http://lists.open-bio.org/mailman/listinfo/bioperl-l

Re: a PerlIO layer for Bio::SeqIO

by Mark A. Jensen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

True that!
----- Original Message -----
From: "Smithies, Russell" <Russell.Smithies@...>
To: "'Mark A. Jensen'" <maj@...>; "'BioPerl List'"
<bioperl-l@...>
Sent: Thursday, October 22, 2009 7:40 PM
Subject: RE: [Bioperl-l] a PerlIO layer for Bio::SeqIO


In a Statistics seminar I attended recently, the presenter pointed out that
Statisticians aren't boring people, they just get excited by boring things.
I think the same applies to Bioinformaticians and Perl programmers  ;-)

--Russell

> -----Original Message-----
> From: Mark A. Jensen [mailto:maj@...]
> Sent: Friday, 23 October 2009 12:04 p.m.
> To: Smithies, Russell; 'BioPerl List'
> Subject: Re: [Bioperl-l] a PerlIO layer for Bio::SeqIO
>
> 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@...>
> To: "'Mark A. Jensen'" <maj@...>; "'BioPerl List'"
> <bioperl-l@...>
> 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@... [mailto:bioperl-l-
> > bounces@...] 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@...
> > 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@...
http://lists.open-bio.org/mailman/listinfo/bioperl-l

Re: a PerlIO layer for Bio::SeqIO

by Mark A. Jensen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...>
To: "Mark A. Jensen" <maj@...>
Cc: "'BioPerl List'" <bioperl-l@...>; "Smithies,Russell"
<Russell.Smithies@...>
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@...>
>> To: "'Mark A. Jensen'" <maj@...>; "'BioPerl List'"
>> <bioperl-l@...>
>> 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@... [mailto:bioperl-l-
>>> bounces@...] 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@...
>>> 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@...
>> http://lists.open-bio.org/mailman/listinfo/bioperl-l
>>
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l@...
> http://lists.open-bio.org/mailman/listinfo/bioperl-l
>
>

_______________________________________________
Bioperl-l mailing list
Bioperl-l@...
http://lists.open-bio.org/mailman/listinfo/bioperl-l