[Bioperl-l] issue writing to pipe with bio sequoia

Stephane Plaisance | VIB | stephane.plaisance at vib.be
Wed Jun 1 08:28:08 UTC 2016


Thanks a lot Chris,

Your code example is much more instructive than the text I found on the IO man pages.
If someone has access to (http://bioperl.org/howtos/SeqIO_HOWTO.html <http://bioperl.org/howtos/SeqIO_HOWTO.html>) and could edit some examples for saving to bgzip it would probably help others.
My code now works like a charm and I generate smaller compressed and tabix index-able bgzip Fasta instead of huge plain files.

THANKS to ALL who helped me

Stephane

> On 31 May 2016, at 20:59, Fields, Christopher J <cjfields at illinois.edu> wrote:
> 
> If you are using a piped command you should use a file handle as input, not a file.  Something like:
> 
> open(my $fh,  "  | $bgzip -c >  $outfile\.gz”);
> $seq_out = Bio::SeqIO->new( -format => 'Fasta', -fh => $fh);
> 
> The newFh() method is used for *returning* a tied filehandle for I/O; IMHO I don't recommend this, as it’s pretty confusing and hard to debug (I avoid most anything related to tied variables for the same reason unless it’s absolutely necessary).  It is not used for dealing with a file handle input.
> 
> chris
> 
>> On May 31, 2016, at 9:06 AM, Stephane Plaisance | VIB | <stephane.plaisance at vib.be> wrote:
>> 
>> Dear,
>> I try to bgzip my fasta outpmut fbut have an issue
>> 
>> 
>> my $seq_out;
>> if ( defined($zipit) ) {
>> 	my $bgzip = `which bgzip`;
>> 	chomp($bgzip);
>> 	die "No bgzip command available\n" unless ( $bgzip );
>> 	$seq_out = Bio::SeqIO -> newFh( -format => 'Fasta', -file => "  | $bgzip -c >  $outfile\.gz");
>> } else {
>> 	$seq_out = Bio::SeqIO -> newFh( -format => 'Fasta', -file => ">$outfile" );
>> }
>> 
>> the code fails although bgzip is in my path and the  $bgzip variable sets it right
>> Any help is very welcome
>> 
>> Stephane
>> _______________________________________________
>> Bioperl-l mailing list
>> Bioperl-l at mailman.open-bio.org
>> http://mailman.open-bio.org/mailman/listinfo/bioperl-l
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.open-bio.org/pipermail/bioperl-l/attachments/20160601/c3756114/attachment.html>


More information about the Bioperl-l mailing list