[Bioperl-guts-l] bioperl-live/Bio/DB/GFF/Adaptor berkeleydb.pm, 1.10, 1.11

Lincoln Stein lstein at pub.open-bio.org
Fri Jul 29 16:04:32 EDT 2005


Update of /home/repository/bioperl/bioperl-live/Bio/DB/GFF/Adaptor
In directory pub.open-bio.org:/tmp/cvs-serv11874/Bio/DB/GFF/Adaptor

Modified Files:
	berkeleydb.pm 
Log Message:
search_notes() is working, but it is too slow -- will need an optimized index for this


Index: berkeleydb.pm
===================================================================
RCS file: /home/repository/bioperl/bioperl-live/Bio/DB/GFF/Adaptor/berkeleydb.pm,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** berkeleydb.pm	29 Jul 2005 16:23:44 -0000	1.10
--- berkeleydb.pm	29 Jul 2005 20:04:30 -0000	1.11
***************
*** 587,591 ****
    #there could be more than one set of attributes......
    while (my ($key, $value) = each %$attributes) {
! 	
      my @features = @{$self->retrieve_features
  		       (-table => "attr", -key => "$key:$value")};
--- 587,591 ----
    #there could be more than one set of attributes......
    while (my ($key, $value) = each %$attributes) {
! 
      my @features = @{$self->retrieve_features
  		       (-table => "attr", -key => "$key:$value")};
***************
*** 611,615 ****
      return unless $feature->{attributes};
      my @attributes = @{$feature->{attributes}};
!     my @values     = map {$_->[1]} @attributes;
      my $value      = "@values";
  
--- 611,615 ----
      return unless $feature->{attributes};
      my @attributes = @{$feature->{attributes}};
!     my @values     = map {lc $_->[0] eq 'note' ? $_->[1] : ()} @attributes;
      my $value      = "@values";
  
***************
*** 618,640 ****
        push @hits,$1;
      }
! 	
      if (@hits) {
        push @matches, scalar @hits;
!       return -1 if @matches >= $limit;
      }
      return scalar @hits;
    };
  
!   my @features = @{$self->filter_features(-table => "attrib__note", -filter => $filter)};
  
!   for (my $i=0; $i<scalar @matches; $i++)  {
      my $feature = $features[$i];
      my $matches = $matches[$i];
! 	
      my $relevance = 10 * $matches;
      my $featname = Bio::DB::GFF::Featname->new($feature->{gclass}=>$feature->{gname});
      my $note;
      $note   = join ' ',map {$_->[1]} grep {$_->[0] eq 'Note'}                @{$feature->{attributes}};
-     $note  .= join ' ',grep /$search/,map {$_->[1]} grep {$_->[0] ne 'Note'} @{$feature->{attributes}};
      push @results,[$featname,$note,$relevance];
    }
--- 618,647 ----
        push @hits,$1;
      }
! 
      if (@hits) {
        push @matches, scalar @hits;
!       return -1 if defined $limit && @matches >= $limit;
      }
      return scalar @hits;
    };
  
!   my @features = @{$self->retrieve_features_range(
! 						  -table => 'attr',
! 						  -start => 'note',
! 						  -filter => $filter,
! 						  -do_while=>sub { my ($feature,$key)=@_;
! 								   $key =~ /^__attr__note/;
! 								 }
! 						 )
! 		 };
  
!   for (my $i=0; $i<@matches; $i++)  {
      my $feature = $features[$i];
      my $matches = $matches[$i];
! 
      my $relevance = 10 * $matches;
      my $featname = Bio::DB::GFF::Featname->new($feature->{gclass}=>$feature->{gname});
      my $note;
      $note   = join ' ',map {$_->[1]} grep {$_->[0] eq 'Note'}                @{$feature->{attributes}};
      push @results,[$featname,$note,$relevance];
    }
***************
*** 652,659 ****
      (@{$search}{qw(rangetype refseq refclass start stop types)},
       @{$options}{qw(sparse sort_by_group ATTRIBUTES temp_table)}) ;
! 	
    $start = 0               unless defined($start);
    $stop  = MAX_BIN         unless defined($stop);
! 	
    my $bin =  bin($start,$stop,MIN_BIN);  
    $bin = $self->normalizeNumber($bin);
--- 659,666 ----
      (@{$search}{qw(rangetype refseq refclass start stop types)},
       @{$options}{qw(sparse sort_by_group ATTRIBUTES temp_table)}) ;
! 
    $start = 0               unless defined($start);
    $stop  = MAX_BIN         unless defined($stop);
! 
    my $bin =  bin($start,$stop,MIN_BIN);  
    $bin = $self->normalizeNumber($bin);
***************
*** 673,677 ****
    my $filter = sub {
      my $feature = shift;
! 	
      my $ref           = $feature->{ref};
      my $feature_start = $feature->{start};
--- 680,684 ----
    my $filter = sub {
      my $feature = shift;
! 
      my $ref           = $feature->{ref};
      my $feature_start = $feature->{start};
***************
*** 730,734 ****
  				       -result => $results);
        }
- 	
        $tier /= 10;
      }
--- 737,740 ----
***************
*** 806,810 ****
  
      my $feat = $self->{data}->get($value);
!     last unless $do_while->($feat);
  
      my $filter_result = $filter ? $filter->($feat) : 1;
--- 812,816 ----
  
      my $feat = $self->{data}->get($value);
!     last unless $do_while->($feat,$key);
  
      my $filter_result = $filter ? $filter->($feat) : 1;
***************
*** 840,844 ****
  
      if (ref($result) eq 'HASH') {
!      $result->{"$feat->{gclass}:$feat->{gname}"} = join($;,$self->_hash_to_array($feat));
      } else {
        push @$result,$feat;
--- 846,850 ----
  
      if (ref($result) eq 'HASH') {
!       $result->{"$feat->{gclass}:$feat->{gname}"} = join($;,$self->_hash_to_array($feat));
      } else {
        push @$result,$feat;



More information about the Bioperl-guts-l mailing list