[Bioperl-l] question about in-between overlapping exact location

George Hartzell hartzell at alerce.com
Wed May 6 04:17:49 UTC 2009


Jason Stajich writes:
 > George -
 > I don't think the location type is taken into account in the overlap  
 > code testing code. Would you expect 2..3 and 3..5 to overlap?
 > 
 > -jason
 > On May 5, 2009, at 2:42 PM, George Hartzell wrote:
 > 
 > >
 > > I was surprised to see that:
 > >
 > >  $ins = Bio::Location::Simple->new(-start => 2,
 > >                                    -end => 3,
 > > 				    -location_type => 'IN-BETWEEN',
 > >                                   );
 > >  $start = Bio::Location::Simple->new(-start => 3,
 > >                                      -end => 5);
 > >
 > >  print "Wow!\n" if $start->overlaps($ins);
 > >
 > > To my mind they would only overlap if the insertion were 3^4 or 4^5.
 > >
 > > Is my mental model of in-between's overlapping exact's wrong, or could
 > > the code be improved (I'm happy to make a change, but...)?

Yep, I'd expect them to overlap.

  1 2 3 4 5
    A T
      T A A

I'm trying to ask a question like the following.  Given a location
that describes an e.g. start codon (3..5) and a description of a
mutation, does the mutation cause a change in the ATG.  Substitutions
are described with exact locations (change bases 3..4 from AT to TA)
and insertions are modeled as in-between locations (insert G at 3^4).

  1 2 3 4 5 6
      A T G
        T G C C

Given 3..5, I can just ask if 3..4 overlaps it (yes), if 3 overlaps it
(yes) and if 3^4 overlaps it (yes).  For things to work out this
easily, 2^3 shouldn't overlap (an insertion there wouldn't change the
codon).

I can get the in-between to work by using RangeI->contains, but then I
end up with 1..4 not "causing a change".

I've ended up with a two part if() that checks the location_type and
uses ->overlap() or ->contains() so that it works out.

g.



More information about the Bioperl-l mailing list