Bioperl: Problem with 'toStream' and 'fromStream' in Sanger Embl.pm ???
Gordon D. Pusch
pusch@mcs.anl.gov
Sat, 12 Sep 1998 16:43:31 -0500
This is not strictly a question for this group, but I am hoping
someone in it will still be able to help me...
I am trying to use the Sanger EMBL modules I downloaded from
<ftp://ftp.sanger.ac.uk/pub/PerlModules/>, but I am running into
fatal erros on the first two executable lines of the example taken
nearly verbatim (modulo pound-bang line) from the documentation at
<http://www.sanger.ac.uk/Software/PerlModule/Embl.html>.
The lines causing the problems are (slightly reformatted for 72-column
readability --- full script appended below):
# open the stream
open(FH, "$emblFile") || die "oops - could not open $emblFile";
# read all of the embl entries from that stream.
$set = Read Embl(\*FH);
# set is an EMBL:Set object.
$set->toStream(\*STDOUT); # print the entries all out to stdout.
However, the 'Read Embl' line yields the error:
In type EMBL::Parser, can't access fromStream - probably passed a wrong variable into Sequence at /home/wit/Sanger/PerlModules/Embl.pm line 86
Likewise, the '$set->toStream()' line is yielding:
Can't call method "toStream" on unblessed reference at ./scan_embl line 50.
As I said, this example is taken nearly verbatim from the documentation ---
all I have added is the pound-bang line to tell it where perl5 is, a
'use lib' statement to tell it where 'Embl.pm' is; I also replaced the
hardwired filename 'emblFile' in the 'open()' statement with a variable,
so I can run it on any file. Can someone tell me what I am doing wrong ???
Thanks in advance,
-- Gordon D. Pusch <pusch@mcs.anl.gov>
Disclaimer: I'm a consultant collaborating with Argonne researchers;
I don't speak for ANL or the DOE --- and they *certainly* don't speak
for =ME= !!!
Claimer: I report =ALL= SPAMvertisers to their ISP --- =NO= exceptions !!!
------------------------------------------------------------------------
#!/usr/local/bin/perl5
($] >= 5.004) || die "version is $] -- need perl 5.004 or greater";
use lib "/home/wit/Sanger/PerlModules";
use Embl;
if (defined $ENV{"VERBOSE"})
{
foreach $symbol (sort keys %Embl::)
{
local *sym = $Embl::{$symbol};
print "\$$symbol is ", (ref $sym), "\n" if defined $sym;
print "\@$symbol is ", (ref @sym), "\n" if defined @sym;
print "\%$symbol is ", (ref %sym), "\n" if defined %sym;
}
print "\n";
}
( $emblFile = shift @ARGV ) || die "usage: scan_embl embl.file > parsed.output";
# read in some embl files from a stream, and write them to stdout.
#
open(FH, "$emblFile") || die "oops - could not open $emblFile"; # open the stream
$set = Read Embl(\*FH); # read all of the embl entries from that stream.
# die "\$set is a ", (ref $set);
# set is an EMBL:Set object.
$set->toStream(\*STDOUT); # print the entries all out to stdout.
# read in an embl entry from efetch using the default parser
#
$myParser = Embl->defaultParser();
open(EFETCH, "efetch M31544 |") || die "Could not open the file";
$efetch = $myParser->setFromStream(\*EFETCH);
close EFETCH;
# now add this to the entries read from file handle earlier
$set->addSet($efetch);
# could print out again with $set->toEMBLStream
# get an array of all of the EMBL::Entry objects within $set,
# and print each one out to a different file
@entries = $set->entries();
while ($entry = pop @entries)
{
if( ! defined ($id = $entry->ID()) )
{
warn("Got no id for this entry. Skipping...\n");
}
open(OUT, ">$id.embl") || die "could not open this entry file";
$entry->toStream(\*OUT);
close OUT;
}
------------------------------------------------------------------------
=========== Bioperl Project Mailing List Message Footer =======
Project URL: http://bio.perl.org/
For info about how to (un)subscribe, where messages are archived, etc:
http://www.techfak.uni-bielefeld.de/bcd/Perl/Bio/vsns-bcd-perl.html
====================================================================