[Bioperl-l] help needed with __DATA__
Shawn Hoon
shawnh at fugu-sg.org
Mon Jul 14 00:18:23 EDT 2003
You need to reset the file handle.
Note sure if this is the best thing to do, but you can use the tell and
seek function of perl:
In subroutine read of base.pm I did the following:
>> lines added
<snip>
>>my $offset;
sub read {
my $self = shift;
my $renzs = new Bio::Restriction::EnzymeCollection(-empty => 1);
>>seek DATA,($offset||=tell DATA), 0;
while (<DATA>) {
chomp;
</snip>
seems to work for me on perl 5.6.1
hth,
shawn
On Sunday, July 13, 2003, at 12:03 PM, Heikki Lehvaslaiho wrote:
> Could anyone suggest a fix, please:
>
> In the new Bio::Restriction analysis system (the relevant classes are
> in
> bioperl-live CVS head) the SeqIO approach is used to to load the
> default
> set of enzymes into a EnzymeCollection from Bio::Restriction::IO::base
> class. I've put the tab delimited list of default enzymes at the end of
> the file after a '__DATA__' line and read it using 'while (<DATA>)'.
>
> This seems to cause a problem. Consecutive calls to code does not seem
> to reset the DATA file handle.
>
> In the following code, the three blocks should work identically but
> only
> the block executed first has enzymes in the collection. One can
> reshuffle the order of code blocks and only the first one will work.
>
> ---------------------------------------------
> use Bio::Restriction::EnzymeCollection;
> use Bio::Restriction::IO;
> use strict;
>
> # 1.
> {
> my $renzs = new Bio::Restriction::EnzymeCollection();
> print scalar $renzs->each_enzyme, "\n";
> }
> #2.
> {
> my $renzs2 = new Bio::Restriction::EnzymeCollection();
> print scalar $renzs2->each_enzyme, "\n";
> }
> #3.
> {
> my $in = new Bio::Restriction::IO; # defaults to 'base.pm'
> my $renzs3 = $in->read;
> print scalar $renzs3->each_enzyme, "\n";
> }
> ---------------------------
>
> Adding 'close DATA' into base.pm will not help. The file handle is not
> automatically opened.
>
> Is this result reproducible?
>
> I am using 'v5.8.0 built for i386-linux-thread-multi'
>
> I could use here documents instead, I guess, but DATA should work,
> too.
>
> -Heikki
>
>
>
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at portal.open-bio.org
> http://portal.open-bio.org/mailman/listinfo/bioperl-l
>
More information about the Bioperl-l
mailing list