[Bioperl-l] Conflicting CGI.pm with Bio::Tools::GuessSeqFormat ?

Lincoln Stein lstein at cshl.edu
Wed Jun 7 16:50:24 UTC 2006


I'm afraid this strategy won't work with the filehandle retrieved from CGI.pm, 
because the CGI upload filehandle is not seekable (for good reasons that I 
won't inflict on you)! You'll have to write to a temporary file, or else read 
the whole sequence into memory. Sorry about this.

Lincoln

On Monday 05 June 2006 05:02, Sendu Bala wrote:
> Wijaya Edward wrote:
> > Dear Lincoln and experts
> >
> > Curently I have a CGI application that does this:
> >
> > 1.  read and uploaded file
> > 2. check the content of the file whether fasta or not
> > 3. print out the content of the file.
> >
> >
> > Now the problem I'm facing is that
> > on step three. The content of the file handled is altered
> > namely the very first line does not get printed.
>
> The problem is almost certainly that the guessing is done by reading the
> first line of the filehandle, so that your subsequent while loop on that
> same filehandle starts at the second line.
> Just seek the filehandle back to the start before trying to print the
> contents out.
>
> ..
> my $guesser_upload = new Bio::Tools::GuessSeqFormat(-fh => $fh_upload );
> my $format_upload  = $guesser_upload->guess;
> seek($fh_upload, 0, 0);
> ..
> while (<$fh_upload>) {
>      ...
> }
>
> An alternative might be to pass GuessSeqFormat the filename in which
> case it would make its own filehandle and close it, leaving your own
> filehandle untouched.
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l

-- 
Lincoln D. Stein
Cold Spring Harbor Laboratory
1 Bungtown Road
Cold Spring Harbor, NY 11724
(516) 367-8380 (voice)
(516) 367-8389 (fax)
FOR URGENT MESSAGES & SCHEDULING, 
PLEASE CONTACT MY ASSISTANT, 
SANDRA MICHELSEN, AT michelse at cshl.edu



More information about the Bioperl-l mailing list