[ensembl-dev] Possible mistake in Bio::EnsEMBL::Feature module

Remo Sanges noncoding at gmail.com
Mon Feb 21 16:25:07 GMT 2011

Dear All,

I think the subroutine 'overlaps' in the Bio::EnsEMBL::Feature module contains potentially dangerous code.

Here is the code in the module downloaded today from the ftp:

=head2 overlaps

   Arg [1]    : Bio::EnsEMBL::Feature $f
                The other feature you want to check overlap with this feature
   Description: This method does a range comparison of this features start and
                end and compares it with another features start and end. It will
                return true if these ranges overlap and the features are on the
                same seq_region.
   Returntype : TRUE if features overlap, FALSE if they don't
   Exceptions : warning if features are on different seq_regions
   Caller     : general
   Status     : Stable


sub overlaps {
   my $self = shift;
   my $f = shift;

   my $sr1_name = $self->seq_region_name;
   my $sr2_name = $f->seq_region_name;

   if ($sr1_name and $sr2_name and ($sr1_name ne $sr2_name)) {
     warning("Bio::EnsEMBL::Feature->overlaps(): features are on different seq regions.");
     return undef;
   return ($self->end >= $f->start and $self->start <= $f->end);

It correctly tests the seq_region_name of the two features, but then the overlap is tested by using 'start' and 'end' calls which might not be related to the specific seq_regions

I think the last line of the sub should be:

   return ($self->seq_region_end >= $f->seq_region_start and $self->seq_region_start <= $f->seq_region_end);

What do you think?



Remo Sanges - Ph.D.
Bioinformatics - Animal Physiology and Evolution
Stazione Zoologica Anton Dohrn
Villa Comunale I, 80121 Napoli - Italy
+39 081 5833428

More information about the Dev mailing list