Adapting script to use under CGI

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • idorjee
    New Member
    • Mar 2007
    • 76

    Adapting script to use under CGI

    hi guys,
    i've a perl script which does fine when i execute it as follows on unix environment:

    bash-2.05$ perl <scriptname>

    But, when i used CGI to output the result a browser, i see nothing. can anyone plz check the following to see what's going on. i would appreciate it.


    Code:
    !/usr/bin/perl
    
    #use the CGI module
    use CGI;
    
    use Bio::Perl;
    use Bio::SearchIO;
    use Bio:B::GenPept;
    
    ####there are some more lines here
    
    print STDOUT "<pre>";
    print STDOUT "Performing BLAST....<br>may take few min.....\n";
    
    system("blastall -p blastp -d nrpart -i $seq -o repo.bls");
    
    my $in = new Bio::SearchIO(-format => 'blast', -file => 'repo.bls');
    while( my $result = $in->next_result ) {
    	while( my $hit = $result->next_hit ) {
    		while( my $hsp = $hit->next_hsp ) {
    			if ( $hsp->evalue <= 0.001 ) {
    				print OUTFILE "Accession=",$hit->accession,"\tEvalue=",$hsp->evalue,"\tPercent_id=",$hsp->percent_identity, "\n";
    				push(@1array, $hit->accession);
    			}
    		}
    	}
    }
    
    
    my $genpeptdb = new Bio:B::GenPept();
    my $seqio = Bio::SeqIO->new(-file => ">outputfilename", -format => 'fasta');
    
    #### more lines follows
    thanks
    Last edited by miller; Mar 9 '07, 10:44 PM. Reason: Code Tag
  • miller
    Recognized Expert Top Contributor
    • Oct 2006
    • 1086

    #2
    Can you verify that blastall is being called via the system command when run under the web service?

    Are you assuming that blastall is in the current working directory?
    Does the web service run under a user/group that has execute and access permissions to the blastall?
    Are there any other environmental issues that the webservice would introduce that you are not taking into account?

    Is the OUTFILE location assuming a certain working directory?
    Does the webservice have write permissions for that location?

    Answer these questions and ones like it and you'll be able to get it to work eventually.

    Good Luck,
    - Miller

    Comment

    • idorjee
      New Member
      • Mar 2007
      • 76

      #3
      thanks for your reply, Miller. but there's something that i don't understand. the blastall seems to be working fine when i change the input (-i) to a file in the same directory instead of $seq, which obviously comes from the html form input. however, i can print the $seq variable with print command. do you know what's going on?


      #### part of the script ######

      ...
      my $seq=$query->param("sequenc e");
      print STDOUT "<br>$seq<b r>";

      print STDOUT "<br>The contents of the uploaded file:\n<br></b>\n";

      print STDOUT "<pre>";
      print STDOUT "Performing BLAST....<br>ma y take few min.....\n";

      system("blastal l -p blastp -d /export/home/dorjee/database/nrpart -i \$seq -o repo.bls");
      ......

      Comment

      • idorjee
        New Member
        • Mar 2007
        • 76

        #4
        by the way, blastall is a database search program for protein and dna sequences which can be download (freely) from NCBI (http://www.ncbi.nlm.ni h.gov/). blastp for protein and blastn for nucleotide sequence search.

        :) DJ

        Comment

        • idorjee
          New Member
          • Mar 2007
          • 76

          #5
          thanks for your reply, Miller. but there's something that i don't understand. the blastall seems to be working fine when i change the input (-i) to a file in the same directory instead of $seq, which obviously comes from the html form input. however, i can print the $seq variable with print command. do you know what's going on?


          #### part of the script ######

          ...
          my $seq=$query->param("sequenc e");
          print STDOUT "<br>$seq<b r>";

          print STDOUT "<br>The contents of the uploaded file:\n<br></b>\n";

          print STDOUT "<pre>";
          print STDOUT "Performing BLAST....<br>ma y take few min.....\n";

          system("blastal l -p blastp -d /export/home/dorjee/database/nrpart -i \$seq -o repo.bls");
          ......

          by the way, blastall is a database search program for protein and dna sequences which can be download (freely) from NCBI (http://www.ncbi.nlm.nih.gov/). blastp for protein and blastn for nucleotide sequence search.

          -DJ :)


          Originally posted by miller
          Can you verify that blastall is being called via the system command when run under the web service?

          Are you assuming that blastall is in the current working directory?
          Does the web service run under a user/group that has execute and access permissions to the blastall?
          Are there any other environmental issues that the webservice would introduce that you are not taking into account?

          Is the OUTFILE location assuming a certain working directory?
          Does the webservice have write permissions for that location?

          Answer these questions and ones like it and you'll be able to get it to work eventually.

          Good Luck,
          - Miller

          Comment

          Working...