[Bioperl-l] SearchIO speed up

Sendu Bala bix at sendu.me.uk
Thu Aug 17 16:07:10 EDT 2006


Chris Fields wrote:
> I don't feel a pressing nature to keep it, but others will likely disagree. 
> 
> How hard would it be to implement hit(), query(), and other methods in HSPI
> to return Bio::SeqFeature::Similarity objects directly instead of just
> inheriting the methods?  In other words, only build and return the objects
> when the user calls hit() or query()?

I can make HSPI inherit only from Bio::Root::Root and then add the 
following methods to GenericHSP (with no other changes):

sub score {
     my $self = shift;
     if (@_) { $self->{_score} = shift; }
     return $self->{_score};
}

sub bits {
     my $self = shift;
     if (@_) { $self->{_bits} = shift; }
     return $self->{_bits};
}

sub query {
     my $self = shift;
     if (@_) { $self->{_query} = shift; }
     return $self->{_query};
}

sub hit {
     my $self = shift;
     if (@_) { $self->{_hit} = shift; }
     return $self->{_hit};
}

*subject = \&hit;

The entire test suite is happy except for t/SimilarityPair (it tests 
that a HSP is a SimilarityPair, which it obviously isn't anymore) and 
t/WABA, since WABAHSP wants to $self->add_tag_value. Changing that to 
$self->hit->add_tag_value solves the problem.

So, it's trivial to make the change, but of course the test suite 
doesn't use HSPs in all the ways users out there may be using them.

The gain? We see a ~1.5x speed up on worst case scenario (see first post 
to this thread), for just the changes given above.


More information about the Bioperl-l mailing list