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

Wijaya Edward ewijaya at i2r.a-star.edu.sg
Mon Jun 5 04:16:59 EDT 2006


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.
--------------------------------------------------------


More information about the Bioperl-l mailing list