[Bioperl-l] Conflicting CGI.pm with Bio::Tools::GuessSeqFormat ?
Lincoln Stein
lstein at cshl.edu
Mon Jun 5 14:51:52 UTC 2006
Hi,
From the Synopsis for GuessSeqFormat:
# To guess the format from an already open filehandle:
my $guesser = new Bio::Tools::GuessSeqFormat( -fh => $filehandle );
my $format = $guesser->guess;
# If the filehandle is seekable (STDIN isn't), it will be
# returned to its original position.
The filehandle returned by CGI.pm is not seekable.
Lincoln
On Monday 05 June 2006 04:16, 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.
>
> So for example if "test1.fasta" looks like this:
> >Seq0
>
> ATCGGGGG
>
> >Seq1
>
> GGGGGGG
>
> >Seq2
>
> ATCCCCCC
>
> When it was printed it gives only:
>
> ATCGGGGG
>
> >Seq1
>
> GGGGGGG
>
> >Seq2
>
> ATCCCCCC
>
> Why is this happening?
>
> Below is the complete cgi script that
> does the task I mentioned earlier.
>
> Did I missed out anything in my code?
>
>
>
> __BEGIN__
> #!/usr/bin/perl -w
>
> use CGI qw/:standard :html3/;
> use CGI::Carp qw( fatalsToBrowser );
> use Data::Dumper;
>
> BEGIN {
> if ( $ENV{PERL5LIB} and $ENV{PERL5LIB} =~ /^(.*)$/ ) {
>
> # Blindly untaint. Taintchecking is to protect
> # from Web data;
> # the environment is under our control.
> eval "use lib '$_';" foreach (
> reverse
> split( /:/, $1 )
> );
> }
> }
>
>
> use Bio::Tools::GuessSeqFormat;
>
> print header,
> start_html('file upload'),
> h1('file upload!');
> print_form() unless param;
> print_results() if param;
> print end_html;
>
> sub print_form {
> print start_multipart_form(),
> filefield(-name=>'upload',-size=>60),br,
> submit(-label=>'Upload File'),
> end_form;
> }
>
> sub print_results {
> my $length;
> my $file = param('upload');
> my $fh_upload = upload('upload');
>
> my $guesser_upload = new Bio::Tools::GuessSeqFormat( -fh => $fh_upload
> ); my $format_upload = $guesser_upload->guess;
>
> if ( !$file ) {
> print "No file uploaded.";
> return;
> }
> print h2('File name'), $file;
> print h2('Format'), $format_upload;
> print h2('The content is'),br;
>
> while (<$fh_upload>) {
>
> # The very first line of the file is not get printed here
> # Why?
>
> print;
> print br;
> $length += length($_);
> }
> print h2('File length'), $length;
> }
>
>
> __END__
>
> Hope to hear from you again.
>
> Regards,
> Edward WIJAYA
> SINGAPORE
>
>
> ------------ Institute For Infocomm Research - Disclaimer -------------
> This email is confidential and may be privileged. If you are not the
> intended recipient, please delete it and notify us immediately. Please do
> not copy or use it for any purpose, or disclose its contents to any other
> person. Thank you. --------------------------------------------------------
--
Lincoln Stein
lstein at cshl.edu
Cold Spring Harbor Laboratory
1 Bungtown Road
Cold Spring Harbor, NY 11724
(516) 367-8380 (voice)
(516) 367-8389 (fax)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.open-bio.org/pipermail/bioperl-l/attachments/20060605/0d6f7bb0/attachment.sig>
More information about the Bioperl-l
mailing list