[Bioperl-l] Regarding blast in Bioperl

Roopa Raghuveer rtbio.2009 at gmail.com
Mon Jan 25 13:43:19 UTC 2010


Hello Mark,Chris and all,

This is Roopa again. I have a small problem again. I am working on Remote
blast. The program works well. But the problem is this.  The program
accesses the server and gets the output correctly. I am trying to send the
result sequences into an array and I found that always the first sequence
among the Result sequences is missing. The code is

 my $str = Bio::SeqIO->new('-file' => $nuc , '-format' => 'fasta' ,
'-organism' => "$organ\[ORGN]");
- Show quoted text -


while (my $input = $str->next_seq())
{
   #Blast a sequence against a database:
    #Alternatively, you could  pass in a file with many
    #sequences rather than loop through sequence one at a time
    #Remove the loop starting 'while (my $input = $str->next_seq())'
    #and swap the two lines below for an example of that.

             open(OUTFILE,'>',$debugfile);
               print OUTFILE $input;
              close(OUTFILE);


   my $r = $factory->submit_blast($input);

                open(OUTFILE,'>',$debugfile);
             #   print OUTFILE $r;
                close(OUTFILE);


   print STDERR "waiting...." if($v>0);

  while ( my @rids = $factory->each_rid ) {
      open(OUTFILE,'>',$debugfile);
            #   print OUTFILE "while entered";
              close(OUTFILE);
     foreach my $rid ( @rids ) {

               open(OUTFILE,'>',$debugfile);
 #  print OUTFILE "foreach entered";
              close(OUTFILE);

        my $rc = $factory->retrieve_blast($rid);

        if( !ref($rc) )
        {
        if( $rc < 0 )
        {
        $factory->remove_rid($rid);
        }
         open(OUTFILE,'>',$debugfile);
              # print OUTFILE "if entered";
              close(OUTFILE);
         print STDERR "." if ( $v > 0 );
         sleep 5;
        }
       else {
              open(OUTFILE,'>',$debugfile);
              # print OUTFILE "else entered";
              close(OUTFILE);

          my $result = $rc->next_result();
         #save the output
        $blastdebugfile = $serverpath."/blastdebug_".time().".txt";

          open(BLASTDEBUGFILE,'>',$blastdebugfile);
          print BLASTDEBUGFILE $result->next_hit();
          close(BLASTDEBUGFILE);

        my $filename = $serverpath."/blastdata_".
time()."\.out";


         # open(DEBUGFILE,'>',$debugfile);
         # open(new,'>',$filename);
         # @arra=<new>;
         # print DEBUGFILE @arra;
         # close(DEBUGFILE);
         # close(new);

         $factory->save_output($filename);

       # open(BLASTDEBUGFILE,'>',$debugfile);
       # print BLASTDEBUGFILE  "Hello $rid";
       # close(BLASTDEBUGFILE);

       $factory->remove_rid($rid);

       open(BLASTDEBUGFILE,'>',$blastdebugfile);
       print BLASTDEBUGFILE  $organism;
        close(BLASTDEBUGFILE);

    # open(OUTFILE,'>',$outfile);
    # print OUTFILE "Test2 $result->database_name()";
    # close(OUTFILE);

#$hit = $result->next_hit;
#open(new,'>',$debugfile);
#print $hit;
#close(new);
$dummy=0;

   while ( my $hit = $result->next_hit ) {

            next unless ( $v >= 0);

          #     open(OUTFILE,'>',$debugfile);
           #    print OUTFILE "$hit in while hits";
            #  close(OUTFILE);
 my $sequ = $gb->get_Seq_by_version($hit->name);
           my $dna = $sequ->seq(); # get the sequence as a string
        $dummy++;
             open(OUTFILE,'>',$debugfile);
          #     print OUTFILE $dummy;
              close(OUTFILE);
          push(@seqs,$dna);
         }
        }
      }
    }
  }

$warum=@seqs;
 open(OUTFILE,'>',$debugfile);
             #  print OUTFILE $warum;
               print OUTFILE @seqs;

              close(OUTFILE);
return(@seqs);
}

open(OUTFILE, '>',$outfile) || die ;

print OUTFILE "<HTML>\n
<head><title>RNAi Result</title>
<meta http-equiv=\"expires\" content=\"0\"></head>\n
<body>\n
<p><font face=\"Courier, monospace font set\">
Inputsequence: <br>";


Here in the above code, I was trying to debug the code and trying to get the
count of the array and even the sequence. But when the output data was
giving 1 sequence, the count of the array was 0 and when I tried to print
the output sequence I could not get any. It was the same when the no of
output sequences was  3, I tried to print the sequences but was getting the
count of the array as 2 and was printing only two sequences.

Please help me in sorting out this problem.

Regards,
Roopa.



More information about the Bioperl-l mailing list