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

Sendu Bala sb at mrc-dunn.cam.ac.uk
Mon Jun 5 05:02:48 EDT 2006


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.


More information about the Bioperl-l mailing list