[Bioperl-l] help needed with __DATA__

Heikki Lehvaslaiho heikki at nildram.co.uk
Sun Jul 13 19:52:39 EDT 2003


Dear Shawn,

Excellent. That works.

I still find it surprising that __DATA__ syntax does not handle all this
automatically.

Thousand thanks,

	-Heikki

On Sun, 2003-07-13 at 23:18, Shawn Hoon wrote:
> 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
> >
> 
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at portal.open-bio.org
> http://portal.open-bio.org/mailman/listinfo/bioperl-l
-- 
______ _/      _/_____________________________________________________
      _/      _/                      http://www.ebi.ac.uk/mutations/
     _/  _/  _/  Heikki Lehvaslaiho    heikki_at_ebi ac uk
    _/_/_/_/_/  EMBL Outstation, European Bioinformatics Institute
   _/  _/  _/  Wellcome Trust Genome Campus, Hinxton
  _/  _/  _/  Cambs. CB10 1SD, United Kingdom
     _/      Phone: +44 (0)1223 494 644   FAX: +44 (0)1223 494 468
___ _/_/_/_/_/________________________________________________________



More information about the Bioperl-l mailing list