[Bioperl-l] Writing embl entry to string

TAPO (Thomas Agersten Poulsen) tapo at novozymes.com
Wed Sep 22 03:12:03 EDT 2004


Dear Bernhard and Peter,

	Thank you for the help. I did the IO::String and it works, but
the other solution looks better :-)
Unfortunately I couldn't use in large scale, as it turned out to be too
slow and too many entries were skipped because they did not conform to
the format somehow, so I ended up writing a very simple splitter from
scratch.

Sincerely 
Thomas

-----Original Message-----
From: Bernhard Schmalhofer [mailto:Bernhard.Schmalhofer at biomax.de] 
Sent: 21. september 2004 15:46
To: Peter van Heusden
Cc: TAPO (Thomas Agersten Poulsen); bioperl-l at bioperl.org
Subject: Re: [Bioperl-l] Writing embl entry to string


Peter van Heusden wrote:
> TAPO (Thomas Agersten Poulsen) wrote:
> 
>> Dear List,
>>
>>     I am writing a small script to split embl-files into smaller file
>> of a given maximum file size.
>> To this end, I would like to get the output from
Bio::SeqIO->write_seq 
>> into a string (so I can evaluate length() on it). Would anybody out 
>> there know if this is posible????
>>
>>  
>>
> There's an example describing how to do this in the SeqIO howto at
> http://bioperl.org/HOWTOs/SeqIO/string.html:
> 
>       use IO::String;
>       use Bio::SeqIO;
>             my $str;
>       my $io = IO::String->new(\$str);
>       my $seqOut = Bio::SeqIO->new(-format => 'swiss', 
>                                    -fh     => $io );
>       $seqOut->write_seq($seq_obj);
>       print $str;
> 

As of Perl 5.6.0 following is also possible, and maybe nicer:

        use Bio::SeqIO;
        my $str;
        open( my $str_fh, '>', \$str );
        my $seq_out = Bio::SeqIO->new( -format => 'swiss',
                                       -fh     => $str_fh ); 

        $seq_out->write_seq( $seq_obj );
        print $str;

CU, Bernhard

-- 
**************************************************
Dipl.-Physiker Bernhard Schmalhofer
Senior Developer
Biomax Informatics AG
Lochhamer Str. 11
82152 Martinsried, Germany
Tel: +49 89 895574-839
Fax: +49 89 895574-825
eMail: Bernhard.Schmalhofer at biomax.com
Website: www.biomax.com
**************************************************




More information about the Bioperl-l mailing list