[Biojava-l] Location Objects

mark.schreiber at novartis.com mark.schreiber at novartis.com
Thu Aug 10 02:17:55 UTC 2006


There is the static member of Location, Location.empty , unfortunately it 
is package private. I have just made it public in biojava-live cause I 
can't see why it shouldn't be. You can actually get it from LocationTools 
buy performing an operation that doesn't make sense. For example do an 
intersection of two locations that don't intersect.

If you are using biojava-live from CVS there is also 
RichLocation.EMPTY_LOCATION which is public. RichLocations are basically 
normal locations with more functionality

I'm not certain that they will behaive in the way you expect. An 
EmptyLocation doens't really exist, we only really use it to avoid 
returning null. Thus the min value of an empty is MAX_INT and the max 
value is MIN_INT. This is because they have to have values and 0,0 could 
be a real location so we use this strangely inverted max an min which 
probably best represents some kind of black-hole or something?!

I would be interested to know what happens when you try using one of the 
above for your example below.

Hope this helps,

- Mark

Mark Schreiber
Research Investigator (Bioinformatics)

Novartis Institute for Tropical Diseases (NITD)
10 Biopolis Road
#05-01 Chromos
Singapore 138670
www.nitd.novartis.com

phone +65 6722 2973
fax  +65 6722 2910





"Nathan S. Haigh" <n.haigh at sheffield.ac.uk>
Sent by: biojava-l-bounces at lists.open-bio.org
08/09/2006 09:20 PM

 
        To:     biojava-l at lists.open-bio.org
        cc:     (bcc: Mark Schreiber/GP/Novartis)
        Subject:        [Biojava-l] Location Objects


I apologies for the waffle but i'm a bit stuck with Location objects,
and in particular if a Location object can be empty and if there are
methods for creating, checking and testing for empty Locations.

I'm writing some classes which use Location objects.

It seems to me that it should be possible to create an empty Location
object and also test if a Location object is empty. In addition, it
would be good if the union method could handle these empty Location 
objects.

What i would like to do, is to iterate over columns in an alignment and
determine in that position should be added to the Location object.
Ideally, what i would like to do is to create an empty Location object
and then use the union method to add positions as i iterate over the
alignment columns. In addition, i'm writing a method that takes an
inverse of a Location given an alignment length using the exclude method.

What i'm currently having to do is create a dummy Location object with
position 0,0 - which doesn't make much sense since they should be +ve
integers shouldn't they? Then while itereating over positions in the
alignment, i use LocationTools.union with the dummy Location and a
PointLocation object to add the current position to the Location object
which is being built.

The main problem i have is when i have an alignment of length 20 and a
Location object coving all positions from 1-20 and i want to invert this
Location object. It make sense to return an "empty" Location object, but
i'm using a Location object with coordinates 0,0 for my purposes. At the
moment my JUnit test for inverting the Location object shown above tests
for a Location object with coordinates 0,0:
    Location inv = invLocation(LocationTools.makeLocation(1, 17), 17);
    assertEquals(LocationTools.makeLocation(0,0), inv);

however i get an error like:
junit.framework.AssertionFailedError: expected:<0> but was:<{}>

Therefore, there must be a way to represent an empty Location object,
but it may not be fully implemented. If i use getMin on this inverted
Location (which should be empty) i get a value of 2147483647 with no 
errors.

Thanks
Nathan



<http://www.mozilla.org/products/thunderbird/>
_______________________________________________
Biojava-l mailing list  -  Biojava-l at lists.open-bio.org
http://lists.open-bio.org/mailman/listinfo/biojava-l






More information about the Biojava-l mailing list