[Bioperl-guts-l] bioperl-live/Bio/SearchIO blast.pm,1.115,1.116

Christopher John Fields cjfields at dev.open-bio.org
Sun Jul 15 15:41:40 EDT 2007


Update of /home/repository/bioperl/bioperl-live/Bio/SearchIO
In directory dev.open-bio.org:/tmp/cvs-serv17192

Modified Files:
	blast.pm 
Log Message:
partial fix for bug 1986

Index: blast.pm
===================================================================
RCS file: /home/repository/bioperl/bioperl-live/Bio/SearchIO/blast.pm,v
retrieving revision 1.115
retrieving revision 1.116
diff -C2 -d -r1.115 -r1.116
*** blast.pm	14 Jun 2007 14:16:14 -0000	1.115
--- blast.pm	15 Jul 2007 19:41:37 -0000	1.116
***************
*** 140,143 ****
--- 140,144 ----
  
  use base qw(Bio::SearchIO);
+ use Data::Dumper;
  
  BEGIN {
***************
*** 371,386 ****
      $self->SUPER::_initialize(@args);
  
!  # Blast reports require a specialized version of the SREB due to the
!  # possibility of iterations (PSI-BLAST). Forwarding all arguments to it.
!  # An issue here is that we want to set new default object factories if none are
!  # supplied.
  
      my $handler = Bio::SearchIO::IteratedSearchResultEventBuilder->new(@args);
      $self->attach_EventHandler($handler);
      
!     # 2006-04-26 move this to the attach_handler function in this
!     # module so we can really reset the handler 
      # Optimization: caching
      # the EventHandler since it is used a lot during the parse.
      # $self->{'_handler_cache'} = $handler;
  
--- 372,388 ----
      $self->SUPER::_initialize(@args);
  
!     # Blast reports require a specialized version of the SREB due to the
!     # possibility of iterations (PSI-BLAST). Forwarding all arguments to it. An
!     # issue here is that we want to set new default object factories if none are
!     # supplied.
  
      my $handler = Bio::SearchIO::IteratedSearchResultEventBuilder->new(@args);
      $self->attach_EventHandler($handler);
      
!     # 2006-04-26 move this to the attach_handler function in this module so we
!     # can really reset the handler 
      # Optimization: caching
      # the EventHandler since it is used a lot during the parse.
+     
      # $self->{'_handler_cache'} = $handler;
  
***************
*** 437,440 ****
--- 439,445 ----
                               # lambda, K, H
      local $_ = "\n";   #consistency
+     # bug 1986; try not to rely on hit table for hit significance/score
+     my ($besthit, $besteval);
+     
      PARSER:
      while ( defined( $_ = $self->_readline ) ) {
***************
*** 450,454 ****
            )
          {
!             $self->debug("blast.pm: Start of new report: $1 $2\n");
              if ( $self->{'_seentop'} ) { 
                  # This handles multi-result input streams
--- 455,460 ----
            )
          {
!             ($reporttype, my $reportversion) = ($1, $2);
!             $self->debug("blast.pm: Start of new report: $reporttype, $reportversion\n");
              if ( $self->{'_seentop'} ) { 
                  # This handles multi-result input streams
***************
*** 457,461 ****
              }
              $self->_start_blastoutput;
-             $reporttype = $1;
              if ($reporttype =~ /RPS-BLAST/) {
                  $reporttype .= '(BLASTP)'; # default RPS-BLAST type
--- 463,466 ----
***************
*** 472,476 ****
                  {
                      'Name' => 'BlastOutput_version',
!                     'Data' => $2
                  }
              );
--- 477,481 ----
                  {
                      'Name' => 'BlastOutput_version',
!                     'Data' => $reportversion
                  }
              );
***************
*** 494,507 ****
                  $self->within_element('iteration')
                    && $self->end_element( { 'Name' => 'Iteration' } );
!                 $self->_start_iteration;
              }
              else {
!                 $self->_start_iteration;
              }
              $seeniteration = 1;
          }
          elsif (/^Query=\s*(.*)$/) {
-             $self->debug("blast.pm: Query= found...$_\n");
              my $q    = $1;
              my $size = 0;
              if ( defined $seenquery ) {
--- 499,512 ----
                  $self->within_element('iteration')
                    && $self->end_element( { 'Name' => 'Iteration' } );
!                 $self->start_element( { 'Name' => 'Iteration' } );
              }
              else {
!                 $self->start_element( { 'Name' => 'Iteration' } );
              }
              $seeniteration = 1;
          }
          elsif (/^Query=\s*(.*)$/) {
              my $q    = $1;
+             $self->debug("blast.pm: Query= found...$_\n");
              my $size = 0;
              if ( defined $seenquery ) {
***************
*** 516,523 ****
                          $self->in_element('iteration')
                            && $self->end_element( { 'Name' => 'Iteration' } );
!                         $self->_start_iteration;
                      }
                      else {
!                         $self->_start_iteration;
                      }
                      $seeniteration = 1;
--- 521,528 ----
                          $self->in_element('iteration')
                            && $self->end_element( { 'Name' => 'Iteration' } );
!                         $self->start_element( { 'Name' => 'Iteration' } );
                      }
                      else {
!                         $self->start_element( { 'Name' => 'Iteration' } );
                      }
                      $seeniteration = 1;
***************
*** 591,595 ****
              # for psiblast.
              if ( !$self->in_element('iteration') ) {
!                 $self->_start_iteration;
              }
              # these elements are dropped with some multiquery reports; add
--- 596,600 ----
              # for psiblast.
              if ( !$self->in_element('iteration') ) {
!                 $self->start_element( { 'Name' => 'Iteration' } );
              }
              # these elements are dropped with some multiquery reports; add
***************
*** 613,617 ****
                  }
              ) if $self->{'_blsdb_letters'};
!           descline:
              while ( defined( $_ = $self->_readline() ) ) {
                  
--- 618,622 ----
                  }
              ) if $self->{'_blsdb_letters'};
!           DESCLINE:
              while ( defined( $_ = $self->_readline() ) ) {
                  
***************
*** 657,661 ****
                      ) {
                      $self->_pushback($_); # Catch leading > (end of section)
!                     last descline;
                  }
              }
--- 662,666 ----
                      ) {
                      $self->_pushback($_); # Catch leading > (end of section)
!                     last DESCLINE;
                  }
              }
***************
*** 671,675 ****
  
              if ( !$self->in_element('iteration') ) {
!                 $self->_start_iteration;
              }
  
--- 676,680 ----
  
              if ( !$self->in_element('iteration') ) {
!                 $self->start_element( { 'Name' => 'Iteration' } );
              }
  
***************
*** 756,763 ****
              if ( !$self->within_element('result') ) {
                  $self->_start_blastoutput;
!                 $self->_start_iteration;
              }
              elsif ( !$self->within_element('iteration') ) {
!                 $self->_start_iteration;
              }
              $self->start_element( { 'Name' => 'Hit' } );
--- 761,768 ----
              if ( !$self->within_element('result') ) {
                  $self->_start_blastoutput;
!                 $self->start_element( { 'Name' => 'Iteration' } );
              }
              elsif ( !$self->within_element('iteration') ) {
!                 $self->start_element( { 'Name' => 'Iteration' } );
              }
              $self->start_element( { 'Name' => 'Hit' } );
***************
*** 786,809 ****
              ) if $gi; 
              # add hit significance (from the hit table)
!             # this is where Bug 1986 goes awry
              
!             my $v = shift @hit_signifs;
!                     
!             if ( defined $v ) {
!                 # should perform a sanity check here,
!                 # but that breaks some report parsing.  Needs investigation
!                 
!                 $self->element(
!                     {
!                         'Name' => 'Hit_signif',
!                         'Data' => $v->[0]
!                     }
!                 );
!                 $self->element(
!                     {
!                         'Name' => 'Hit_score',
!                         'Data' => $v->[1]
!                     }
!                 );
              }
              while ( defined( $_ = $self->_readline() ) ) {
--- 791,822 ----
              ) if $gi; 
              # add hit significance (from the hit table)
!             # this is where Bug 1986 went awry
              
!             # get hit significance, score from hit table; maybe we should
!             # use the bestscore, besteval from the HSPs instead?
!             HITTABLE:
!             while (my $v = shift @hit_signifs) {        
!                 # Perform a sanity check here, may break some report parsing.
!                 # Needs further investigation.
!                 my $tableid = $v->[2];
!                 if ($tableid !~ m{$id}) {
!                     $self->debug("Hit table ID $tableid doesn't match current hit id $id, checking next hit table entry...\n");
!                     next HITTABLE;
!                 } else {
!                     $self->debug("Hit table $id match : signif: $v->[0], score: $v->[1]\n");
!                     $self->element(
!                         {
!                             'Name' => 'Hit_signif',
!                             'Data' => $v->[0]
!                         }
!                     );
!                     $self->element(
!                         {
!                             'Name' => 'Hit_score',
!                             'Data' => $v->[1]
!                         }
!                     );
!                     last HITTABLE;
!                 }
              }
              while ( defined( $_ = $self->_readline() ) ) {
***************
*** 1828,1838 ****
  }
  
- sub _start_iteration {
-     my $self = shift;
-     $self->start_element( { 'Name' => 'Iteration' } );
- 
-     #   $self->{'_hit_info'} = undef;
- }
- 
  =head2 _will_handle
  
--- 1841,1844 ----
***************
*** 1907,1916 ****
              $self->{'_handler_rc'} = $handler->$func( $data->{'Attributes'} );
          }
!         else {
              #$self->debug( # changed 4/29/2006 to play nice with other event handlers
              #    "Bio::SearchIO::InternalParserError ".
              #    "\nCan't handle elements of type \'$type.\'"
              #);
!         }
          unshift @{ $self->{'_elements'} }, $type;
          if ( $type eq 'result' ) {
--- 1913,1922 ----
              $self->{'_handler_rc'} = $handler->$func( $data->{'Attributes'} );
          }
!         #else {
              #$self->debug( # changed 4/29/2006 to play nice with other event handlers
              #    "Bio::SearchIO::InternalParserError ".
              #    "\nCan't handle elements of type \'$type.\'"
              #);
!         #}
          unshift @{ $self->{'_elements'} }, $type;
          if ( $type eq 'result' ) {



More information about the Bioperl-guts-l mailing list